NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.11k stars 14.15k forks source link

error message: ... while calling the 'head' builtin #274798

Open davidak opened 11 months ago

davidak commented 11 months ago

Describe the bug

This error message does not tell me where the error has to be fixed. It looks like the issue is in nixos code.

[root@gaming:~]# nixos-rebuild switch
building Nix...
building the system configuration...
error:
       … while calling the 'head' builtin

         at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/attrsets.nix:922:11:

          921|         || pred here (elemAt values 1) (head values) then
          922|           head values
             |           ^
          923|         else

       … while evaluating the attribute 'value'

         at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/modules.nix:807:9:

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

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

       error: 'pkgconfig' has been renamed to/replaced by 'pkg-config'

With --show-trace:

show ``` [root@gaming:~]# time nixos-rebuild switch --show-trace building Nix... building the system configuration... error: … while calling anonymous lambda at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/attrsets.nix:918:24: 917| let f = attrPath: 918| zipAttrsWith (n: values: | ^ 919| let here = attrPath ++ [n]; in … while calling 'g' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/attrsets.nix:701:19: 700| g = 701| name: value: | ^ 702| if isAttrs value && cond value … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/attrsets.nix:704:20: 703| then recurse (path ++ [name]) value 704| else f (path ++ [name]) value; | ^ 705| in mapAttrs g; … while calling anonymous lambda at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/modules.nix:242:72: 241| # For definitions that have an associated option 242| declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options; | ^ 243| … while evaluating the option `system.build.toplevel': … while calling anonymous lambda at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/modules.nix:822:28: 821| # Process mkMerge and mkIf properties. 822| defs' = concatMap (m: | ^ 823| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value)) … while evaluating definitions from `/nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/nixos/modules/system/activation/top-level.nix': … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/modules.nix:823:137: 822| defs' = concatMap (m: 823| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value)) | ^ 824| ) defs; … while calling 'dischargeProperties' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/modules.nix:894:25: 893| */ 894| dischargeProperties = def: | ^ 895| if def._type or "" == "merge" then … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/nixos/modules/system/activation/top-level.nix:71:12: 70| # Replace runtime dependencies 71| system = foldr ({ oldDependency, newDependency }: drv: | ^ 72| pkgs.replaceDependency { inherit oldDependency newDependency drv; } … while calling 'foldr' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/lists.nix:53:20: 52| */ 53| foldr = op: nul: list: | ^ 54| let … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/lists.nix:60:8: 59| else op (elemAt list n) (fold' (n + 1)); 60| in fold' 0; | ^ 61| … while calling 'fold'' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/lists.nix:56:15: 55| len = length list; 56| fold' = n: | ^ 57| if n == len … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/nixos/modules/system/activation/top-level.nix:68:10: 67| then throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}" 68| else showWarnings config.warnings baseSystem; | ^ 69| … while calling 'showWarnings' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/trivial.nix:414:28: 413| 414| showWarnings = warnings: res: lib.foldr (w: x: warn w x) res warnings; | ^ 415| … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/trivial.nix:414:33: 413| 414| showWarnings = warnings: res: lib.foldr (w: x: warn w x) res warnings; | ^ 415| … while calling 'foldr' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/lists.nix:53:20: 52| */ 53| foldr = op: nul: list: | ^ 54| let … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/lists.nix:60:8: 59| else op (elemAt list n) (fold' (n + 1)); 60| in fold' 0; | ^ 61| … while calling 'fold'' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/lists.nix:56:15: 55| len = length list; 56| fold' = n: | ^ 57| if n == len … while calling 'g' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/attrsets.nix:701:19: 700| g = 701| name: value: | ^ 702| if isAttrs value && cond value … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/attrsets.nix:704:20: 703| then recurse (path ++ [name]) value 704| else f (path ++ [name]) value; | ^ 705| in mapAttrs g; … while calling anonymous lambda at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/modules.nix:242:72: 241| # For definitions that have an associated option 242| declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options; | ^ 243| … while evaluating the option `warnings': … while calling anonymous lambda at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/modules.nix:822:28: 821| # Process mkMerge and mkIf properties. 822| defs' = concatMap (m: | ^ 823| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value)) … while evaluating definitions from `/nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/nixos/modules/system/boot/systemd.nix': … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/modules.nix:823:137: 822| defs' = concatMap (m: 823| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value)) | ^ 824| ) defs; … while calling 'dischargeProperties' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/modules.nix:894:25: 893| */ 894| dischargeProperties = def: | ^ 895| if def._type or "" == "merge" then … while calling anonymous lambda at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/attrsets.nix:615:10: 614| attrs: 615| map (name: f name attrs.${name}) (attrNames attrs); | ^ 616| … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/attrsets.nix:615:16: 614| attrs: 615| map (name: f name attrs.${name}) (attrNames attrs); | ^ 616| … while calling anonymous lambda at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/nixos/modules/system/boot/systemd.nix:425:16: 424| mapAttrsToList 425| (name: service: | ^ 426| let … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/nixos/modules/system/boot/systemd.nix:432:16: 431| concatLists [ 432| (optional (type == "oneshot" && (restart == "always" || restart == "on-success")) | ^ 433| "Service '${name}.service' with 'Type=oneshot' cannot have 'Restart=always' or 'Restart=on-success'" … while calling 'optional' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/lists.nix:359:20: 358| */ 359| optional = cond: elem: if cond then [elem] else []; | ^ 360| … while calling 'g' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/attrsets.nix:701:19: 700| g = 701| name: value: | ^ 702| if isAttrs value && cond value … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/attrsets.nix:704:20: 703| then recurse (path ++ [name]) value 704| else f (path ++ [name]) value; | ^ 705| in mapAttrs g; … while calling anonymous lambda at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/modules.nix:242:72: 241| # For definitions that have an associated option 242| declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options; | ^ 243| … while evaluating the option `systemd.services.trustix.serviceConfig': … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/modules.nix:844:59: 843| if isDefined then 844| if all (def: type.check def.value) defsFinal then type.merge loc defsFinal | ^ 845| else let allInvalid = filter (def: ! type.check def.value) defsFinal; … while calling 'merge' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/types.nix:556:20: 555| check = isAttrs; 556| merge = loc: defs: | ^ 557| mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs: … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/types.nix:557:35: 556| merge = loc: defs: 557| mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs: | ^ 558| (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue … while calling 'filterAttrs' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/attrsets.nix:381:5: 380| # The attribute set to filter 381| set: | ^ 382| listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set)); … while calling anonymous lambda at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/attrsets.nix:382:29: 381| set: 382| listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set)); | ^ 383| … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/attrsets.nix:382:62: 381| set: 382| listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set)); | ^ 383| … while calling anonymous lambda at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/types.nix:557:51: 556| merge = loc: defs: 557| mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs: | ^ 558| (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue … while calling anonymous lambda at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/types.nix:557:86: 556| merge = loc: defs: 557| mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs: | ^ 558| (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue … while calling anonymous lambda at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/modules.nix:822:28: 821| # Process mkMerge and mkIf properties. 822| defs' = concatMap (m: | ^ 823| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value)) … while evaluating definitions from `/home/davidak/code/trustix/packages/trustix/nixos': … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/modules.nix:823:137: 822| defs' = concatMap (m: 823| map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value)) | ^ 824| ) defs; … while calling 'dischargeProperties' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/modules.nix:894:25: 893| */ 894| dischargeProperties = def: | ^ 895| if def._type or "" == "merge" then … while evaluating derivation 'trustix-dev' whose name attribute is located at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/pkgs/stdenv/generic/make-derivation.nix:348:7 … while evaluating attribute 'nativeBuildInputs' of derivation 'trustix-dev' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/pkgs/stdenv/generic/make-derivation.nix:392:7: 391| depsBuildBuild = elemAt (elemAt dependencies 0) 0; 392| nativeBuildInputs = elemAt (elemAt dependencies 0) 1; | ^ 393| depsBuildTarget = elemAt (elemAt dependencies 0) 2; … while calling 'getOutput' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/attrsets.nix:1045:23: 1044| */ 1045| getOutput = output: pkg: | ^ 1046| if ! pkg ? outputSpecified || ! pkg.outputSpecified … while calling anonymous lambda at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/pkgs/stdenv/generic/make-derivation.nix:289:13: 288| (map (drv: drv.__spliced.buildBuild or drv) (checkDependencyList "depsBuildBuild" depsBuildBuild)) 289| (map (drv: drv.__spliced.buildHost or drv) (checkDependencyList "nativeBuildInputs" nativeBuildInputs')) | ^ 290| (map (drv: drv.__spliced.buildTarget or drv) (checkDependencyList "depsBuildTarget" depsBuildTarget)) … while calling anonymous lambda at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/lists.nix:165:29: 164| */ 165| imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list); | ^ 166| … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/lists.nix:165:32: 164| */ 165| imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list); | ^ 166| … while calling anonymous lambda at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/pkgs/stdenv/generic/make-derivation.nix:261:73: 260| checkDependencyList = checkDependencyList' []; 261| checkDependencyList' = positions: name: deps: flip imap1 deps (index: dep: | ^ 262| if isDerivation dep || dep == null || builtins.isString dep || builtins.isPath dep then dep … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/pkgs/stdenv/generic/make-derivation.nix:262:8: 261| checkDependencyList' = positions: name: deps: flip imap1 deps (index: dep: 262| if isDerivation dep || dep == null || builtins.isString dep || builtins.isPath dep then dep | ^ 263| else if isList dep then checkDependencyList' ([index] ++ positions) name dep … while calling 'isDerivation' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/attrsets.nix:742:5: 741| # Value to check. 742| value: value.type or null == "derivation"; | ^ 743| … while calling anonymous lambda at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/pkgs/top-level/aliases.nix:44:22: 43| mapAliases = aliases: 44| lib.mapAttrs (n: alias: | ^ 45| removeDistribute … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/pkgs/top-level/aliases.nix:45:7: 44| lib.mapAttrs (n: alias: 45| removeDistribute | ^ 46| (removeRecurseForDerivations … while calling 'removeDistribute' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/pkgs/top-level/aliases.nix:32:22: 31| # sets from building on Hydra. 32| removeDistribute = alias: with lib; | ^ 33| if isDerivation alias then … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/pkgs/top-level/aliases.nix:33:8: 32| removeDistribute = alias: with lib; 33| if isDerivation alias then | ^ 34| dontDistribute alias … while calling 'isDerivation' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/attrsets.nix:742:5: 741| # Value to check. 742| value: value.type or null == "derivation"; | ^ 743| … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/pkgs/top-level/aliases.nix:46:10: 45| removeDistribute 46| (removeRecurseForDerivations | ^ 47| (checkInPkgs n alias))) … while calling 'removeRecurseForDerivations' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/pkgs/top-level/aliases.nix:25:33: 24| # to appear while listing all the packages available. 25| removeRecurseForDerivations = alias: with lib; | ^ 26| if alias.recurseForDerivations or false … from call site at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/pkgs/top-level/aliases.nix:47:12: 46| (removeRecurseForDerivations 47| (checkInPkgs n alias))) | ^ 48| aliases; … while calling 'checkInPkgs' at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/pkgs/top-level/aliases.nix:38:20: 37| # Make sure that we are not shadowing something from all-packages.nix. 38| checkInPkgs = n: alias: | ^ 39| if builtins.hasAttr n super error: 'pkgconfig' has been renamed to/replaced by 'pkg-config' ```

