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

Rembg package for python don't work when imported in a flake #754

Open
jptrzy opened this issue Aug 24, 2024 · 1 comment
Open

Rembg package for python don't work when imported in a flake #754

jptrzy opened this issue Aug 24, 2024 · 1 comment

Comments

@jptrzy
Copy link

jptrzy commented Aug 24, 2024

It is my first time using nur repos, so I don't know, if the issue is on my side or not.

I tried importing nur.repos..hello-nur and everything worked fine,
but while importing nur.repos.nagy.python3Packages.rembg everything starts to fuck up.

flake.nix:

{
  description = "TODo";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
    nur.url = "github:nix-community/NUR";
  };

  outputs = { self, nixpkgs, nur, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let
    pkgs = import nixpkgs { inherit system; };

    nurPkgs = import nur {
      nurpkgs = pkgs;
      pkgs = pkgs;
    };

    pythonEnv = pkgs.python3.withPackages (ps: with ps; [
      nurPkgs.repos.nagy.python3Packages.rembg
    ]);
  in {
    devShell = pkgs.mkShell {
      packages = [
        nurPkgs.repos.mic92.hello-nur
        pythonEnv
      ];
    };
  });
}

Error message:

$ nix develop --show-trace
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:9:12:
            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'nix-shell'
         whose name attribute is located at /nix/store/xd4806df52f1vhc7w614vqkffvw1763f-source/pkgs/stdenv/generic/make-derivation.nix:336:7

       … while evaluating attribute 'nativeBuildInputs' of derivation 'nix-shell'
         at /nix/store/xd4806df52f1vhc7w614vqkffvw1763f-source/pkgs/stdenv/generic/make-derivation.nix:380:7:
          379|       depsBuildBuild              = elemAt (elemAt dependencies 0) 0;
          380|       nativeBuildInputs           = elemAt (elemAt dependencies 0) 1;
             |       ^
          381|       depsBuildTarget             = elemAt (elemAt dependencies 0) 2;

       … while calling the 'getAttr' builtin
         at <nix/derivation-internal.nix>:19:19:
           18|       value = commonAttrs // {
           19|         outPath = builtins.getAttr outputName strict;
             |                   ^
           20|         drvPath = strict.drvPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:9:12:
            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'python3-3.12.4-env'
         whose name attribute is located at /nix/store/xd4806df52f1vhc7w614vqkffvw1763f-source/pkgs/stdenv/generic/make-derivation.nix:336:7

       … while evaluating attribute 'passAsFile' of derivation 'python3-3.12.4-env'
         at /nix/store/xd4806df52f1vhc7w614vqkffvw1763f-source/pkgs/build-support/trivial-builders/default.nix:60:9:
           59|         inherit buildCommand name;
           60|         passAsFile = [ "buildCommand" ]
             |         ^
           61|           ++ (derivationArgs.passAsFile or [ ]);

       … while evaluating the attribute 'passAsFile'
         at /nix/store/xd4806df52f1vhc7w614vqkffvw1763f-source/pkgs/build-support/buildenv/default.nix:76:5:
           75|     # XXX: The size is somewhat arbitrary
           76|     passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else [ ];
             |     ^
           77|   }

       … while evaluating a branch condition
         at /nix/store/xd4806df52f1vhc7w614vqkffvw1763f-source/pkgs/build-support/buildenv/default.nix:76:18:
           75|     # XXX: The size is somewhat arbitrary
           76|     passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else [ ];
             |                  ^
           77|   }

       … in the argument of the not operator
         at /nix/store/xd4806df52f1vhc7w614vqkffvw1763f-source/pkgs/build-support/buildenv/default.nix:76:48:
           75|     # XXX: The size is somewhat arbitrary
           76|     passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else [ ];
             |                                                ^
           77|   }

       … while calling the 'lessThan' builtin
         at /nix/store/xd4806df52f1vhc7w614vqkffvw1763f-source/pkgs/build-support/buildenv/default.nix:76:48:
           75|     # XXX: The size is somewhat arbitrary
           76|     passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else [ ];
             |                                                ^
           77|   }

       … while calling the 'stringLength' builtin
         at /nix/store/xd4806df52f1vhc7w614vqkffvw1763f-source/pkgs/build-support/buildenv/default.nix:76:21:
           75|     # XXX: The size is somewhat arbitrary
           76|     passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else [ ];
             |                     ^
           77|   }

       … while calling the 'toJSON' builtin
         at /nix/store/xd4806df52f1vhc7w614vqkffvw1763f-source/pkgs/build-support/buildenv/default.nix:58:12:
           57|             nativeBuildInputs buildInputs;
           58|     pkgs = builtins.toJSON (map (drv: {
             |            ^
           59|       paths =

       … while calling the 'map' builtin
         at /nix/store/xd4806df52f1vhc7w614vqkffvw1763f-source/pkgs/build-support/buildenv/default.nix:58:29:
           57|             nativeBuildInputs buildInputs;
           58|     pkgs = builtins.toJSON (map (drv: {
             |                             ^
           59|       paths =

       … from call site
         at /nix/store/xd4806df52f1vhc7w614vqkffvw1763f-source/pkgs/development/interpreters/python/wrapper.nix:20:13:
           19|   env = let
           20|     paths = requiredPythonModules (extraLibs ++ [ python ] ) ;
             |             ^
           21|     pythonPath = "${placeholder "out"}/${python.sitePackages}";

       … while calling 'requiredPythonModules'
         at /nix/store/xd4806df52f1vhc7w614vqkffvw1763f-source/pkgs/development/interpreters/python/python-packages-base.nix:54:27:
           53|   # Get list of required Python modules given a list of derivations.
           54|   requiredPythonModules = drvs: let
             |                           ^
           55|     modules = lib.filter hasPythonModule drvs;

       … while calling the 'foldl'' builtin
         at /nix/store/xd4806df52f1vhc7w614vqkffvw1763f-source/pkgs/development/interpreters/python/python-packages-base.nix:56:6:
           55|     modules = lib.filter hasPythonModule drvs;
           56|   in lib.unique ([python] ++ modules ++ lib.concatLists (lib.catAttrs "requiredPythonModules" modules));
             |      ^
           57|

       … while calling the 'filter' builtin
         at /nix/store/xd4806df52f1vhc7w614vqkffvw1763f-source/pkgs/development/interpreters/python/python-packages-base.nix:55:15:
           54|   requiredPythonModules = drvs: let
           55|     modules = lib.filter hasPythonModule drvs;
             |               ^
           56|   in lib.unique ([python] ++ modules ++ lib.concatLists (lib.catAttrs "requiredPythonModules" modules));

       … while calling 'hasPythonModule'
         at /nix/store/xd4806df52f1vhc7w614vqkffvw1763f-source/pkgs/development/interpreters/python/python-packages-base.nix:51:21:
           50|   # Check whether a derivation provides a Python module.
           51|   hasPythonModule = drv: drv?pythonModule && drv.pythonModule == python;
             |                     ^
           52|

       … in the left operand of the AND (&&) operator
         at /nix/store/xd4806df52f1vhc7w614vqkffvw1763f-source/pkgs/development/interpreters/python/python-packages-base.nix:51:43:
           50|   # Check whether a derivation provides a Python module.
           51|   hasPythonModule = drv: drv?pythonModule && drv.pythonModule == python;
             |                                           ^
           52|

       … from call site
         at /nix/store/5ykifwh5m8232hcks74p8f7phjxdw0mb-source/flake.nix:24:7:
           23|     pythonEnv = pkgs.python3.withPackages (ps: with ps; [
           24|       nurPkgs.repos.nagy.python3Packages.rembg
             |       ^
           25|       # Add other Python packages here if needed

       … while calling 'createRepo'
         at /nix/store/qn9gxai1s6ib5lyfhayq6s7jyzq03dvf-source/default.nix:18:22:
           17|
           18|   createRepo = name: attr: import ./lib/evalRepo.nix {
             |                      ^
           19|     inherit name pkgs lib;

       … from call site
         at /nix/store/qn9gxai1s6ib5lyfhayq6s7jyzq03dvf-source/default.nix:18:28:
           17|
           18|   createRepo = name: attr: import ./lib/evalRepo.nix {
             |                            ^
           19|     inherit name pkgs lib;

       … while calling anonymous lambda
         at /nix/store/qn9gxai1s6ib5lyfhayq6s7jyzq03dvf-source/lib/evalRepo.nix:1:1:
            1| { name
             | ^
            2| , url

       … from call site
         at /nix/store/qn9gxai1s6ib5lyfhayq6s7jyzq03dvf-source/lib/evalRepo.nix:33:11:
           32|     might result in infinite recursion when used with NixOS modules.
           33|   '' else expr (builtins.intersectAttrs args passedArgs)
             |           ^
           34|

       … while calling anonymous lambda
         at /nix/store/jiixxaq1ihy0dzgp78i21gh17piy2h83-source/default.nix:1:1:
            1| {
             | ^
            2|   pkgs ? import <nixpkgs> { },

       … in the left operand of the update (//) operator
         at /nix/store/jiixxaq1ihy0dzgp78i21gh17piy2h83-source/default.nix:17:1:
           16| applied-overlay
           17| // {
             | ^
           18|

       … while calling the 'import' builtin
         at /nix/store/jiixxaq1ihy0dzgp78i21gh17piy2h83-source/default.nix:8:21:
            7| let
            8|   by-name-overlay = import <nixpkgs/pkgs/top-level/by-name-overlay.nix> ./pkgs/by-name;
             |                     ^
            9|   # this line allows packages to call themselves

       … while realising the context of a path

       … while calling the 'findFile' builtin
         at /nix/store/jiixxaq1ihy0dzgp78i21gh17piy2h83-source/default.nix:8:28:
            7| let
            8|   by-name-overlay = import <nixpkgs/pkgs/top-level/by-name-overlay.nix> ./pkgs/by-name;
             |                            ^
            9|   # this line allows packages to call themselves

       error: cannot look up '<nixpkgs/pkgs/top-level/by-name-overlay.nix>' in pure evaluation mode (use '--impure' to override)
@Pandapip1
Copy link

This is an issue with nagy's upstream: https://github.com/nagy/nur-packages/blob/6d4ca3a1f1725bbb9bbe921411e4221eaa97658a/default.nix#L8 is impure. For the time being, adding the --impure argument to your nix commands should work until it's fixed.

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