Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: error: value is null while a Boolean was expected for current unstable of nixpkgs and master of home-manager #4035

Closed
2 tasks done
DanielSiepmann opened this issue May 30, 2023 · 7 comments · Fixed by #4036
Assignees
Labels
bug triage Issues or feature request that have not been triaged yet

Comments

@DanielSiepmann
Copy link
Contributor

Are you following the right branch?

  • My Nixpkgs and Home Manager versions are in sync

Is there an existing issue for this?

  • I have searched the existing issues

Issue description

I'm unable to execute home-manager switch with current nixpkgs unstable and home-manager master.

Output of home-manager switch --show-trace
error:
       … while evaluating the attribute 'buildCommand' of the derivation 'home-manager-generation'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:303:7:

          302|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          303|       name =
             |       ^
          304|         let

       … while evaluating the attribute 'text' of the derivation 'activation-script'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:303:7:

          302|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          303|       name =
             |       ^
          304|         let

       … while evaluating call site

       at «none»:0: (source not available)

       … while calling 'mkCmd'

       at /home/daniels/.nix-defexpr/channels/home-manager/modules/home-environment.nix:659:17:

          658|       let
          659|         mkCmd = res: ''
             |                 ^
          660|             _iNote "Activating %s" "${res.name}"

       … while evaluating the attribute 'data'

       at /home/daniels/.nix-defexpr/channels/home-manager/modules/lib/dag.nix:89:37:

           88|     in if sorted ? result then {
           89|       result = map (v: { inherit (v) name data; }) sorted.result;
             |                                     ^
           90|     } else

       … while evaluating the attribute 'data'

       at /home/daniels/.nix-defexpr/channels/home-manager/modules/lib/dag.nix:83:9:

           82|         name = n;
           83|         data = v.data;
             |         ^
           84|         after = v.after ++ dagBefore dag n;

       … while evaluating call site

       at «none»:0: (source not available)

       … while calling 'g'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/attrsets.nix:595:19:

          594|           g =
          595|             name: value:
             |                   ^
          596|             if isAttrs value && cond value

       … while evaluating call site

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/attrsets.nix:598:20:

          597|               then recurse (path ++ [name]) value
          598|               else f (path ++ [name]) value;
             |                    ^
          599|         in mapAttrs g;

       … while calling anonymous lambda

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/modules.nix:248:72:

          247|           # For definitions that have an associated option
          248|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          249|

       … while evaluating the attribute 'value'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/modules.nix:759:9:

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

       … while evaluating the option `home.activation.checkFilesChanged.data':

       … while evaluating the attribute 'mergedValue'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/modules.nix:794:5:

          793|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          794|     mergedValue =
             |     ^
          795|       if isDefined then

       … while evaluating the attribute 'values'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/modules.nix:788:9:

          787|       in {
          788|         values = defs''';
             |         ^
          789|         inherit (defs'') highestPrio;

       … while evaluating the attribute 'values'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/modules.nix:887:7:

          886|     in {
          887|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |       ^
          888|       inherit highestPrio;

       … while evaluating call site

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/modules.nix:774:17:

          773|         # Process mkMerge and mkIf properties.
          774|         defs' = concatMap (m:
             |                 ^
          775|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while calling anonymous lambda

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/modules.nix:774:28:

          773|         # Process mkMerge and mkIf properties.
          774|         defs' = concatMap (m:
             |                            ^
          775|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating definitions from `/home/daniels/.nix-defexpr/channels/home-manager/modules/files.nix':

       … while evaluating call site

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/modules.nix:775:137:

          774|         defs' = concatMap (m:
          775|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          776|         ) defs;

       … while calling 'dischargeProperties'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/modules.nix:846:25:

          845|   */
          846|   dischargeProperties = def:
             |                         ^
          847|     if def._type or "" == "merge" then

       … while evaluating the attribute 'value'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/modules.nix:599:44:

          598|       defnsByName' = byName "config" (module: value:
          599|           [{ inherit (module) file; inherit value; }]
             |                                            ^
          600|         ) configs;

       … while evaluating call site

       at /home/daniels/.nix-defexpr/channels/home-manager/modules/files.nix:299:12:

          298|         declare -A changedFiles
          299|       '' + concatMapStrings (v:
             |            ^
          300|         let

       … while calling 'concatMapStrings'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/strings.nix:59:25:

           58|   */
           59|   concatMapStrings = f: list: concatStrings (map f list);
             |                         ^
           60|

       … while evaluating call site

       at «none»:0: (source not available)

       … while calling anonymous lambda

       at /home/daniels/.nix-defexpr/channels/home-manager/modules/files.nix:299:30:

          298|         declare -A changedFiles
          299|       '' + concatMapStrings (v:
             |                              ^
          300|         let

       … while evaluating call site

       at /home/daniels/.nix-defexpr/channels/home-manager/modules/files.nix:301:23:

          300|         let
          301|           sourceArg = escapeShellArg (sourceStorePath v);
             |                       ^
          302|           targetArg = escapeShellArg v.target;

       … while calling 'escapeShellArg'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/strings.nix:427:20:

          426|   */
          427|   escapeShellArg = arg: "'${replaceStrings ["'"] ["'\\''"] (toString arg)}'";
             |                    ^
          428|

       … while evaluating call site

       at /home/daniels/.nix-defexpr/channels/home-manager/modules/files.nix:301:39:

          300|         let
          301|           sourceArg = escapeShellArg (sourceStorePath v);
             |                                       ^
          302|           targetArg = escapeShellArg v.target;

       … while calling 'sourceStorePath'

       at /home/daniels/.nix-defexpr/channels/home-manager/modules/files.nix:15:21:

           14|
           15|   sourceStorePath = file:
             |                     ^
           16|     let

       … while evaluating call site

       at «none»:0: (source not available)

       … while calling 'g'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/attrsets.nix:595:19:

          594|           g =
          595|             name: value:
             |                   ^
          596|             if isAttrs value && cond value

       … while evaluating call site

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/attrsets.nix:598:20:

          597|               then recurse (path ++ [name]) value
          598|               else f (path ++ [name]) value;
             |                    ^
          599|         in mapAttrs g;

       … while calling anonymous lambda

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/modules.nix:248:72:

          247|           # For definitions that have an associated option
          248|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          249|

       … while evaluating the attribute 'value'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/modules.nix:759:9:

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

       … while evaluating the option `home.file."/home/daniels/.Xresources".source':

       … while evaluating the attribute 'mergedValue'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/modules.nix:794:5:

          793|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          794|     mergedValue =
             |     ^
          795|       if isDefined then

       … while evaluating call site

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/modules.nix:796:12:

          795|       if isDefined then
          796|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
             |            ^
          797|         else let allInvalid = filter (def: ! type.check def.value) defsFinal;

       … while calling anonymous lambda

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/modules.nix:796:17:

          795|       if isDefined then
          796|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
             |                 ^
          797|         else let allInvalid = filter (def: ! type.check def.value) defsFinal;

       … while evaluating call site

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/modules.nix:796:22:

          795|       if isDefined then
          796|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
             |                      ^
          797|         else let allInvalid = filter (def: ! type.check def.value) defsFinal;

       … while calling 'check'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/types.nix:490:15:

          489|       descriptionClass = "noun";
          490|       check = x: isStringLike x && builtins.substring 0 1 (toString x) == "/";
             |               ^
          491|       merge = mergeEqualOption;

       … while evaluating call site

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:506:14:

          505|   meta = checkMeta.commonMeta { inherit validity attrs pos references; };
          506|   validity = checkMeta.assertValidity { inherit meta attrs; };
             |              ^
          507|

       … while calling 'assertValidity'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/pkgs/stdenv/generic/check-meta.nix:442:20:

          441|
          442|   assertValidity = { meta, attrs }: let
             |                    ^
          443|       validity = checkValidity attrs;

       … while evaluating call site

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/pkgs/stdenv/generic/check-meta.nix:443:18:

          442|   assertValidity = { meta, attrs }: let
          443|       validity = checkValidity attrs;
             |                  ^
          444|     in validity // {

       … while calling 'checkValidity'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/pkgs/stdenv/generic/check-meta.nix:343:19:

          342|   # Along with a boolean flag for each reason
          343|   checkValidity = attrs:
             |                   ^
          344|     # Check meta attribute types first, to make sure it is always called even when there are other issues

       … while evaluating call site

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/pkgs/stdenv/generic/check-meta.nix:362:13:

          361|     # --- Put checks that can be ignored here ---
          362|     else if hasDeniedUnfreeLicense attrs && !(hasAllowlistedLicense attrs) then
             |             ^
          363|       { valid = "no"; reason = "unfree"; errormsg = "has an unfree license (‘${showLicense attrs.meta.license}’)"; }

       … while calling 'hasDeniedUnfreeLicense'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/pkgs/stdenv/generic/check-meta.nix:77:28:

           76|   # `allowUnfreePredicate` function.
           77|   hasDeniedUnfreeLicense = attrs:
             |                            ^
           78|     hasUnfreeLicense attrs &&

       … while evaluating call site

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/pkgs/stdenv/generic/check-meta.nix:78:5:

           77|   hasDeniedUnfreeLicense = attrs:
           78|     hasUnfreeLicense attrs &&
             |     ^
           79|     !allowUnfree &&

       … while calling 'hasUnfreeLicense'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/pkgs/stdenv/generic/check-meta.nix:51:22:

           50|
           51|   hasUnfreeLicense = attrs:
             |                      ^
           52|     hasLicense attrs &&

       … while evaluating call site

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/pkgs/stdenv/generic/check-meta.nix:52:5:

           51|   hasUnfreeLicense = attrs:
           52|     hasLicense attrs &&
             |     ^
           53|     isUnfree (lib.lists.toList attrs.meta.license);

       … while calling 'hasLicense'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/pkgs/stdenv/generic/check-meta.nix:34:16:

           33|
           34|   hasLicense = attrs:
             |                ^
           35|     attrs ? meta.license;

       … while evaluating call site

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/pkgs/build-support/trivial-builders/default.nix:144:16:

          143|         passAsFile = [ "text" ];
          144|         meta = lib.optionalAttrs (executable && matches != null) {
             |                ^
          145|           mainProgram = lib.head matches;

       … while calling 'optionalAttrs'

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/lib/attrsets.nix:675:5:

          674|     # The attribute set to return if `cond` is `true`.
          675|     as:
             |     ^
          676|     if cond then as else {};

       error: value is null while a Boolean was expected

       at /nix/store/62bs9f80ppj67ridljx8pk5m1hhzqzdw-nixpkgs/nixpkgs/pkgs/build-support/trivial-builders/default.nix:144:35:

          143|         passAsFile = [ "text" ];
          144|         meta = lib.optionalAttrs (executable && matches != null) {
             |                                   ^
          145|           mainProgram = lib.head matches;

Also the system issues a warning when enabling enableNixpkgsReleaseCheck. home-manager master seems to be on 23.05 instead of 23.11-pre.

Workaround: I've now switched nixpkgs from unstable to 23.05.

Maintainer CC

No response

System information

this path will be fetched (0.00 MiB download, 0.00 MiB unpacked):
  /nix/store/nn818zlhq4hnx794c57adijwikdw6cqz-nix-info
copying path '/nix/store/nn818zlhq4hnx794c57adijwikdw6cqz-nix-info' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 5.4.0-148-generic, Ubuntu, 20.04.6 LTS (Focal Fossa), nobuild`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - channels(daniels): `"home-manager, nixpkgs, phps"`
 - nixpkgs: `/home/daniels/.nix-defexpr/channels/nixpkgs`


nix-channel --list
home-manager https://github.com/nix-community/home-manager/archive/master.tar.gz
nixpkgs https://nixos.org/channels/nixpkgs-unstable
phps https://github.com/fossar/nix-phps/archive/master.tar.gz
@DanielSiepmann DanielSiepmann added bug triage Issues or feature request that have not been triaged yet labels May 30, 2023
@XaydBayeck
Copy link

XaydBayeck commented May 30, 2023

I'm using NixOS. My configuration is build by flake.

And I meet the same problem.

nixos on  main [⇡] took 4s
❯ nix-info -m
 - system: `"x86_64-linux"`
 - host os: `Linux 6.3.1-zen1, NixOS, 23.05 (Stoat), 23.05.20230522.7084250`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - channels(sid): `"nixos"`
 - channels(root): `"nixos"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

@cherryblossom000
Copy link

cherryblossom000 commented May 30, 2023

I believe the issue is something to do with this:

executable = mkOption {
type = types.nullOr types.bool;
default = null;
description = ''
Set the execute bit. If <literal>null</literal>, defaults to the mode
of the <varname>source</varname> file or to <literal>false</literal>
for files created through the <varname>text</varname> option.
'';
};

I think the issue occurs when executable is null, and for some reason it isn't defaulting to the executable mode of the file.

A workaround that worked for me was to modify ~/.nix-defexpr/channels/home-manager/modules/lib/file-type.nix and change the default for executable to false.


I tried changing my home.file."some-path".executable to false, but that didn't resolve the issue because then home-manager seemed to be using executable = null for my ssh config, which is why I ended up modifying the home-manager code as described above.

@NobbZ
Copy link
Contributor

NobbZ commented May 30, 2023

If you have missed it in the trace:

From what I have seen, this seems to be caused by home.file.*.source, not sure if it also happens for home.file.*.txt.

And I was able to extract a "good" and a "bad" commit of nixpkgs from my flake.lock, leading to the following diff on nixpkgs:

$ git diff -U10 f91ee3065de91a3531329a674a45ddcb3467a650..5e871d8aa6f57cc8e0dc087d1c5013f6e212b4ce pkgs/build-support/trivial-builders/default.nix
diff --git a/pkgs/build-support/trivial-builders/default.nix b/pkgs/build-support/trivial-builders/default.nix
index e90d0a6d202..d3cb22a1f53 100644
--- a/pkgs/build-support/trivial-builders/default.nix
+++ b/pkgs/build-support/trivial-builders/default.nix
@@ -128,23 +128,29 @@ rec {
   writeTextFile =
     { name # the name of the derivation
     , text
     , executable ? false # run chmod +x ?
     , destination ? ""   # relative path appended to $out eg "/bin/foo"
     , checkPhase ? ""    # syntax checks, e.g. for scripts
     , meta ? { }
     , allowSubstitutes ? false
     , preferLocalBuild ? true
     }:
+    let
+      matches = builtins.match "/bin/([^/]+)" destination;
+    in
     runCommand name
-      { inherit text executable checkPhase meta allowSubstitutes preferLocalBuild;
+      { inherit text executable checkPhase allowSubstitutes preferLocalBuild;
         passAsFile = [ "text" ];
+        meta = lib.optionalAttrs (executable && matches != null) {
+          mainProgram = lib.head matches;
+        } // meta;
       }
       ''
         target=$out${lib.escapeShellArg destination}
         mkdir -p "$(dirname "$target")"
 
         if [ -e "$textPath" ]; then
           mv "$textPath" "$target"
         else
           echo -n "$text" > "$target"
         fi
@@ -343,22 +349,20 @@ rec {
       checkPhase =
         if checkPhase == null then ''
           runHook preCheck
           ${stdenv.shellDryRun} "$target"
           # use shellcheck which does not include docs
           # pandoc takes long to build and documentation isn't needed for in nixpkgs usage
           ${lib.getExe (haskell.lib.compose.justStaticExecutables shellcheck.unwrapped)} "$target"
           runHook postCheck
         ''
         else checkPhase;
-
-      meta.mainProgram = name;
     };
 
   # Create a C binary
   writeCBin = name: code:
     runCommandCC name
     {
       inherit name code;
       executable = true;
       passAsFile = ["code"];
       # Pointless to do this on a remote machine.

So from my point of view, this seems to be an issue with nixpkgs.

This change breaks for anything that uses writeTextFile with a non-/bin destination and executable = true as far as I can see.

@NobbZ
Copy link
Contributor

NobbZ commented May 30, 2023

The underlying issue seems to be fixed via NixOS/nixpkgs@4431bab (NixOS/nixpkgs#234862) which is not in the channels yet.

I can successfully evaluate my configuration when using nixpkgs-master as follows, as well as passing pkgs = inputs.nixpkgs-master.legacyPackages.${system} in my flake.

I will probably just wait for the fix to propagate into the channels before updating again.

@ncfavier
Copy link
Member

It doesn't make sense to pass null to writeTextFile. This should be fixed in HM, not in nixpkgs. #4036

@NobbZ
Copy link
Contributor

NobbZ commented May 30, 2023

I think it is totally fine to have a fix in both…

Making HM semantically correct, while at the same time keeping nixpkgs backward compatible.

Though I wouldn't mind the latter if the error was less confusing and more obvious.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/error-value-is-null-while-a-boolean-was-expected-where-to-start/29649/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Issues or feature request that have not been triaged yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants