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

"stack overflow; max-call-depth exceeded" when building generateKeysScript #224

Open
CyberShadow opened this issue Mar 9, 2024 · 4 comments

Comments

@CyberShadow
Copy link
Contributor

$ cat ../in2023.nix      
{
  device = "instantnoodlep";
  flavor = "lineageos";
}

$ nix-build --arg configuration ../in2023.nix -A generateKeysScript -o generate-keys --show-trace
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:9:12:
            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'generate_keys.sh'
         whose name attribute is located at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/pkgs/stdenv/generic/make-derivation.nix:205:7

       … while evaluating attribute 'text' of derivation 'generate_keys.sh'
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/pkgs/build-support/trivial-builders.nix:117:16:
          116|     runCommand name
          117|       { inherit text executable checkPhase meta;
             |                ^
          118|         passAsFile = [ "text" ];

       … while evaluating derivation 'android-key-tools'
         whose name attribute is located at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/pkgs/stdenv/generic/make-derivation.nix:205:7

       … while evaluating attribute 'buildCommand' of derivation 'android-key-tools'
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/pkgs/build-support/trivial-builders.nix:74:14:
           73|       name = lib.strings.sanitizeDerivationName name;
           74|       inherit buildCommand;
             |              ^
           75|       passAsFile = [ "buildCommand" ]

       … from call site
         at /home/vladimir/work/android-build/robotnix/modules/signing.nix:205:14:
          204|
          205|         cp ${config.source.dirs."development".src}/tools/make_key $out/bin/make_key
             |              ^
          206|         substituteInPlace $out/bin/make_key --replace openssl ${lib.getBin pkgs.openssl}/bin/openssl

       … while calling 'g'
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/attrsets.nix:301:19:
          300|           g =
          301|             name: value:
             |                   ^
          302|             if isAttrs value && cond value

       … from call site
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/attrsets.nix:304:20:
          303|               then recurse (path ++ [name]) value
          304|               else f (path ++ [name]) value;
             |                    ^
          305|         in mapAttrs g set;

       … while calling anonymous lambda
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/modules.nix:171:72:
          170|           # For definitions that have an associated option
          171|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          172|

       … while evaluating the option `source.dirs.development.src':

       … from call site
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/modules.nix:578:35:
          577|       # yield a value computed from the definitions
          578|       value = if opt ? apply then opt.apply res.mergedValue else res.mergedValue;
             |                                   ^
          579|

       … while calling 'apply'
         at /home/vladimir/work/android-build/robotnix/modules/source.nix:83:17:
           82|         default = pkgs.runCommand "empty" {} "mkdir -p $out";
           83|         apply = src: # Maybe replace with with pkgs.applyPatches? Need patchFlags though...
             |                 ^
           84|           if (config.patches != [] || config.postPatch != "")

       … from call site
         at /home/vladimir/work/android-build/robotnix/modules/source.nix:84:39:
           83|         apply = src: # Maybe replace with with pkgs.applyPatches? Need patchFlags though...
           84|           if (config.patches != [] || config.postPatch != "")
             |                                       ^
           85|           then (pkgs.runCommand "${builtins.replaceStrings ["/"] ["="] config.relpath}-patched" {} ''

       … while calling 'g'
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/attrsets.nix:301:19:
          300|           g =
          301|             name: value:
             |                   ^
          302|             if isAttrs value && cond value

       … from call site
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/attrsets.nix:304:20:
          303|               then recurse (path ++ [name]) value
          304|               else f (path ++ [name]) value;
             |                    ^
          305|         in mapAttrs g set;

       … while calling anonymous lambda
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/modules.nix:171:72:
          170|           # For definitions that have an associated option
          171|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          172|

       … while evaluating the option `source.dirs.development.postPatch':

       … while calling anonymous lambda
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/modules.nix:597:28:
          596|         # Process mkMerge and mkIf properties.
          597|         defs' = concatMap (m:
             |                            ^
          598|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating definitions from `/home/vladimir/work/android-build/robotnix/modules/source.nix':

       … from call site
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/modules.nix:598:137:
          597|         defs' = concatMap (m:
          598|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          599|         ) defs;

       … while calling 'dischargeProperties'
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/modules.nix:669:25:
          668|   */
          669|   dischargeProperties = def:
             |                         ^
          670|     if def._type or "" == "merge" then

       … from call site
         at /home/vladimir/work/android-build/robotnix/modules/source.nix:197:38:
          196|         relpathSplit = lib.splitString "/" config.relpath;
          197|         mountPoints = lib.attrNames (lib.attrByPath relpathSplit {} dirsTree);
             |                                      ^
          198|       in mkIf (mountPoints != [])

       … while calling 'attrByPath'
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/attrsets.nix:24:35:
           23|   */
           24|   attrByPath = attrPath: default: e:
             |                                   ^
           25|     let attr = head attrPath;

       … from call site
         at /home/vladimir/work/android-build/robotnix/modules/source.nix:47:5:
           46|   in
           47|     combineTreeBranches (lib.mapAttrsToList (name: dir: listToTreeBranch (lib.splitString "/" dir.relpath)) enabledDirs);
             |     ^
           48|

       … while calling 'combineTreeBranches'
         at /home/vladimir/work/android-build/robotnix/modules/source.nix:43:27:
           42|       else { "${builtins.head xs}" = listToTreeBranch (builtins.tail xs); };
           43|     combineTreeBranches = branches:
             |                           ^
           44|       lib.foldr lib.recursiveUpdate {} branches;

       … from call site
         at /home/vladimir/work/android-build/robotnix/modules/source.nix:44:7:
           43|     combineTreeBranches = branches:
           44|       lib.foldr lib.recursiveUpdate {} branches;
             |       ^
           45|     enabledDirs = lib.filterAttrs (name: dir: dir.enable) config.source.dirs;

       … while calling 'foldr'
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/lists.nix:52:20:
           51|   */
           52|   foldr = op: nul: list:
             |                    ^
           53|     let

       … from call site
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/lists.nix:59:8:
           58|         else op (elemAt list n) (fold' (n + 1));
           59|     in fold' 0;
             |        ^
           60|

       … while calling 'fold''
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/lists.nix:55:15:
           54|       len = length list;
           55|       fold' = n:
             |               ^
           56|         if n == len

       … from call site
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/lists.nix:58:14:
           57|         then nul
           58|         else op (elemAt list n) (fold' (n + 1));
             |              ^
           59|     in fold' 0;

       … while calling 'recursiveUpdate'
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/attrsets.nix:449:26:
          448|      */
          449|   recursiveUpdate = lhs: rhs:
             |                          ^
          450|     recursiveUpdateUntil (path: lhs: rhs:

       … from call site
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/attrsets.nix:450:5:
          449|   recursiveUpdate = lhs: rhs:
          450|     recursiveUpdateUntil (path: lhs: rhs:
             |     ^
          451|       !(isAttrs lhs && isAttrs rhs)

       … while calling 'recursiveUpdateUntil'
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/attrsets.nix:418:37:
          417|      */
          418|   recursiveUpdateUntil = pred: lhs: rhs:
             |                                     ^
          419|     let f = attrPath:

       … from call site
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/attrsets.nix:428:8:
          427|       );
          428|     in f [] [rhs lhs];
             |        ^
          429|

       … while calling 'zipAttrsWith'
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/attrsets.nix:381:21:
          380|   */
          381|   zipAttrsWith = f: sets: zipAttrsWithNames (concatMap attrNames sets) f sets;
             |                     ^
          382|   /* Like `zipAttrsWith' with `(name: values: values)' as the function.

       … from call site
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/attrsets.nix:381:27:
          380|   */
          381|   zipAttrsWith = f: sets: zipAttrsWithNames (concatMap attrNames sets) f sets;
             |                           ^
          382|   /* Like `zipAttrsWith' with `(name: values: values)' as the function.

       … while calling 'zipAttrsWithNames'
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/attrsets.nix:366:33:
          365|   */
          366|   zipAttrsWithNames = names: f: sets:
             |                                 ^
          367|     listToAttrs (map (name: {

       … from call site
         at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/lists.nix:58:34:
           57|         then nul
           58|         else op (elemAt list n) (fold' (n + 1));
             |                                  ^
           59|     in fold' 0;

       (11079 duplicate frames omitted)

       error: stack overflow; max-call-depth exceeded
       at /nix/store/d0dl9ch4hhxkqikc1dw3868j95gsbb0h-source/lib/attrsets.nix:381:46:
          380|   */
          381|   zipAttrsWith = f: sets: zipAttrsWithNames (concatMap attrNames sets) f sets;
             |                                              ^
          382|   /* Like `zipAttrsWith' with `(name: values: values)' as the function.
@CyberShadow
Copy link
Contributor Author

It seems to be due to a bug in nixpkgs.

The bug manifests with the nixpkgs version in flake.lock, but not a more recent version.

@CyberShadow
Copy link
Contributor Author

2dcae7d82f5ef0b373413d2fbfc1001141561c74 is the first good commit
commit 2dcae7d82f5ef0b373413d2fbfc1001141561c74
Author: pennae <[email protected]>
Date:   Sat Dec 25 15:20:26 2021 +0100

    lib/attrsets: use builtins.zipAttrsWith if available

 lib/attrsets.nix | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
bisect found first good commit

NixOS/nixpkgs@2dcae7d
NixOS/nixpkgs#152046

Looks like it wasn't even intended as a bugfix.

@Atemu
Copy link
Contributor

Atemu commented Mar 9, 2024

If we can get that exact version to build, feel free to update the lock.

See #218

@c2vi
Copy link

c2vi commented Apr 23, 2024

just increasing the max-call-depth by adding --option max-call-depth 1000000 to the nix build command solved it for me as a workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants