flake-compat icon indicating copy to clipboard operation
flake-compat copied to clipboard

`flake-compat` is not compatible with Nix Flakes

Open 9999years opened this issue 1 year ago • 0 comments

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.

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

9999years avatar Mar 09 '24 00:03 9999years