!wfudwzqQUiJYJnqfSY:nixos.org

NixOS Module System

143 Members
28 Servers

You have reached the beginning of time (for this room).


SenderMessageTime
31 May 2025
@bew:matrix.orgbew joined the room.13:10:36
@bew:matrix.orgbewHello! Given I am making a custom module system, and I have set _module.args.foobar = "something". I'm trying to use eval.extendModules and override the _module.args.foobar with a value with higher priority (by 1). In my case I cannot just hardcode another priority because the extendModules might be called multiple times, thus I need to override foobar multiple times. I tried finding the highestPrio field of _module.args.foobar using eval.options._module.args.foobar.highestPrio but it's saying that foobar doesn't exist here. Am I missing something? 13:11:04
@bew:matrix.orgbew *

Hello!

Given I am making a custom module system, and I have set _module.args.foobar = "something".
I'm trying to use eval.extendModules and override the _module.args.foobar with a value with higher priority (by 1).
In my case I cannot just hardcode another priority because the extendModules might be called multiple times, thus I need to override foobar multiple times.
I tried finding the highestPrio field of _module.args.foobar using eval.options._module.args.foobar.highestPrio but it's saying that foobar doesn't exist here.
Am I missing something?

13:13:31
@bew:matrix.orgbew *

Hello!

Given I am making a custom module system, and I have set _module.args.foobar = "something".
I'm trying to use eval.extendModules and override the _module.args.foobar with a value with higher priority (by 1).
In my case I cannot just hardcode another priority because the extendModules might be called multiple times, thus I need to override foobar multiple times.
I tried finding the highestPrio field of _module.args.foobar using eval.options._module.args.foobar.highestPrio but it's saying that foobar doesn't exist here.
Am I missing something?

13:14:01
@bew:matrix.orgbew *

Hello!

Given I am making a custom module system, and I have set _module.args.foobar = "something".
I'm trying to use eval.extendModules and override the _module.args.foobar with a value with higher priority (by 1).
In my case I cannot just hardcode another priority because the extendModules might be called multiple times, thus I need to override foobar multiple times.
Currently I do this by keeping track of the previous priority manually out of band (I re-implemented a kind of extendModules myself before discovering that it exists 👀), but I recently discovered highestPrio which would allow me to find the previous prio directly on the last module eval.

I tried finding the highestPrio field of _module.args.foobar using eval.options._module.args.foobar.highestPrio but it's saying that foobar doesn't exist here.

Am I missing something?

13:18:15
@bew:matrix.orgbew *

Hello!

I am making a custom module system, and I have set _module.args.foobar = mkOverride 1000 "something".
I'm trying to use eval.extendModules and override the _module.args.foobar with a value with higher priority (by 1).
In my case I cannot just hardcode 999 here because the extendModules might be called multiple times, thus I need to override foobar multiple times with priority 998 then 997, etc...
Currently I do this by keeping track of the previous priority manually out of band (I re-implemented a kind of extendModules myself before discovering that it exists 👀), but I recently discovered highestPrio which would allow me to find the previous prio directly on the last module eval.

I tried finding the highestPrio field of _module.args.foobar using eval.options._module.args.foobar.highestPrio but it's saying that foobar doesn't exist here.

Am I missing something?

13:21:48
@bew:matrix.orgbew *

Hello!

I am making a custom module system, and I have set _module.args.foobar = mkOverride 1000 "something".
I'm trying to use eval.extendModules and override the _module.args.foobar with a value with higher priority (by 1).
In my case I cannot just hardcode 999 here because the extendModules might be called multiple times, thus I need to override foobar multiple times with priority 998 then 997, etc...
Currently I do this by keeping track of the previous priority manually out of band (I re-implemented a kind of extendModules myself before discovering that it exists 👀), but I recently discovered highestPrio which would allow me to find the previous prio directly on the last module eval.

I tried finding the highestPrio field of _module.args.foobar using eval.options._module.args.foobar.highestPrio but it's saying that foobar doesn't exist here.

What am I missing? 🤔

13:22:48
@bew:matrix.orgbew *

Hello!

