mattpolzin / nix-idris2-packages

5 stars 1 forks source link

[a note]: `/. + builtins.getEnv "PWD"` doesnt work for me #30

Open srghma opened 4 weeks ago

srghma commented 4 weeks ago

IF have src = /. + builtins.getEnv "PWD" (or no src)

        # nix develop
        devShell = inputs.packageset.impureShell {
          inherit system;
          # src = builtins.getEnv "PWD"; # throws error "builder for '/nix/store/95dfjlcyajz57n4k0vlqa200cjnkz7x9-pack-attrs.drv' failed with exit code 1"
          src = /. + builtins.getEnv "PWD"; # throws error "builder for '/nix/store/95dfjlcyajz57n4k0vlqa200cjnkz7x9-pack-attrs.drv' failed with exit code 1"
          # src = ./.; # works ok
          ipkgName = "pack";
        };
 ✘  ~/projects/idris2-pack   nix-support2 ±  nix develop --show-trace
warning: Git tree '/home/srghma/projects/idris2-pack' is dirty
warning: 'https://all-hies.cachix.org' does not appear to be a binary cache
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

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

       … while evaluating attribute 'buildInputs' of derivation 'nix-shell'
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/pkgs/stdenv/generic/make-derivation.nix:383:7:
          382|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          383|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          384|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

       … while calling the 'elemAt' builtin
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/pkgs/stdenv/generic/make-derivation.nix:383:37:
          382|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          383|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |                                     ^
          384|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

       … while calling the 'map' builtin
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/pkgs/stdenv/generic/make-derivation.nix:312:8:
          311|       (map (drv: getDev drv.__spliced.hostHost or drv) (checkDependencyList "depsHostHost" depsHostHost))
          312|       (map (drv: getDev drv.__spliced.hostTarget or drv) (checkDependencyList "buildInputs" buildInputs'))
             |        ^
          313|     ]

       … from call site
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/pkgs/stdenv/generic/make-derivation.nix:312:59:
          311|       (map (drv: getDev drv.__spliced.hostHost or drv) (checkDependencyList "depsHostHost" depsHostHost))
          312|       (map (drv: getDev drv.__spliced.hostTarget or drv) (checkDependencyList "buildInputs" buildInputs'))
             |                                                           ^
          313|     ]

       … while calling 'checkDependencyList''
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/pkgs/stdenv/generic/make-derivation.nix:279:43:
          278|   checkDependencyList = checkDependencyList' [];
          279|   checkDependencyList' = positions: name: deps:
             |                                           ^
          280|     imap1

       … from call site
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/pkgs/stdenv/generic/make-derivation.nix:280:5:
          279|   checkDependencyList' = positions: name: deps:
          280|     imap1
             |     ^
          281|       (index: dep:

       … while calling 'imap1'
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/lib/lists.nix:334:14:
          333|   */
          334|   imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list);
             |              ^
          335|

       … while calling the 'genList' builtin
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/lib/lists.nix:334:20:
          333|   */
          334|   imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list);
             |                    ^
          335|

       … while evaluating the second argument passed to builtins.genList

       … while calling the 'length' builtin
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/lib/lists.nix:334:60:
          333|   */
          334|   imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list);
             |                                                            ^
          335|

       … from call site
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/pkgs/build-support/mkshell/default.nix:40:17:
           39|
           40|   buildInputs = mergeInputs "buildInputs";
             |                 ^
           41|   nativeBuildInputs = packages ++ (mergeInputs "nativeBuildInputs");

       … while calling 'mergeInputs'
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/pkgs/build-support/mkshell/default.nix:17:17:
           16| let
           17|   mergeInputs = name:
             |                 ^
           18|     (attrs.${name} or [ ]) ++

       … while calling the 'filter' builtin
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/pkgs/build-support/mkshell/default.nix:23:6:
           22|     # this leaves actual dependencies of the derivations in `inputsFrom`, but never the derivations themselves
           23|     (lib.subtractLists inputsFrom (lib.flatten (lib.catAttrs name inputsFrom)));
             |      ^
           24|

       … from call site
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/pkgs/build-support/mkshell/default.nix:23:36:
           22|     # this leaves actual dependencies of the derivations in `inputsFrom`, but never the derivations themselves
           23|     (lib.subtractLists inputsFrom (lib.flatten (lib.catAttrs name inputsFrom)));
             |                                    ^
           24|

       … while calling 'flatten'
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/lib/lists.nix:431:13:
          430|   */
          431|   flatten = x:
             |             ^
          432|     if isList x

       … while evaluating a branch condition
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/lib/lists.nix:432:5:
          431|   flatten = x:
          432|     if isList x
             |     ^
          433|     then concatMap (y: flatten y) x

       … while calling the 'isList' builtin
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/lib/lists.nix:432:8:
          431|   flatten = x:
          432|     if isList x
             |        ^
          433|     then concatMap (y: flatten y) x

       … while calling the 'catAttrs' builtin
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/pkgs/build-support/mkshell/default.nix:23:49:
           22|     # this leaves actual dependencies of the derivations in `inputsFrom`, but never the derivations themselves
           23|     (lib.subtractLists inputsFrom (lib.flatten (lib.catAttrs name inputsFrom)));
             |                                                 ^
           24|

       … while calling a functor (an attribute set with a '__functor' attribute)
         at /nix/store/bdzpxlrd0bdb7lj8jn49kpihic8yhdld-source/ipkg-shell.nix:10:9:
            9| let
           10|   pkg = buildIdris' {
             |         ^
           11|     inherit src ipkgName;

       … from call site
         at /nix/store/00vdsv2f7plfmhfxkzywqpiryd3bifha-source/lib/trivial.nix:966:7:
          965|     { # TODO: Should we add call-time "type" checking like built in?
          966|       __functor = self: f;
             |       ^
          967|       __functionArgs = args;

       … while calling anonymous lambda
         at /nix/store/bdzpxlrd0bdb7lj8jn49kpihic8yhdld-source/build-idris-prime.nix:18:1:
           17| }:
           18| {
             | ^
           19|   src,

       … from call site
         at /nix/store/bdzpxlrd0bdb7lj8jn49kpihic8yhdld-source/build-idris-prime.nix:66:1:
           65| in
           66| execOrLib (
             | ^
           67|   buildIdris (

       … while calling 'execOrLib'
         at /nix/store/bdzpxlrd0bdb7lj8jn49kpihic8yhdld-source/build-idris-prime.nix:54:5:
           53|   execOrLib =
           54|     pkg: if ipkgAttrs ? "executable" then pkg.executable else pkg.library { inherit withSource; };
             |     ^
           55|

       … while evaluating a branch condition
         at /nix/store/bdzpxlrd0bdb7lj8jn49kpihic8yhdld-source/build-idris-prime.nix:54:10:
           53|   execOrLib =
           54|     pkg: if ipkgAttrs ? "executable" then pkg.executable else pkg.library { inherit withSource; };
             |          ^
           55|

       … while calling the 'fromJSON' builtin
         at /nix/store/bdzpxlrd0bdb7lj8jn49kpihic8yhdld-source/build-idris-prime.nix:33:15:
           32|   withSource ? false,
           33|   ipkgAttrs ? builtins.fromJSON (
             |               ^
           34|     builtins.readFile (

       … while evaluating the first argument passed to builtins.fromJSON

       … while calling the 'readFile' builtin
         at /nix/store/bdzpxlrd0bdb7lj8jn49kpihic8yhdld-source/build-idris-prime.nix:34:5:
           33|   ipkgAttrs ? builtins.fromJSON (
           34|     builtins.readFile (
             |     ^
           35|       import ./ipkg-attrs.nix {

       … while realising the context of path '/nix/store/zfz8mbq1d4z2z9sgpl7hqxmzc8qmr3s6-pack-attrs'

       error: builder for '/nix/store/95dfjlcyajz57n4k0vlqa200cjnkz7x9-pack-attrs.drv' failed with exit code 1

so I had to replace with src = ./.;

P.S. couldnt reproduce with

:lf .
pkgs = inputs.nixpkgs.outputs.legacyPackages."x86_64-linux"

f = { runCommand, idris2, src, ipkgName, }: runCommand "${ipkgName}-attrs" { nativeBuildInputs = [ idris2 ]; } ''cd "${src}"; ls -al .; idris2 --dump-ipkg-json ${ipkgName}.ipkg > $out''
src = /. + builtins.getEnv "PWD"
:b f { runCommand = pkgs.runCommand; idris2 = pkgs.idris2; src = src; ipkgName = "pack"; }

builds ok but

 ✘  ~/projects/idris2-pack   nix-support2 ±  cat /nix/store/w2n7f70q3hnyzgzpwlpvfx2xcchd2irj-pack-attrs
     ____    __     _         ___
    /  _/___/ /____(_)____   |__ \
    / // __  / ___/ / ___/   __/ /     Version 0.7.0
  _/ // /_/ / /  / (__  )   / __/      https://www.idris-lang.org
 /___/\__,_/_/  /_/____/   /____/      Type :? for help

Welcome to Idris 2.  Enjoy yourself!
File error in --dump-ipkg-json: File Not Found
Main>
Bye for now!
srghma commented 4 weeks ago
        pack = pkgs.idris2Packages.buildIdris' {
          ipkgName = "pack";
          # src = ./.;
          src = /. + builtins.getEnv "PWD";
        };

fails with same error

mattpolzin commented 4 weeks ago

Huh. Getting PWD always felt like a hack anyway, but it was a nice thought that in the simplest possible case not even a source directory would need to be specified.