!wfudwzqQUiJYJnqfSY:nixos.org

NixOS Module System

82 Members
21 Servers

Load older messages


SenderMessageTime
14 Sep 2024
@mwoodpatrickmx:matrix.orgmwoodpatrickmx joined the room.16:12:46
15 Sep 2024
@brisingr05:matrix.org@brisingr05:matrix.org left the room.23:40:59
16 Sep 2024
@silentlurker:matrix.orgsilentlurker joined the room.19:56:52
17 Sep 2024
@vandycarlos:matrix.orgvandycarlos joined the room.01:25:05
18 Sep 2024
@llakala:matrix.orgllakala joined the room.03:12:22
@jopejoe1:matrix.orgjopejoe1 joined the room.14:26:32
@artur:glasgow.social(artur 'manuel) changed their profile picture.23:01:34
21 Sep 2024
@luna-null:matrix.orgAutumn joined the room.05:44:16
24 Sep 2024
@ckie:ckie.devmei 🌒& changed their profile picture.23:21:50
25 Sep 2024
@luna-null:matrix.orgAutumn changed their display name from luna-null to Autumn.06:39:16
@brian:bmcgee.ie@brian:bmcgee.ie left the room.08:38:01
30 Sep 2024
@mattsturg:matrix.orgMatt Sturgeon

I'm getting weird and hard to reproduce issues when attempting to extend/override a type's merge function.

I ran into this a while back when extending coercedTo into a deprecation transition type.

I just ran into it again when attempting to remove a deprecated attr from a submodule's final value.

I've attempted to find a MRE, but in simple examples overriding the type's merge attr seems to behave as expected.

Have I found a nix bug? Or is there some other quirkiness going on here?

07:11:04
@mattsturg:matrix.orgMatt Sturgeon *

I'm getting weird and hard to reproduce issues when attempting to extend/override an option-type's merge function.

I ran into this a while back when extending coercedTo into a deprecation transition type.

I just ran into it again when attempting to remove a deprecated attr from a submodule's final value.

I've attempted to find a MRE, but in simple examples overriding the type's merge attr seems to behave as expected.

Have I found a nix bug? Or is there some other quirkiness going on here?

07:11:21
@mattsturg:matrix.orgMatt Sturgeon

My MRE attempt is producing the expected behavior:

nix-repl> (lib.modules.mergeDefinitions [] result.list-type' [ { file = "."; value = ["a"]; } { file = "."; value = ["b"]; } ]).mergedValue                  [ "a'" "b'" ]

nix-repl> (lib.modules.mergeDefinitions [] result.configuration.options.list'.type [ { file = "."; value = ["a"]; } { file = "."; value = ["b"]; } ]).mergedV[ "a'" "b'" ]

nix-repl> (lib.modules.mergeDefinitions [] result.attrs-type' [ { file = "."; value = { a = "a"; }; } { file = "."; value = { b = "b"; }; } ]).mergedValue   { a = "a'"; b = "b'"; }

nix-repl> (lib.modules.mergeDefinitions [] result.configuration.options.attrs'.type [ { file = "."; value = { a = "a"; }; } { file = "."; value = { b = "b"; { a = "a'"; b = "b'"; }

So I'm struggling to understand why in #2342 I have issues where the the type behaves differently after being used in evalModules and/or listOf:

nix-repl> (lib.modules.mergeDefinitions [] lib.nixvim.keymaps.deprecatedMapOptionSubmodule  [ { file = "."; value = {key = "a"; action = "b";}; } ]).mergedValue
{ action = "b"; key = "a"; mode = ""; options = { ... }; }

nix-repl> (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type.nestedTypes.elemType  [ { file = "."; value ={ action = "b"; key = "a"; lua = «error: error:
       … while evaluating the attribute 'value'

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:9:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          822|         inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:17:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |                 ^
          822|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `lua' was accessed but has no value defined. Try setting the option.»; mode = ""; options = { ... }; }

nix-repl> builtins.head (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type  [ { file = "."; value = [{key = "a"; action = "b";}]; } { file = "."; value = [{ key = "c"; action = "d";}]; } ]).mergedValue
{ action = "b"; key = "a"; lua = «error: error:
       … while evaluating the attribute 'value'

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:9:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          822|         inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:17:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |                 ^
          822|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `"[definition 1-entry 1]".lua' was accessed but has no value defined. Try setting the option.»; mode = ""; options = { ... }; }

NOTE: legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type.nestedTypes.elemType and lib.nixvim.keymaps.deprecatedMapOptionSubmodule should be the same thing, but one works correctly while the other does not.

07:37:44
@mattsturg:matrix.orgMatt Sturgeon *

My MRE attempt is producing the expected behavior:

nix-repl> (lib.modules.mergeDefinitions [] result.list-type' [ { file = "."; value = ["a"]; } { file = "."; value = ["b"]; } ]).mergedValue
[ "a'" "b'" ]

nix-repl> (lib.modules.mergeDefinitions [] result.configuration.options.list'.type [ { file = "."; value = ["a"]; } { file = "."; value = ["b"]; } ]).mergedValue
[ "a'" "b'" ]

nix-repl> (lib.modules.mergeDefinitions [] result.attrs-type' [ { file = "."; value = { a = "a"; }; } { file = "."; value = { b = "b"; }; } ]).mergedValue
{ a = "a'"; b = "b'"; }

nix-repl> (lib.modules.mergeDefinitions [] result.configuration.options.attrs'.type [ { file = "."; value = { a = "a"; }; } { file = "."; value = { b = "b"; }; } ]).mergedValue
{ a = "a'"; b = "b'"; }

So I'm struggling to understand why in #2342 I have issues where the the type behaves differently after being used in evalModules and/or listOf:

nix-repl> (lib.modules.mergeDefinitions [] lib.nixvim.keymaps.deprecatedMapOptionSubmodule  [ { file = "."; value = {key = "a"; action = "b";}; } ]).mergedValue
{ action = "b"; key = "a"; mode = ""; options = { ... }; }

nix-repl> (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type.nestedTypes.elemType  [ { file = "."; value ={ action = "b"; key = "a"; lua = «error: error:
       … while evaluating the attribute 'value'

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:9:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          822|         inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:17:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |                 ^
          822|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `lua' was accessed but has no value defined. Try setting the option.»; mode = ""; options = { ... }; }

nix-repl> builtins.head (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type  [ { file = "."; value = [{key = "a"; action = "b";}]; } { file = "."; value = [{ key = "c"; action = "d";}]; } ]).mergedValue
{ action = "b"; key = "a"; lua = «error: error:
       … while evaluating the attribute 'value'

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:9:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          822|         inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:17:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |                 ^
          822|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `"[definition 1-entry 1]".lua' was accessed but has no value defined. Try setting the option.»; mode = ""; options = { ... }; }

NOTE: legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type.nestedTypes.elemType and lib.nixvim.keymaps.deprecatedMapOptionSubmodule should be the same thing, but one works correctly while the other does not.

07:41:01
@mattsturg:matrix.orgMatt Sturgeon *

My MRE attempt is producing the expected behavior:

nix-repl> (lib.modules.mergeDefinitions [] result.list-type' [ { file = "."; value = ["a"]; } { file = "."; value = ["b"]; } ]).mergedValue
[ "a'" "b'" ]

nix-repl> (lib.modules.mergeDefinitions [] result.configuration.options.list'.type [ { file = "."; value = ["a"]; } { file = "."; value = ["b"]; } ]).mergedValue
[ "a'" "b'" ]

nix-repl> (lib.modules.mergeDefinitions [] result.attrs-type' [ { file = "."; value = { a = "a"; }; } { file = "."; value = { b = "b"; }; } ]).mergedValue
{ a = "a'"; b = "b'"; }

nix-repl> (lib.modules.mergeDefinitions [] result.configuration.options.attrs'.type [ { file = "."; value = { a = "a"; }; } { file = "."; value = { b = "b"; }; } ]).mergedValue
{ a = "a'"; b = "b'"; }

So I'm struggling to understand why in #2342 I have issues where the the type behaves differently after being used in evalModules and/or listOf:

nix-repl> (lib.modules.mergeDefinitions [] lib.nixvim.keymaps.deprecatedMapOptionSubmodule  [ { file = "."; value = {key = "a"; action = "b";}; } ]).mergedValue
{ action = "b"; key = "a"; mode = ""; options = { ... }; }

nix-repl> (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type.nestedTypes.elemType  [ { file = "."; value ={ action = "b"; key = "a"; lua = «error: error:
       … while evaluating the attribute 'value'

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:9:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          822|         inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:17:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |                 ^
          822|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `lua' was accessed but has no value defined. Try setting the option.»; mode = ""; options = { ... }; }

nix-repl> builtins.head (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type  [ { file = "."; value = [{key = "a"; action = "b";}]; } { file = "."; value = [{ key = "c"; action = "d";}]; } ]).mergedValue
{ action = "b"; key = "a"; lua = «error: error:
       … while evaluating the attribute 'value'

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:9:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          822|         inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:17:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |                 ^
          822|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `"[definition 1-entry 1]".lua' was accessed but has no value defined. Try setting the option.»; mode = ""; options = { ... }; }

NOTE: legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type.nestedTypes.elemType and lib.nixvim.keymaps.deprecatedMapOptionSubmodule should be the same thing, but one works correctly while the other does not.

EDIT: Accessing lib via special args also does not produce the issue (i.e. works correctly):

nix-repl> (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration._module.specialArgs.lib.nixvim.keymaps.deprecatedMapOptionSubmodule  [ { file = "."; value = {key = "a"; action = "b";}; } ]).mergedValue
{ action = "b"; key = "a"; mode = ""; options = { ... }; }

07:45:01
@mattsturg:matrix.orgMatt Sturgeon *

My MRE attempt is producing the expected behavior:

nix-repl> (lib.modules.mergeDefinitions [] result.list-type' [ { file = "."; value = ["a"]; } { file = "."; value = ["b"]; } ]).mergedValue
[ "a'" "b'" ]

nix-repl> (lib.modules.mergeDefinitions [] result.configuration.options.list'.type [ { file = "."; value = ["a"]; } { file = "."; value = ["b"]; } ]).mergedValue
[ "a'" "b'" ]

nix-repl> (lib.modules.mergeDefinitions [] result.attrs-type' [ { file = "."; value = { a = "a"; }; } { file = "."; value = { b = "b"; }; } ]).mergedValue
{ a = "a'"; b = "b'"; }

nix-repl> (lib.modules.mergeDefinitions [] result.configuration.options.attrs'.type [ { file = "."; value = { a = "a"; }; } { file = "."; value = { b = "b"; }; } ]).mergedValue
{ a = "a'"; b = "b'"; }

So I'm struggling to understand why in #2342 I have issues where the the type behaves differently after being used in evalModules and/or listOf:

nix-repl> (lib.modules.mergeDefinitions [] lib.nixvim.keymaps.deprecatedMapOptionSubmodule  [ { file = "."; value = {key = "a"; action = "b";}; } ]).mergedValue
{ action = "b"; key = "a"; mode = ""; options = { ... }; }

nix-repl> (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type.nestedTypes.elemType  [ { file = "."; value ={ action = "b"; key = "a"; lua = «error: error:
       … while evaluating the attribute 'value'

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:9:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          822|         inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:17:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |                 ^
          822|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `lua' was accessed but has no value defined. Try setting the option.»; mode = ""; options = { ... }; }

nix-repl> builtins.head (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type  [ { file = "."; value = [{key = "a"; action = "b";}]; } { file = "."; value = [{ key = "c"; action = "d";}]; } ]).mergedValue
{ action = "b"; key = "a"; lua = «error: error:
       … while evaluating the attribute 'value'

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:9:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          822|         inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:17:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |                 ^
          822|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `"[definition 1-entry 1]".lua' was accessed but has no value defined. Try setting the option.»; mode = ""; options = { ... }; }

NOTE: legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type.nestedTypes.elemType and lib.nixvim.keymaps.deprecatedMapOptionSubmodule should be the same thing, but one works correctly while the other does not. The keymaps option is literally defined as:

keymaps = lib.mkOption {
  type = lib.types.listOf helpers.keymaps.deprecatedMapOptionSubmodule;
  # ...
}

EDIT: Accessing lib via special args also does not produce the issue (i.e. works correctly):

nix-repl> (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration._module.specialArgs.lib.nixvim.keymaps.deprecatedMapOptionSubmodule  [ { file = "."; value = {key = "a"; action = "b";}; } ]).mergedValue
{ action = "b"; key = "a"; mode = ""; options = { ... }; }

07:48:54
@mattsturg:matrix.orgMatt Sturgeon *

My MRE attempt is producing the expected behavior:

nix-repl> (lib.modules.mergeDefinitions [] result.list-type' [ { file = "."; value = ["a"]; } { file = "."; value = ["b"]; } ]).mergedValue
[ "a'" "b'" ]

nix-repl> (lib.modules.mergeDefinitions [] result.configuration.options.list'.type [ { file = "."; value = ["a"]; } { file = "."; value = ["b"]; } ]).mergedValue
[ "a'" "b'" ]

nix-repl> (lib.modules.mergeDefinitions [] result.attrs-type' [ { file = "."; value = { a = "a"; }; } { file = "."; value = { b = "b"; }; } ]).mergedValue
{ a = "a'"; b = "b'"; }

nix-repl> (lib.modules.mergeDefinitions [] result.configuration.options.attrs'.type [ { file = "."; value = { a = "a"; }; } { file = "."; value = { b = "b"; }; } ]).mergedValue
{ a = "a'"; b = "b'"; }

So I'm struggling to understand why in #2342 I have issues where the the type behaves differently after being used in evalModules and/or listOf:

nix-repl> (lib.modules.mergeDefinitions [] lib.nixvim.keymaps.deprecatedMapOptionSubmodule  [ { file = "."; value = {key = "a"; action = "b";}; } ]).mergedValue
{ action = "b"; key = "a"; mode = ""; options = { ... }; }

nix-repl> (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type.nestedTypes.elemType  [ { file = "."; value ={ action = "b"; key = "a"; lua = «error: error:
       … while evaluating the attribute 'value'

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:9:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          822|         inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:17:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |                 ^
          822|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `lua' was accessed but has no value defined. Try setting the option.»; mode = ""; options = { ... }; }

nix-repl> builtins.head (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type  [ { file = "."; value = [{key = "a"; action = "b";}]; } { file = "."; value = [{ key = "c"; action = "d";}]; } ]).mergedValue
{ action = "b"; key = "a"; lua = «error: error:
       … while evaluating the attribute 'value'

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:9:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          822|         inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:17:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |                 ^
          822|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `"[definition 1-entry 1]".lua' was accessed but has no value defined. Try setting the option.»; mode = ""; options = { ... }; }

NOTE: legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type.nestedTypes.elemType and lib.nixvim.keymaps.deprecatedMapOptionSubmodule should be the same thing, but one works correctly while the other does not.

The keymaps option is literally defined as:

keymaps = lib.mkOption {
  type = lib.types.listOf helpers.keymaps.deprecatedMapOptionSubmodule;
  # ...
}

EDIT: Accessing lib via special args also does not produce the issue (i.e. works correctly):

nix-repl> (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration._module.specialArgs.lib.nixvim.keymaps.deprecatedMapOptionSubmodule  [ { file = "."; value = {key = "a"; action = "b";}; } ]).mergedValue
{ action = "b"; key = "a"; mode = ""; options = { ... }; }

07:49:22
@mattsturg:matrix.orgMatt Sturgeon *

My MRE attempt is producing the expected behavior:

nix-repl> (lib.modules.mergeDefinitions [] result.list-type' [ { file = "."; value = ["a"]; } { file = "."; value = ["b"]; } ]).mergedValue
[ "a'" "b'" ]

nix-repl> (lib.modules.mergeDefinitions [] result.configuration.options.list'.type [ { file = "."; value = ["a"]; } { file = "."; value = ["b"]; } ]).mergedValue
[ "a'" "b'" ]

nix-repl> (lib.modules.mergeDefinitions [] result.attrs-type' [ { file = "."; value = { a = "a"; }; } { file = "."; value = { b = "b"; }; } ]).mergedValue
{ a = "a'"; b = "b'"; }

nix-repl> (lib.modules.mergeDefinitions [] result.configuration.options.attrs'.type [ { file = "."; value = { a = "a"; }; } { file = "."; value = { b = "b"; }; } ]).mergedValue
{ a = "a'"; b = "b'"; }

So I'm struggling to understand why in #2342 I have issues where the the type behaves differently after being used in evalModules and/or listOf:

nix-repl> (lib.modules.mergeDefinitions [] lib.nixvim.keymaps.deprecatedMapOptionSubmodule  [ { file = "."; value = {key = "a"; action = "b";}; } ]).mergedValue
{ action = "b"; key = "a"; mode = ""; options = { ... }; }

nix-repl> (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type.nestedTypes.elemType  [ { file = "."; value ={ action = "b"; key = "a"; lua = «error: error:
       … while evaluating the attribute 'value'

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:9:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          822|         inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:17:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |                 ^
          822|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `lua' was accessed but has no value defined. Try setting the option.»; mode = ""; options = { ... }; }

nix-repl> builtins.head (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type  [ { file = "."; value = [{key = "a"; action = "b";}]; } { file = "."; value = [{ key = "c"; action = "d";}]; } ]).mergedValue
{ action = "b"; key = "a"; lua = «error: error:
       … while evaluating the attribute 'value'

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:9:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          822|         inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin

         at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:17:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |                 ^
          822|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `"[definition 1-entry 1]".lua' was accessed but has no value defined. Try setting the option.»; mode = ""; options = { ... }; }

NOTE: legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type.nestedTypes.elemType and lib.nixvim.keymaps.deprecatedMapOptionSubmodule should be the same thing, but one works correctly while the other does not.

The keymaps option is literally defined as:

keymaps = lib.mkOption {
  type = lib.types.listOf lib.nixvim.keymaps.deprecatedMapOptionSubmodule;
  # ...
}

EDIT: Accessing lib via special args also does not produce the issue (i.e. works correctly):

nix-repl> (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration._module.specialArgs.lib.nixvim.keymaps.deprecatedMapOptionSubmodule  [ { file = "."; value = {key = "a"; action = "b";}; } ]).mergedValue
{ action = "b"; key = "a"; mode = ""; options = { ... }; }

07:49:46
1 Oct 2024
@-_o:matrix.org-_o joined the room.21:03:34
2 Oct 2024
@cafkafk:fem.ggcafkafk 🏳️‍⚧️ joined the room.12:19:06
4 Oct 2024
@terrorjack:matrix.terrorjack.comterrorjack joined the room.17:38:04
7 Oct 2024
@thunder:kotiboksi.xyzThunder joined the room.08:26:57
@lehmanator:tchncs.deSam Lehman changed their profile picture.14:24:14
10 Oct 2024
@p4cmanus3r:matrix.orgp4cmanus3r joined the room.13:24:45
11 Oct 2024
@lehmanator:tchncs.deSam Lehman

Are there any good writeups on using lib.types?

I've gone through the manual, the nix.dev deep dive, and a bunch of other Nix module related posts, but nothing seems to cover the more advanced use cases of lib.types and submodules.

15:12:19
@artturin:matrix.orgArtturin joined the room.19:28:40
15 Oct 2024
@pyrox:pyrox.devdish [Fox/It/She] joined the room.03:21:06
19 Oct 2024
@jwillikers:matrix.orgjwillikers joined the room.12:07:59
21 Oct 2024
@artur:glasgow.social(artur 'manuel) changed their display name from (lambda (f l) (format nil "~a ~a")) "Artur" "Manuel" to (artur 'manuel).20:04:44

There are no newer messages yet.


Back to Room ListRoom Version: 10