lol

lib: add builtins prefixes for prelude functions to improve clarity

NAHO e8f998c3 6177c4ad

+11 -11
+2 -2
lib/fileset/default.nix
··· 947 947 `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. 948 948 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, 949 949 and has presumably already been fetched in a way that excludes untracked files. 950 - Fetchers with such equivalent behavior include `fetchGit`, `fetchTree` (experimental), and `pkgs.fetchgit` when used without `leaveDotGit`. 950 + Fetchers with such equivalent behavior include `builtins.fetchGit`, `builtins.fetchTree` (experimental), and `pkgs.fetchgit` when used without `leaveDotGit`. 951 951 952 952 If you don't need the configuration, 953 953 you can use [`gitTracked`](#function-library-lib.fileset.gitTracked) instead. ··· 956 956 (which uses [`--cached`](https://git-scm.com/docs/git-ls-files#Documentation/git-ls-files.txt--c) by default). 957 957 958 958 :::{.warning} 959 - Currently this function is based on [`fetchGit`](https://nixos.org/manual/nix/stable/language/builtins.html#builtins-fetchGit) 959 + Currently this function is based on [`builtins.fetchGit`](https://nixos.org/manual/nix/stable/language/builtins.html#builtins-fetchGit) 960 960 As such, this function causes all Git-tracked files to be unnecessarily added to the Nix store, 961 961 without being re-usable by [`toSource`](#function-library-lib.fileset.toSource). 962 962
+4 -4
lib/fileset/internal.nix
··· 932 932 throw '' 933 933 lib.fileset.${function}: The ${argument} (${toString path}) is a store path within a working tree of a Git repository. 934 934 This indicates that a source directory was imported into the store using a method such as `import "''${./.}"` or `path:.`. 935 - This function currently does not support such a use case, since it currently relies on `fetchGit`. 935 + This function currently does not support such a use case, since it currently relies on `builtins.fetchGit`. 936 936 You could make this work by using a fetcher such as `fetchGit` instead of copying the whole repository. 937 937 If you can't avoid copying the repo to the store, see https://github.com/NixOS/nix/issues/9292.'' 938 938 else 939 939 # Otherwise we're going to assume that the path was a Git directory originally, 940 940 # but it was fetched using a method that already removed files not tracked by Git, 941 - # such as `fetchGit`, `pkgs.fetchgit` or others. 941 + # such as `builtins.fetchGit`, `pkgs.fetchgit` or others. 942 942 # So we can just import the path in its entirety. 943 943 _singleton path; 944 944 ··· 946 946 tryFetchGit = 947 947 let 948 948 # This imports the files unnecessarily, which currently can't be avoided 949 - # because `fetchGit` is the only function exposing which files are tracked by Git. 949 + # because `builtins.fetchGit` is the only function exposing which files are tracked by Git. 950 950 # With the [lazy trees PR](https://github.com/NixOS/nix/pull/6530), 951 951 # the unnecessarily import could be avoided. 952 952 # However a simpler alternative still would be [a builtins.gitLsFiles](https://github.com/NixOS/nix/issues/2944). ··· 960 960 in 961 961 # We can identify local working directories by checking for .git, 962 962 # see https://git-scm.com/docs/gitrepository-layout#_description. 963 - # Note that `fetchGit` _does_ work for bare repositories (where there's no `.git`), 963 + # Note that `builtins.fetchGit` _does_ work for bare repositories (where there's no `.git`), 964 964 # even though `git ls-files` wouldn't return any files in that case. 965 965 if !pathExists (path + "/.git") then 966 966 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
··· 1415 1415 ## But it fails if the path is imported with a fetcher that doesn't remove .git (like just using "${./.}") 1416 1416 expectFailure 'import "${./.}" { fs = lib.fileset; }' 'lib.fileset.gitTracked: The argument \(.*\) is a store path within a working tree of a Git repository. 1417 1417 [[:blank:]]*This indicates that a source directory was imported into the store using a method such as `import "\$\{./.\}"` or `path:.`. 1418 - [[:blank:]]*This function currently does not support such a use case, since it currently relies on `fetchGit`. 1418 + [[:blank:]]*This function currently does not support such a use case, since it currently relies on `builtins.fetchGit`. 1419 1419 [[:blank:]]*You could make this work by using a fetcher such as `fetchGit` instead of copying the whole repository. 1420 1420 [[:blank:]]*If you can'\''t avoid copying the repo to the store, see https://github.com/NixOS/nix/issues/9292.' 1421 1421 ··· 1441 1441 ## But it fails if the path is imported with a fetcher that doesn't remove .git (like just using "${./.}") 1442 1442 expectFailure 'import "${./.}" { fs = lib.fileset; }' 'lib.fileset.gitTrackedWith: The second argument \(.*\) is a store path within a working tree of a Git repository. 1443 1443 [[:blank:]]*This indicates that a source directory was imported into the store using a method such as `import "\$\{./.\}"` or `path:.`. 1444 - [[:blank:]]*This function currently does not support such a use case, since it currently relies on `fetchGit`. 1444 + [[:blank:]]*This function currently does not support such a use case, since it currently relies on `builtins.fetchGit`. 1445 1445 [[:blank:]]*You could make this work by using a fetcher such as `fetchGit` instead of copying the whole repository. 1446 1446 [[:blank:]]*If you can'\''t avoid copying the repo to the store, see https://github.com/NixOS/nix/issues/9292.' 1447 1447 expectFailure 'import "${./.}/sub" { fs = lib.fileset; }' 'lib.fileset.gitTracked: The argument \(.*/sub\) is a store path within a working tree of a Git repository. 1448 1448 [[:blank:]]*This indicates that a source directory was imported into the store using a method such as `import "\$\{./.\}"` or `path:.`. 1449 - [[:blank:]]*This function currently does not support such a use case, since it currently relies on `fetchGit`. 1449 + [[:blank:]]*This function currently does not support such a use case, since it currently relies on `builtins.fetchGit`. 1450 1450 [[:blank:]]*You could make this work by using a fetcher such as `fetchGit` instead of copying the whole repository. 1451 1451 [[:blank:]]*If you can'\''t avoid copying the repo to the store, see https://github.com/NixOS/nix/issues/9292.' 1452 1452 rm -rf -- *
+1 -1
lib/path/README.md
··· 102 102 - (-) `./.` is rather long. 103 103 - (-) We don't require users to type this though, as it's only output by the library. 104 104 As inputs all three variants are supported for subpaths (and we can't do anything about absolute paths) 105 - - (-) `dirOf "foo" == "."`, so `.` would be consistent with that. 105 + - (-) `builtins.dirOf "foo" == "."`, so `.` would be consistent with that. 106 106 - (+) `./.` is consistent with the [decision to have leading `./`][leading-dots]. 107 107 - (+) `./.` is a valid Nix path expression, although this property does not hold for every relative path or subpath. 108 108
+1 -1
lib/tests/misc.nix
··· 4487 4487 testPackagesFromDirectoryRecursiveStringDirectory = { 4488 4488 expr = packagesFromDirectoryRecursive { 4489 4489 callPackage = path: overrides: import path overrides; 4490 - # Do NOT remove the `toString` call here!!! 4490 + # Do NOT remove the `builtins.toString` call here!!! 4491 4491 directory = toString ./packages-from-directory/plain; 4492 4492 }; 4493 4493 expected = {