flake-compat is not compatible with Nix Flakes #64

Open
opened 2024-03-09 00:30:18 +00:00 by 9999years · 0 comments
9999years commented 2024-03-09 00:30:18 +00:00 (Migrated from github.com)

Since 0f9255e01c, default.nix has used builtins.storePath, which is not available in pure evaluation mode (e.g. when used in a Flake).

This makes it challenging to use flake-compat to incrementally migrate to Nix flakes.

Stack trace
       … while evaluating the file '/nix/store/g10gzvphg32jxpga3rkqymyzhj1fvx33-source/default.nix':

       … while evaluating the attribute 'defaultNix'
         at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:229:5:
          228|   rec {
          229|     defaultNix =
             |     ^
          230|       (builtins.removeAttrs result ["__functor"])

       … in the left operand of the update (//) operator
         at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:231:7:
          230|       (builtins.removeAttrs result ["__functor"])
          231|       // (if result ? defaultPackage.${system} then { default = result.defaultPackage.${system}; } else {})
             |       ^
          232|       // (if result ? packages.${system}.default then { default = result.packages.${system}.default; } else {});

       … while calling the 'removeAttrs' builtin
         at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:230:8:
          229|     defaultNix =
          230|       (builtins.removeAttrs result ["__functor"])
             |        ^
          231|       // (if result ? defaultPackage.${system} then { default = result.defaultPackage.${system}; } else {})

       … from call site
         at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:224:10:
          223|     else if lockFile.version >= 5 && lockFile.version <= 7
          224|     then allNodes.${lockFile.root}
             |          ^
          225|     else throw "lock file '${lockFilePath}' has unsupported version ${toString lockFile.version}";

       … while calling anonymous lambda
         at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:156:13:
          155|     builtins.mapAttrs
          156|       (key: node:
             |             ^
          157|         let

       … in the condition of the assert statement
         at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:211:13:
          210|           if node.flake or true then
          211|             assert builtins.isFunction flake.outputs;
             |             ^
          212|             result

       … while calling the 'isFunction' builtin
         at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:211:20:
          210|           if node.flake or true then
          211|             assert builtins.isFunction flake.outputs;
             |                    ^
          212|             result

       … while calling the 'import' builtin
         at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:167:19:
          166|
          167|           flake = import (outPath + "/flake.nix");
             |                   ^
          168|

       … while realising the context of a path

       … while calling the 'storePath' builtin
         at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:115:15:
          114|               # If it's already a store path, don't copy it again.
          115|               builtins.storePath src
             |               ^
          116|             else

       error: 'builtins.storePath' is not allowed in pure evaluation mode
Since https://github.com/edolstra/flake-compat/commit/0f9255e01c2351cc7d116c072cb317785dd33b33, `default.nix` has used `builtins.storePath`, which is not available in pure evaluation mode (e.g. when used in a Flake). This makes it challenging to use `flake-compat` to incrementally migrate to Nix flakes. <details> <summary>Stack trace</summary> ``` … while evaluating the file '/nix/store/g10gzvphg32jxpga3rkqymyzhj1fvx33-source/default.nix': … while evaluating the attribute 'defaultNix' at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:229:5: 228| rec { 229| defaultNix = | ^ 230| (builtins.removeAttrs result ["__functor"]) … in the left operand of the update (//) operator at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:231:7: 230| (builtins.removeAttrs result ["__functor"]) 231| // (if result ? defaultPackage.${system} then { default = result.defaultPackage.${system}; } else {}) | ^ 232| // (if result ? packages.${system}.default then { default = result.packages.${system}.default; } else {}); … while calling the 'removeAttrs' builtin at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:230:8: 229| defaultNix = 230| (builtins.removeAttrs result ["__functor"]) | ^ 231| // (if result ? defaultPackage.${system} then { default = result.defaultPackage.${system}; } else {}) … from call site at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:224:10: 223| else if lockFile.version >= 5 && lockFile.version <= 7 224| then allNodes.${lockFile.root} | ^ 225| else throw "lock file '${lockFilePath}' has unsupported version ${toString lockFile.version}"; … while calling anonymous lambda at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:156:13: 155| builtins.mapAttrs 156| (key: node: | ^ 157| let … in the condition of the assert statement at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:211:13: 210| if node.flake or true then 211| assert builtins.isFunction flake.outputs; | ^ 212| result … while calling the 'isFunction' builtin at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:211:20: 210| if node.flake or true then 211| assert builtins.isFunction flake.outputs; | ^ 212| result … while calling the 'import' builtin at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:167:19: 166| 167| flake = import (outPath + "/flake.nix"); | ^ 168| … while realising the context of a path … while calling the 'storePath' builtin at /nix/store/8kpx53qi52yhjai1vdw8zpa95iqa61bv-source/default.nix:115:15: 114| # If it's already a store path, don't copy it again. 115| builtins.storePath src | ^ 116| else error: 'builtins.storePath' is not allowed in pure evaluation mode ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/flake-compat#64
No description provided.