!wfudwzqQUiJYJnqfSY:nixos.org

NixOS Module System

82 Members
21 Servers

Load older messages


SenderMessageTime
21 May 2024
@nbp:mozilla.orgnbpsubmodules are a non-evaluated set of modules which would be evaluated to compute the result.09:17:39
@nbp:mozilla.orgnbpIf you look at the various virtualisation options, you will find some which are re-importing NixOS modules, or suggesting to make mutation to the system configuration IIRC09:18:41
22 May 2024
@mjolnir:nixos.orgNixOS Moderation Botchanged room power levels.15:25:50
@mjolnir:nixos.orgNixOS Moderation Botchanged room power levels.15:28:05
@infinidoge:matrix.org@infinidoge:matrix.org changed their display name from Infinidoge to Migrated to @infinidoge:inx.moe.21:36:24
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️ joined the room.22:19:53
@infinidoge:matrix.org@infinidoge:matrix.org left the room.22:21:14
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️ changed their display name from Infinidoge 🏳️‍⚧️ to Migrated to @infinidoge:inx.moe.22:35:31
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️ changed their display name from Migrated to @infinidoge:inx.moe to Infinidoge.22:37:11
23 May 2024
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️ changed their display name from Infinidoge to Infinidoge🏳️‍⚧️.01:31:17
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️ changed their display name from Infinidoge🏳️‍⚧️ to Infinidoge 🏳️‍⚧️.01:31:27
26 May 2024
@lehmanator:tchncs.deSam LehmanI want to have several profile configs that all import the same base profile config or nixosModules, but I'd like to be able to import multiple of them simultaneously, which results in an error. My goal is to have each profile work as a fully standalone unit, but also be granularly composable into more featured profiles. Is there some pattern that would allow this organization scheme?10:34:14
@lehmanator:tchncs.deSam Lehman

If lib.evalModules recursively enumerates the entire tree of imports prior to config eval, and each path in imports is uniquely identifable, why does it opt to throw an error instead of filtering the paths of the merged imports list with something like lib.unique?

Is there some behavior of the module system that depends on being able to apply the same import multiple times while building the options attrset?

10:37:03
@djacu:matrix.org@djacu:matrix.org Sam Lehman: do you have some example code you could link to? 14:31:39
27 May 2024
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️
In reply to@lehmanator:tchncs.de
I want to have several profile configs that all import the same base profile config or nixosModules, but I'd like to be able to import multiple of them simultaneously, which results in an error. My goal is to have each profile work as a fully standalone unit, but also be granularly composable into more featured profiles. Is there some pattern that would allow this organization scheme?
Probably the easiest way to accomplish something like this would be to have all of the profiles imported, but control what gets applied with options

Something like:
common:
`nix
options = {
profile1 = lib.mkOption {
type = lib.types.bool;
default = false;
};
profile2 = lib.mkOption {
type = lib.types.bool;
default = false;
};
profile3 = lib.mkOption {
type = lib.types.bool;
default = false;
};
};

config = {
# Common config here
};
`profile1`:
```nix
config = lib.mkIf config.profile1 {
  # Profile 1 config here
};
```
`profile2`:
```nix
config = lib.mkIf config.profile2 {
  # Profile 2 config here
};
And so on
01:33:16
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️ Probably the easiest way to accomplish something like this would be to have all of the profiles imported, but control what gets applied with options

Something like:
common:

`nix
options = {
profile1 = lib.mkOption {
type = lib.types.bool;
default = false;
};
profile2 = lib.mkOption {
type = lib.types.bool;
default = false;
};
profile3 = lib.mkOption {
type = lib.types.bool;
default = false;
};
};

config = {
# Common config here
};
`

profile1:

config = lib.mkIf config.profile1 {
  # Profile 1 config here
};

profile2:

config = lib.mkIf config.profile2 {
  # Profile 2 config here
};
And so on
01:33:16
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️Matrix, why must you pain me01:33:24
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️ Probably the easiest way to accomplish something like this would be to have all of the profiles imported, but control what gets applied with options

