hercules-ci/gitignore.nix

Pure eval mode still having issues

Closed this issue · 6 comments

jaen commented

I have a flake which uses a flake that cleans sources using gitignore.nix. I've been having the ~/.gitignore issue in both repos. I have upgraded gitignore.nix in the dependency repo and the issue stopped happening there. But in the flake that uses this dependency I'm getting this now (after upgrading the dependency):

╭─jaen@hotaru ~/Projects/homelab/infrastructure <master*>
╰─$ nix develop
warning: Git tree '/home/jaen/Projects/homelab/infrastructure' is dirty
error (ignored): error: end of string reached
error: the path '~/.' can not be resolved in pure mode
(use '--show-trace' to show detailed location information)

so it seems it's still not quite fixed?

Nix will not update transitive dependencies in some cases. Please make sure that the transitive dependency is up to date using nix flake lock --update-input xyz or nix flake lock --recreate-lock-file.
If the issue still occurs, could you post the trace as suggested in the error message?

jaen commented

Looks up to date to me:

╭─jaen@hotaru ~/Projects/homelab/infrastructure <master>
╰─$ jq '.nodes."image-builder".inputs."nix-gitignore"' ./flake.lock
"nix-gitignore"

╭─jaen@hotaru ~/Projects/homelab/infrastructure <master>
╰─$ jq '.nodes."nix-gitignore".locked.rev' ./flake.lock
"f840a659d57e53fa751a9248b17149fd0cf2a221"

The stracktrace looks like follows:

