!wfudwzqQUiJYJnqfSY:nixos.org

NixOS Module System

82 Members
21 Servers

Load older messages


SenderMessageTime
20 Feb 2024
@infinisil:matrix.orginfinisil djacu: Setting a default with options.foo = lib.mkOption { default = <value>; ... } is equivalent to config.foo = lib.mkOptionDefault <value>; 23:23:21
@infinisil:matrix.orginfinisil Furthermore, default = <value> (and there's defaultText too) can get rendered in the manual, config.foo = ... can't 23:24:14
@djacu:matrix.org@djacu:matrix.orgRight right I forgot about the docs side. I was more focused on merge behavior. So either way they get default priority. Thanks for the explanation!23:48:23
21 Feb 2024
@infinisil:matrix.orginfinisil djacu (Well you need mkOptionDefault to get the same priority for config, which is generally not done) 11:25:22
25 Feb 2024
@olafkfreund:matrix.org@olafkfreund:matrix.org joined the room.22:43:41
1 Mar 2024
@accelbread:matrix.orgaccelbread joined the room.04:27:37
7 Mar 2024
@djacu:matrix.org@djacu:matrix.org

How does the module system handle definitions with no priority?

I've got two modules

{lib, ...}: {
  options = {
    name = lib.mkOption {
      type = lib.types.str;
    };
  };

  config = {
    name = lib.mkDefault "foo";
  };
}
{...}: {
  config = {
    name = "bar";
  };
}

If I evaluate them together, I get "bar" for the value for name. How does it handle this situation? Is is like using mkForce? Does it bypass the priority system completely?

I imagine the answer is somewhere in this function but I am having trouble working through the logic.
https://github.com/hsjobeki/nixpkgs/blob/985fc9b995c07037f6a6273bafa3526f06bb2343/lib/modules.nix#L818

On a side note, this appears to be the place where option declarations with a default attribute value use mkOptionDefault.

04:41:32
@djacu:matrix.org@djacu:matrix.org After digging some more it seems like it actually might happen in mergeDefinitions which calls filterOverrides'. My reading of it leads me to believe that definitions with no priority get set a priority of defaultOverridePriority which is fairly low (100). 05:15:44
9 Mar 2024
@qyriad:katesiria.orgQyriad joined the room.00:39:08
14 Mar 2024
@mjolnir:nixos.orgNixOS Moderation Botchanged room power levels.18:44:27
15 Mar 2024
@spacesbot:nixos.devspacesbot - keeps a log of public NixOS channels joined the room.04:06:23
16 Mar 2024
@nerves:bark.lgbtJason Odoom joined the room.02:12:10
@jee_mj:matrix.orgmj joined the room.14:00:14
17 Mar 2024
@qyriad:matrix.org@qyriad:matrix.org left the room.20:43:44
18 Mar 2024
@infinidoge:matrix.org@infinidoge:matrix.org joined the room.18:47:27
19 Mar 2024
@mjolnir:nixos.orgNixOS Moderation Botchanged room power levels.00:29:53
21 Mar 2024
@mjolnir:nixos.orgNixOS Moderation Botchanged room power levels.18:02:50
22 Mar 2024
@chadac:matrix.orgchadac joined the room.02:03:16
@t3rminal-filth:matrix.orgterminalfilth joined the room.05:13:35
@t3rminal-filth:matrix.orgterminalfilth set a profile picture.05:24:39
@t3rminal-filth:matrix.orgterminalfilth changed their profile picture.05:24:49
23 Mar 2024
@federicodschonborn:matrix.org@federicodschonborn:matrix.org joined the room.00:37:24
@ss:someonex.netSomeoneSerge (utc+3) changed their display name from SomeoneSerge (hash-versioned python modules when) to SomeoneSerge (migrating synapse).02:11:12
27 Mar 2024
@hexa:lossy.networkhexais there a way to set an optional option default?23:21:25
@hexa:lossy.networkhexa
  default = if foo then "bar" else omit;
23:21:46
@hexa:lossy.networkhexa *
  default = if foo then "bar" else omit; # if not foo, consider the value unset
23:22:21
@hexa:lossy.networkhexauhhhhhh23:25:58
@hexa:lossy.networkhexacan I like23:26:00
@hexa:lossy.networkhexa
  bla = mkOption {
  } // lib.optionalAttrs (cond) {
    default = "bar";
  };
23:26:37
@hexa:lossy.networkhexaprobably can23:26:51

Show newer messages


Back to Room ListRoom Version: 10