Something like:
common:

`
options = {
profile1 = lib.mkOption {
type = lib.types.bool;
default = false;
};
profile2 = lib.mkOption {
type = lib.types.bool;
default = false;
};
profile3 = lib.mkOption {
type = lib.types.bool;
default = false;
};
};

config = {
# Common config here
};
`

profile1:

config = lib.mkIf config.profile1 {
  # Profile 1 config here
};

profile2:

config = lib.mkIf config.profile2 {
  # Profile 2 config here
};
And so on
01:33:40
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️ Probably the easiest way to accomplish something like this would be to have all of the profiles imported, but control what gets applied with options

Something like:
common:
`
options = {
profile1 = lib.mkOption {
type = lib.types.bool;
default = false;
};
profile2 = lib.mkOption {
type = lib.types.bool;
default = false;
};
profile3 = lib.mkOption {
type = lib.types.bool;
default = false;
};
};

config = {
# Common config here
};
`

profile1:
config = lib.mkIf config.profile1 {
  # Profile 1 config here
};

profile2:
config = lib.mkIf config.profile2 {
  # Profile 2 config here
};
And so on
01:34:20
@infinidoge:inx.moeInfinidoge 🏳️‍⚧️ Probably the easiest way to accomplish something like this would be to have all of the profiles imported, but control what gets applied with options

Something like:
common:
options = {
  profile1 = lib.mkOption {
    type = lib.types.bool;
    default = false;
  };
  profile2 = lib.mkOption {
    type = lib.types.bool;
    default = false;
  };
  profile3 = lib.mkOption {
    type = lib.types.bool;
    default = false;
  };
};
config = {
  # Common config here
};

profile1:
config = lib.mkIf config.profile1 {
  # Profile 1 config here
};

profile2:
config = lib.mkIf config.profile2 {
  # Profile 2 config here
};
And so on
01:34:41
@nbp:mozilla.orgnbp Sam Lehman: Yes, evalModules should capture the whole tree of imports and deduplicated moduled key property.
However, if you are using flakes, the key attribute is not initialized if the module is not listed as a path, to be imported by the module system.
09:42:10
@nbp:mozilla.orgnbp * Sam Lehman: Yes, evalModules should capture the whole tree of imports and deduplicated moduled key property.
However, if you are using flakes, and define a nixosModules within the flake.nix file, then the key attribute is not initialized to any value which can safely be deduplicated.
09:43:28
@nbp:mozilla.orgnbp infinisil: I just watch your stream from a month ago. _options used to be the default, except that it got removed in favor of toJSON / toTOML functions 🤦 17:07:25
@nbp:mozilla.orgnbp * infinisil: I just watch your stream from a month ago. _options used to be the default in submodules, except that it got removed in favor of toJSON / toTOML functions 🤦 17:07:36
@infinisil:matrix.orginfinisil

@nbp:mozilla.org Aren't you thinking of _module?

17:09:00
@infinisil:matrix.orginfinisil

I'm the one who removed that in submodules ;)

17:10:35
@nbp:mozilla.orgnbp Yes _module was one way to expose the internal details. 17:12:15
@nbp:mozilla.orgnbpThere are multiple problems to finding the declarations of a submodule option.17:12:47
@nbp:mozilla.orgnbpOne of them is the apply function, which implies that the content would be post-processed.17:13:32
@nbp:mozilla.orgnbp

Another one, which I bet nobody noticed, is that you can add submodules at the definition site:

nix-repl> (nixosConfigurations.ouessant.extendModules { modules = [ ({...}: { fileSystems."/" = {lib, ...}: { options.color = lib.mkOption { type = lib.types.str; default = "red"; }; }; }) ]; }).config.fileSystems."/".color
"red"
17:19:11

Show newer messages


Back to Room ListRoom Version: 10