╭─jaen@hotaru ~/Projects/homelab/infrastructure <master>
╰─$ nix develop --show-trace
error (ignored): error: end of string reached
error: the path '~/.' can not be resolved in pure mode

       … while realising the context of a path

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:276:21:

          275|   # TODO: get something like builtins.pathType or builtins.stat into Nix
          276|   guardFile = p: if pathExists p then [p] else [];
             |                     ^
          277|   guardNonEmptyString = s: if s == "" then [s] else [];

       … while evaluating 'guardFile'

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:276:15:

          275|   # TODO: get something like builtins.pathType or builtins.stat into Nix
          276|   guardFile = p: if pathExists p then [p] else [];
             |               ^
          277|   guardNonEmptyString = s: if s == "" then [s] else [];

       … from call site

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:215:31:

          214|       );
          215|   maybeGlobalConfig = take 1 (guardFile (home /.gitconfig)
             |                               ^
          216|                            ++ maybeXdgGitConfigFile

       … while evaluating 'sublist'

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/lib/lists.nix:590:5:

          589|     # Input list
          590|     list:
             |     ^
          591|     let len = length list; in

       … from call site

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:215:23:

          214|       );
          215|   maybeGlobalConfig = take 1 (guardFile (home /.gitconfig)
             |                       ^
          216|                            ++ maybeXdgGitConfigFile

       … while evaluating 'for'

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:263:12:

          262|   nullableToList = x: if x == null then [] else [x];
          263|   for = l: f: concatMap f l;
             |            ^
          264|   guard = b: if b then [{}] else [];

       … from call site

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:219:23:

          218|
          219|   globalConfigItems = for maybeGlobalConfig (globalConfigFile:
             |                       ^
          220|     parse-ini.parseIniFile globalConfigFile

       … while evaluating 'for'

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:263:12:

          262|   nullableToList = x: if x == null then [] else [x];
          263|   for = l: f: concatMap f l;
             |            ^
          264|   guard = b: if b then [{}] else [];

       … from call site

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:223:5:

          222|   globalConfiguredExcludesFile = take 1 (
          223|     for
             |     ^
          224|       globalConfigItems

       … while evaluating 'sublist'

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/lib/lists.nix:590:5:

          589|     # Input list
          590|     list:
             |     ^
          591|     let len = length list; in

       … from call site

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:222:34:

          221|   );
          222|   globalConfiguredExcludesFile = take 1 (
             |                                  ^
          223|     for

       … while evaluating 'sublist'

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/lib/lists.nix:590:5:

          589|     # Input list
          590|     list:
             |     ^
          591|     let len = length list; in

       … from call site

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:238:28:

          237|     );
          238|   maybeGlobalIgnoresFile = take 1
             |                            ^
          239|                             ( globalConfiguredExcludesFile

       … while evaluating 'findAncestryGitignores'

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:108:28:

          107|   #
          108|   findAncestryGitignores = path:
             |                            ^
          109|     let

       … from call site

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:67:34:

           66|                                  parse-gitignore.gitignoreFilter (readFile file) contextDir
           67|                               ) (findAncestryGitignores dir);
             |                                  ^
           68|       startingPatterns = builtins.foldl'

       … while evaluating 'runFilterPattern'

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/rules.nix:34:14:

           33|   runFilterPattern =
           34|     r: path: type:
             |              ^
           35|       let

       … from call site

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:87:32:

           86|                               type == nodeTypes.directory &&
           87|                               (parse-gitignore.runFilterPattern currentPatterns (dir + "/${name}") type)
             |                                ^
           88|                            ) nodes;

       … while evaluating anonymous lambda

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:85:35:

           84|     let nodes = readDir dir;
           85|         dirs = filterAttrs (name: type:
             |                                   ^
           86|                               type == nodeTypes.directory &&

       … from call site

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/lib/attrsets.nix:225:62:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                                                              ^
          226|

       … while evaluating anonymous lambda

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/lib/attrsets.nix:225:29:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                             ^
          226|

       … from call site

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/lib/attrsets.nix:225:18:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                  ^
          226|

       … while evaluating 'filterAttrs'

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/lib/attrsets.nix:224:23:

          223|   */
          224|   filterAttrs = pred: set:
             |                       ^
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));

       … from call site

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:85:16:

           84|     let nodes = readDir dir;
           85|         dirs = filterAttrs (name: type:
             |                ^
           86|                               type == nodeTypes.directory &&

       … while evaluating 'findDescendantPatternsTree'

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:83:49:

           82|   # currentPatterns.
           83|   findDescendantPatternsTree = currentPatterns: dir:
             |                                                 ^
           84|     let nodes = readDir dir;

       … from call site

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:73:7:

           72|     in
           73|       findDescendantPatternsTree startingPatterns dir;
             |       ^
           74|

       … while evaluating 'findPatternsTree'

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:63:22:

           62|    */
           63|   findPatternsTree = dir:
             |                      ^
           64|     let

       … from call site

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:25:24:

           24|     let
           25|       patternsBelowP = findPatternsTree basePath;
             |                        ^
           26|       basePathStr = toString basePath;

       … while evaluating 'getPatterns'

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:37:18:

           36|   getPatterns =
           37|     patternTree: pathElems:
             |                  ^
           38|       if length pathElems == 0

       … from call site

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:42:14:

           41|         if hd == "" || hd == "."
           42|         then getPatterns patternTree (tail pathElems)
             |              ^
           43|         else

       … while evaluating 'getPatterns'

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:37:18:

           36|   getPatterns =
           37|     patternTree: pathElems:
             |                  ^
           38|       if length pathElems == 0

       … from call site

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:31:59:

           30|         localDirPathElements = splitString "/" localDirPath;
           31|         patternResult = parse-gitignore.runFilterPattern (getPatterns patternsBelowP localDirPathElements)."/patterns" path type;
             |                                                           ^
           32|         nonempty = any (nodeName: gitignoreFilter (basePath + "/${nodeName}") != false)

       … while evaluating 'runFilterPattern'

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/rules.nix:34:14:

           33|   runFilterPattern =
           34|     r: path: type:
             |              ^
           35|       let

       … from call site

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:31:25:

           30|         localDirPathElements = splitString "/" localDirPath;
           31|         patternResult = parse-gitignore.runFilterPattern (getPatterns patternsBelowP localDirPathElements)."/patterns" path type;
             |                         ^
           32|         nonempty = any (nodeName: gitignoreFilter (basePath + "/${nodeName}") != false)

       … while evaluating anonymous lambda

       at /nix/store/mjjr6c5c1cjvj17dx11bmyhzvpx2wy0f-source/find-files.nix:28:13:

           27|     in
           28|       path: type: let
             |             ^
           29|         localDirPath = removePrefix basePathStr (toString (dirOf path));

       … from call site

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/lib/sources.nix:106:28:

          105|       inherit (orig) origSrc;
          106|       filter = path: type: filter path type && orig.filter path type;
             |                            ^
          107|       name = if name != null then name else orig.name;

       … while evaluating 'filter'

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/lib/sources.nix:106:22:

          105|       inherit (orig) origSrc;
          106|       filter = path: type: filter path type && orig.filter path type;
             |                      ^
          107|       name = if name != null then name else orig.name;

       … from call site

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/lib/sources.nix:261:17:

          260|       inherit origSrc filter name;
          261|       outPath = builtins.path { inherit filter name; path = origSrc; };
             |                 ^
          262|     };

       … while adding path '/nix/store/ykj35hvw9j180bwg4dbxljjjvkyn2dn7-source'

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/lib/sources.nix:261:17:

          260|       inherit origSrc filter name;
          261|       outPath = builtins.path { inherit filter name; path = origSrc; };
             |                 ^
          262|     };

       … while evaluating the attribute 'src' of the derivation 'image-builder'

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/pkgs/stdenv/generic/make-derivation.nix:278:7:

          277|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          278|       name =
             |       ^
          279|         let

       … while evaluating the attribute 'text' of the derivation 'image-builder'

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/pkgs/stdenv/generic/make-derivation.nix:278:7:

          277|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          278|       name =
             |       ^
          279|         let

       … while evaluating the attribute 'buildInputs' of the derivation 'nix-shell'

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/pkgs/stdenv/generic/make-derivation.nix:278:7:

          277|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          278|       name =
             |       ^
          279|         let

