···947947 `gitTrackedWith` does not perform any filtering when the path is a [Nix store path](https://nixos.org/manual/nix/stable/store/store-path.html#store-path) and not a repository.948948 In this way, it accommodates the use case where the expression that makes the `gitTracked` call does not reside in an actual git repository anymore,949949 and has presumably already been fetched in a way that excludes untracked files.950950- Fetchers with such equivalent behavior include `fetchGit`, `fetchTree` (experimental), and `pkgs.fetchgit` when used without `leaveDotGit`.950950+ Fetchers with such equivalent behavior include `builtins.fetchGit`, `builtins.fetchTree` (experimental), and `pkgs.fetchgit` when used without `leaveDotGit`.951951952952 If you don't need the configuration,953953 you can use [`gitTracked`](#function-library-lib.fileset.gitTracked) instead.···956956 (which uses [`--cached`](https://git-scm.com/docs/git-ls-files#Documentation/git-ls-files.txt--c) by default).957957958958 :::{.warning}959959- Currently this function is based on [`fetchGit`](https://nixos.org/manual/nix/stable/language/builtins.html#builtins-fetchGit)959959+ Currently this function is based on [`builtins.fetchGit`](https://nixos.org/manual/nix/stable/language/builtins.html#builtins-fetchGit)960960 As such, this function causes all Git-tracked files to be unnecessarily added to the Nix store,961961 without being re-usable by [`toSource`](#function-library-lib.fileset.toSource).962962
+4-4
lib/fileset/internal.nix
···932932 throw ''933933 lib.fileset.${function}: The ${argument} (${toString path}) is a store path within a working tree of a Git repository.934934 This indicates that a source directory was imported into the store using a method such as `import "''${./.}"` or `path:.`.935935- This function currently does not support such a use case, since it currently relies on `fetchGit`.935935+ This function currently does not support such a use case, since it currently relies on `builtins.fetchGit`.936936 You could make this work by using a fetcher such as `fetchGit` instead of copying the whole repository.937937 If you can't avoid copying the repo to the store, see https://github.com/NixOS/nix/issues/9292.''938938 else939939 # Otherwise we're going to assume that the path was a Git directory originally,940940 # but it was fetched using a method that already removed files not tracked by Git,941941- # such as `fetchGit`, `pkgs.fetchgit` or others.941941+ # such as `builtins.fetchGit`, `pkgs.fetchgit` or others.942942 # So we can just import the path in its entirety.943943 _singleton path;944944···946946 tryFetchGit =947947 let948948 # This imports the files unnecessarily, which currently can't be avoided949949- # because `fetchGit` is the only function exposing which files are tracked by Git.949949+ # because `builtins.fetchGit` is the only function exposing which files are tracked by Git.950950 # With the [lazy trees PR](https://github.com/NixOS/nix/pull/6530),951951 # the unnecessarily import could be avoided.952952 # However a simpler alternative still would be [a builtins.gitLsFiles](https://github.com/NixOS/nix/issues/2944).···960960 in961961 # We can identify local working directories by checking for .git,962962 # see https://git-scm.com/docs/gitrepository-layout#_description.963963- # Note that `fetchGit` _does_ work for bare repositories (where there's no `.git`),963963+ # Note that `builtins.fetchGit` _does_ work for bare repositories (where there's no `.git`),964964 # even though `git ls-files` wouldn't return any files in that case.965965 if !pathExists (path + "/.git") then966966 throw "lib.fileset.${function}: Expected the ${argument} (${toString path}) to point to a local working tree of a Git repository, but it's not."
+3-3
lib/fileset/tests.sh
···14151415## But it fails if the path is imported with a fetcher that doesn't remove .git (like just using "${./.}")14161416expectFailure 'import "${./.}" { fs = lib.fileset; }' 'lib.fileset.gitTracked: The argument \(.*\) is a store path within a working tree of a Git repository.14171417[[:blank:]]*This indicates that a source directory was imported into the store using a method such as `import "\$\{./.\}"` or `path:.`.14181418-[[:blank:]]*This function currently does not support such a use case, since it currently relies on `fetchGit`.14181418+[[:blank:]]*This function currently does not support such a use case, since it currently relies on `builtins.fetchGit`.14191419[[:blank:]]*You could make this work by using a fetcher such as `fetchGit` instead of copying the whole repository.14201420[[:blank:]]*If you can'\''t avoid copying the repo to the store, see https://github.com/NixOS/nix/issues/9292.'14211421···14411441## But it fails if the path is imported with a fetcher that doesn't remove .git (like just using "${./.}")14421442expectFailure 'import "${./.}" { fs = lib.fileset; }' 'lib.fileset.gitTrackedWith: The second argument \(.*\) is a store path within a working tree of a Git repository.14431443[[:blank:]]*This indicates that a source directory was imported into the store using a method such as `import "\$\{./.\}"` or `path:.`.14441444-[[:blank:]]*This function currently does not support such a use case, since it currently relies on `fetchGit`.14441444+[[:blank:]]*This function currently does not support such a use case, since it currently relies on `builtins.fetchGit`.14451445[[:blank:]]*You could make this work by using a fetcher such as `fetchGit` instead of copying the whole repository.14461446[[:blank:]]*If you can'\''t avoid copying the repo to the store, see https://github.com/NixOS/nix/issues/9292.'14471447expectFailure 'import "${./.}/sub" { fs = lib.fileset; }' 'lib.fileset.gitTracked: The argument \(.*/sub\) is a store path within a working tree of a Git repository.14481448[[:blank:]]*This indicates that a source directory was imported into the store using a method such as `import "\$\{./.\}"` or `path:.`.14491449-[[:blank:]]*This function currently does not support such a use case, since it currently relies on `fetchGit`.14491449+[[:blank:]]*This function currently does not support such a use case, since it currently relies on `builtins.fetchGit`.14501450[[:blank:]]*You could make this work by using a fetcher such as `fetchGit` instead of copying the whole repository.14511451[[:blank:]]*If you can'\''t avoid copying the repo to the store, see https://github.com/NixOS/nix/issues/9292.'14521452rm -rf -- *
+1-1
lib/path/README.md
···102102- (-) `./.` is rather long.103103 - (-) We don't require users to type this though, as it's only output by the library.104104 As inputs all three variants are supported for subpaths (and we can't do anything about absolute paths)105105-- (-) `dirOf "foo" == "."`, so `.` would be consistent with that.105105+- (-) `builtins.dirOf "foo" == "."`, so `.` would be consistent with that.106106- (+) `./.` is consistent with the [decision to have leading `./`][leading-dots].107107- (+) `./.` is a valid Nix path expression, although this property does not hold for every relative path or subpath.108108
+1-1
lib/tests/misc.nix
···44874487 testPackagesFromDirectoryRecursiveStringDirectory = {44884488 expr = packagesFromDirectoryRecursive {44894489 callPackage = path: overrides: import path overrides;44904490- # Do NOT remove the `toString` call here!!!44904490+ # Do NOT remove the `builtins.toString` call here!!!44914491 directory = toString ./packages-from-directory/plain;44924492 };44934493 expected = {