I am making a custom module system, and I have set _module.args.foobar = mkOverride 1000 "something".
I'm trying to use eval.extendModules and override the _module.args.foobar with a value with higher priority (by 1).
In my case I cannot just hardcode 999 here because the extendModules might be called multiple times, thus I need to override foobar multiple times with priority 998 then 997, etc...
Currently I do this by keeping track of the previous priority manually out of band (I re-implemented a kind of extendModules myself before discovering that it exists 👀), but I recently discovered highestPrio which would allow me to find the previous prio directly on the last module eval.

I tried finding the highestPrio field of _module.args.foobar using eval.options._module.args.foobar.highestPrio but it's saying that foobar doesn't exist here.
It kind of make sense to me because foobar is not an option, it's really part of the config at this point, but then is there still a way to access the priority?

What am I missing? 🤔

13:56:33
@bew:matrix.orgbew *

Hello!

I am making a custom module system, and I have set _module.args.foobar = mkOverride 1000 "something".
I'm trying to use eval.extendModules and override the _module.args.foobar with a value with higher priority (by 1).
In my case I cannot just hardcode 999 here because the extendModules might be called multiple times, thus I need to override foobar multiple times with priority 998 then 997, etc...
Currently I do this by keeping track of the previous priority manually out of band (I re-implemented a kind of extendModules myself before discovering that it exists 👀), but I recently discovered highestPrio which would allow me to find the previous prio directly on the last module eval.

I tried finding the highestPrio field of _module.args.foobar using eval.options._module.args.foobar.highestPrio but it's saying that foobar doesn't exist here.
It kind of make sense to me because foobar is not an option, it's really part of the config at this point, but then is there still a way to access the priority from eval?

What am I missing? 🤔

14:00:34
@bew:matrix.orgbew *

Hello!

I am making a custom module system, and I have set _module.args.foobar = mkOverride 1000 "something".
I'm trying to use eval.extendModules and override the _module.args.foobar with a value with higher priority (by 1).
In my case I cannot just hardcode 999 here because the extendModules might be called multiple times, thus I need to override foobar multiple times with priority 998 then 997, etc...
Currently I do this by keeping track of the previous priority manually out of band (I re-implemented a kind of extendModules myself before discovering that it exists 👀), but I recently discovered highestPrio which would allow me to find the previous prio directly on the last module eval.

I tried finding the highestPrio field of _module.args.foobar using eval.options._module.args.foobar.highestPrio but it's saying that foobar doesn't exist here.
It kind of make sense to me because foobar is not an option, it's really part of the config at this point, but then is there still a way to access the priority from module eval?

What am I missing? 🤔

14:00:51
@mattsturg:matrix.orgMatt Sturgeon

Options have highestPrio (and other) attributes, however in this case _module.args is the option, not _module.args.foobar.

foobar is an attribute of _module.args' value.

You may find it helpful to inspect this in nix repl.

In this case you can use lib.modules.mergeAttrDefinitionsWithPrio to get the priorities of each attr of _module.args; there's an example of this in the nixos/modules/misc/nixpkgs.nix module.

19:03:54
1 Jun 2025
@bew:matrix.orgbewI see, thanks a lot for the answer! In the end I went with a custom option to store some state about the current eval, which allows me to directly be able to access highestPrio on those options 👍10:11:25
@bew:matrix.orgbew* I see, thanks a lot for the answer! In the end I went with a custom options to store some state about the current eval, which allows me to directly be able to access highestPrio on those options 👍10:11:35
@mattsturg:matrix.orgMatt Sturgeon

Awesome. That sounds more idiomatic!

Just a general design titbit: extendModules is more efficient when you don't read anything from the extended configuration.

Due to laziness, extended module evals don't actually need to be fully evaluated, so if you only read from the "final" extended configuration, then you don't need to also spend time evaluating the other ones.

10:18:21
@bew:matrix.orgbew* I see, thanks a lot for the answer! In the end I'm going with a custom options to store some state about the current eval, which allows me to directly be able to access highestPrio on those options 👍11:39:28

Show newer messages


Back to Room ListRoom Version: 10