Ok, that seems to be a new failure mode then. Does #60 fix the problem for you?

jaen commented

@roberth I have tested it like this:

diff --git a/flake.lock b/flake.lock
index fc07b92..001c3c1 100644
--- a/flake.lock
+++ b/flake.lock
@@ -301,7 +301,9 @@
         "flake-compat": "flake-compat_3",
         "flake-utils": "flake-utils_6",
         "mach-nix": "mach-nix",
-        "nix-gitignore": "nix-gitignore",
+        "nix-gitignore": [
+          "nix-gitignore"
+        ],
         "nixpkgs": [
           "nixpkgs"
         ],
@@ -387,15 +389,16 @@
     "nix-gitignore": {
       "flake": false,
       "locked": {
-        "lastModified": 1657706534,
-        "narHash": "sha256-5jIzNHKtDu06mA325K/5CshUVb5r7sSmnRiula6Gr7o=",
+        "lastModified": 1658400562,
+        "narHash": "sha256-wk38v/mbLsOo6+IDmmH1H0ADR87iq9QTTD1BP9X2Ags=",
         "owner": "hercules-ci",
         "repo": "gitignore.nix",
-        "rev": "f840a659d57e53fa751a9248b17149fd0cf2a221",
+        "rev": "e42bb748f3947d3264c38f84883422ffa4300e74",
         "type": "github"
       },
       "original": {
         "owner": "hercules-ci",
+        "ref": "globalIgnores-pure-mode",
         "repo": "gitignore.nix",
         "type": "github"
       }
@@ -532,6 +535,7 @@
         "flake-utils-plus": "flake-utils-plus",
         "image-builder": "image-builder",
         "nickel": "nickel",
+        "nix-gitignore": "nix-gitignore",
         "nix-ng": "nix-ng",
         "nix-processmgmt": "nix-processmgmt",
         "nixpkgs": "nixpkgs_2",
diff --git a/flake.nix b/flake.nix
index 75a9eec..02bf0d2 100644
--- a/flake.nix
+++ b/flake.nix
@@ -13,8 +13,9 @@
     # nix-container-images = { url = "github:cloudwatt/nix-container-images"; flake = false; };
     # With the follows it somehow breaks from missing alejandra?!?!
     nickel               = { url = "github:tweag/nickel"; }; # inputs.nixpkgs.follows = "nixpkgs"; };
+    nix-gitignore        = { url = "github:hercules-ci/gitignore.nix/globalIgnores-pure-mode";        flake = false; };
 
-    image-builder        = { url = "git+ssh://git@git.jaen.me/jaen/image-builder.git"; inputs.nixpkgs.follows = "nixpkgs"; };
+    image-builder        = { url = "git+ssh://git@git.jaen.me/jaen/image-builder.git"; inputs.nixpkgs.follows = "nixpkgs"; inputs.nix-gitignore.follows = "nix-gitignore"; };
     deployer             = { url = "git+ssh://git@git.jaen.me/jaen/deployer.git"; inputs.nixpkgs.follows = "nixpkgs"; };
   };

and the error doesn't appear again, so it looks like it fixes the issue.

Great! Merging...

+        "rev": "e42

Error 42? Sounds about right then ;)

jaen commented

FWIW confirmed upgrading to new master fixes it, thanks!