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

"'allow-import-from-derivation' is disabled" error #34

Closed
kamoii opened this issue Nov 28, 2021 · 2 comments
Closed

"'allow-import-from-derivation' is disabled" error #34

kamoii opened this issue Nov 28, 2021 · 2 comments

Comments

@kamoii
Copy link

kamoii commented Nov 28, 2021

I'm new to nix, so I don't know if this is an error or intended, but when I try to run nix flake show,
I get the error 'allow-import-from-derivation' is disabled.

$ nix flake show --version
nix (Nix) 2.4
$ nix flake show --show-trace
git+file:///.../github/purenix?ref=main&rev=4dd6ec3913825a66cc2c8a82219428d812c0a203
├───defaultPackage
error: cannot build '/nix/store/vnvd0kq9vphs2b191yh0wk1z7ffffjlq-cabal2nix-purenix.drv' during evaluation because the option 'allow-import-from-derivation' is disabled

       … while importing '/nix/store/ybyh4wwhkwg6fpp2acqd87rkrhj4499r-cabal2nix-purenix'

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/pkgs/development/haskell-modules/make-package-set.nix:87:47:

           86|       # info that callPackage uses to determine the arguments).
           87|       drv = if lib.isFunction fn then fn else import fn;
             |                                               ^
           88|       auto = builtins.intersectAttrs (lib.functionArgs drv) scope;

       … while evaluating 'drvScope'

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/pkgs/development/haskell-modules/make-package-set.nix:91:18:

           90|       # this wraps the `drv` function to add a `overrideScope` function to the result.
           91|       drvScope = allArgs: drv allArgs // {
             |                  ^
           92|         overrideScope = f:

       … from call site

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/lib/customisation.nix:69:16:

           68|     let
           69|       result = f origArgs;
             |                ^
           70|

       … while evaluating 'makeOverridable'

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/lib/customisation.nix:67:24:

           66|   */
           67|   makeOverridable = f: origArgs:
             |                        ^
           68|     let

       … from call site

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/pkgs/development/haskell-modules/make-package-set.nix:101:8:

          100|       };
          101|     in lib.makeOverridable drvScope (auto // manualArgs);
             |        ^
          102|

       … while evaluating 'callPackageWithScope'

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/pkgs/development/haskell-modules/make-package-set.nix:78:37:

           77|   # here `bar` is a manual argument.
           78|   callPackageWithScope = scope: fn: manualArgs:
             |                                     ^
           79|     let

       … from call site

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/pkgs/development/haskell-modules/make-package-set.nix:118:28:

          117|   defaultScope = mkScope self;
          118|   callPackage = drv: args: callPackageWithScope defaultScope drv args;
             |                            ^
          119|

       … while evaluating 'callPackage'

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/pkgs/development/haskell-modules/make-package-set.nix:118:22:

          117|   defaultScope = mkScope self;
          118|   callPackage = drv: args: callPackageWithScope defaultScope drv args;
             |                      ^
          119|

       … from call site

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/pkgs/development/haskell-modules/make-package-set.nix:174:9:

          173|       };
          174|     }) (self.callPackage src args);
             |         ^
          175|

       … while evaluating 'overrideCabal'

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/pkgs/development/haskell-modules/lib/compose.nix:38:22:

           37|    */
           38|   overrideCabal = f: drv: (drv.override (args: args // {
             |                      ^
           39|     mkDerivation = drv: (args.mkDerivation drv).override f;

       … from call site

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/pkgs/development/haskell-modules/make-package-set.nix:162:5:

          161|   callPackageKeepDeriver = src: args:
          162|     overrideCabal (orig: {
             |     ^
          163|       preConfigure = ''

       … while evaluating 'callPackageKeepDeriver'

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/pkgs/development/haskell-modules/make-package-set.nix:161:33:

          160|   # annoyance.
          161|   callPackageKeepDeriver = src: args:
             |                                 ^
          162|     overrideCabal (orig: {

       … from call site

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/pkgs/development/haskell-modules/make-package-set.nix:218:14:

          217|            inherit src;
          218|          }) (callPackageKeepDeriver expr args);
             |              ^
          219|

       … while evaluating 'overrideCabal'

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/pkgs/development/haskell-modules/lib/compose.nix:38:22:

           37|    */
           38|   overrideCabal = f: drv: (drv.override (args: args // {
             |                      ^
           39|     mkDerivation = drv: (args.mkDerivation drv).override f;

       … from call site

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/pkgs/development/haskell-modules/make-package-set.nix:216:10:

          215|         };
          216|       in overrideCabal (orig: {
             |          ^
          217|            inherit src;

       … while evaluating 'callCabal2nixWithOptions'

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/pkgs/development/haskell-modules/make-package-set.nix:205:66:

          204|     # Creates a Haskell package from a source package by calling cabal2nix on the source.
          205|     callCabal2nixWithOptions = name: src: extraCabal2nixOptions: args:
             |                                                                  ^
          206|       let

       … from call site

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/pkgs/development/haskell-modules/make-package-set.nix:220:38:

          219|
          220|     callCabal2nix = name: src: args: self.callCabal2nixWithOptions name src "" args;
             |                                      ^
          221|

       … while evaluating 'callCabal2nix'

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/pkgs/development/haskell-modules/make-package-set.nix:220:32:

          219|
          220|     callCabal2nix = name: src: args: self.callCabal2nixWithOptions name src "" args;
             |                                ^
          221|

       … from call site

       at /nix/store/lgkd30fbvyz9ndyqai6c2cckbfp12bfc-source/nix/overlay.nix:33:11:

           32|           in
           33|           hfinal.callCabal2nix "purenix" src { };
             |           ^
           34|       };

       … while evaluating the attribute 'haskellPackages.purenix'

       at /nix/store/lgkd30fbvyz9ndyqai6c2cckbfp12bfc-source/nix/overlay.nix:5:9:

            4|       prev.haskell.packageOverrides hfinal hprev // {
            5|         purenix =
             |         ^
            6|           let

       … while evaluating 'overrideCabal'

       at /nix/store/r85b90gdvvpfl04rnn2aisr6jggi2pp0-source/pkgs/development/haskell-modules/lib/compose.nix:38:22:

           37|    */
           38|   overrideCabal = f: drv: (drv.override (args: args // {
             |                      ^
           39|     mkDerivation = drv: (args.mkDerivation drv).override f;

       … from call site

       at /nix/store/lgkd30fbvyz9ndyqai6c2cckbfp12bfc-source/nix/overlay.nix:38:5:

           37|   purenix =
           38|     final.haskell.lib.compose.justStaticExecutables final.haskellPackages.purenix;
             |     ^
           39|

       … while evaluating the attribute 'purenix'

       at /nix/store/lgkd30fbvyz9ndyqai6c2cckbfp12bfc-source/nix/overlay.nix:37:3:

           36|
           37|   purenix =
             |   ^
           38|     final.haskell.lib.compose.justStaticExecutables final.haskellPackages.purenix;

       … while evaluating the attribute 'defaultPackage'

       at /nix/store/lgkd30fbvyz9ndyqai6c2cckbfp12bfc-source/flake.nix:15:11:

           14|         {
           15|           defaultPackage = pkgs.purenix;
             |           ^
           16|           packages.purenix = pkgs.purenix;
@cdepillabout
Copy link
Member

cdepillabout commented Nov 29, 2021

Unfortunately this is a problem with IFD in flakes.

There are a couple things on the Nix issue tracker that talk about this, as well as a few posts on Discourse:

If you'd like nix flake show working locally, you'll have to make sure to only build for your local system/architecture:

diff --git a/flake.nix b/flake.nix
index a15d0ce..192bdf6 100644
--- a/flake.nix
+++ b/flake.nix
@@ -30,5 +30,5 @@
           };
         };
     in
-    { inherit overlay; } // inputs.flake-utils.lib.eachDefaultSystem perSystem;
+    { inherit overlay; } // inputs.flake-utils.lib.eachSystem [ "x86_64-linux" ]  perSystem;
 }

With this change, nix flake show works again:

$ nix flake show
git+file:///home/me/git/purenix-org/purenix
├───defaultPackage
│   └───x86_64-linux: package 'purenix-1.0'
├───devShell
│   └───x86_64-linux: development environment 'ghc-shell-for-purenix-1.0-0'
├───devShells
│   └───x86_64-linux
│       ├───hacking-on-purenix: development environment 'ghc-shell-for-purenix-1.0-0'
│       └───use-purenix: development environment 'use-purenix-shell'
├───overlay: Nixpkgs overlay
└───packages
    └───x86_64-linux
        └───purenix: package 'purenix-1.0'

Since this is more of an upstream Nix problem, I'll go ahead and close this!

@kamoii
Copy link
Author

kamoii commented Nov 29, 2021

@cdepillabout
Thank you very much for the information, I did not know about IFD, I will look into it.

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

2 participants