The relevant information hidden in all the noise is:

error: 'pkgconfig' has been renamed to/replaced by 'pkg-config' while evaluating definitions from `/home/davidak/code/trustix/packages/trustix/nixos'

Steps To Reproduce

Steps to reproduce the behavior:

  1. nixos-rebuild switch

Expected behavior

Clear and short error messages.

Additional context

Add any other context about the problem here.

Notify maintainers

Metadata


Add a :+1: reaction to issues you find important.

pennae commented 11 months ago

This error message does not tell me where the error has to be fixed.

because that's impossible. in theory the evaluator could be extended to track value provenance and provide all locations where a value that ends up resolving to an error was referenced, but if that were to happen nix would be entirely unusable--not only because it'd be a lot slower and use a lot more memory, but the location trace would be so full of uninteresting locations you'd still have no chance of finding anything.

ghpzin commented 10 months ago

So which channel was it on (better with exact commit) ? From your description:

host os: Linux 6.6.6, NixOS, 23.05 (Stoat), 23.05.5184.946310306972
version: nix-env (Nix) 2.13.6
channels(root): "home-manager-23.11.tar.gz, nixos-23.11, nixos-hardware, nixos-unstable"

2 top lines point to it being 23.05, other one to 23.11 or unstable, logs point to 23.11:

/nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/lib/modules.nix:823:137:

Also you mentioned It looks like the issue is in nixos code., but also from your logs:

       … while evaluating the option `systemd.services.trustix.serviceConfig':
...
       … while evaluating definitions from `/home/davidak/code/trustix/packages/trustix/nixos':
...

       … while evaluating derivation 'trustix-dev'
         whose name attribute is located at /nix/store/skzb00cq9vb43ryyr8dyzxlqmqmfy0ss-nixos-23.11/nixos/pkgs/stdenv/generic/make-derivation.nix:348:7

       … while evaluating attribute 'nativeBuildInputs' of derivation 'trustix-dev'

From the name I assume it is: https://github.com/nix-community/trustix So maybe try to disable everything related to trustix in your configuration. And if error on rebuild disappears and you did not do something on top of it (like running old version) - it's better to look for the issue on trustix side. As far as I can see they have replaced pkgconfig with pkg-config in: https://github.com/nix-community/trustix/pull/60