|
107 | 107 | _printFileset |
108 | 108 | _intersection |
109 | 109 | _difference |
110 | | - _mirrorStorePath |
| 110 | + _fromFetchGit |
111 | 111 | _fetchGitSubmodulesMinver |
112 | 112 | _emptyWithoutBase |
113 | 113 | ; |
|
148 | 148 | inherit (lib.trivial) |
149 | 149 | isFunction |
150 | 150 | pipe |
151 | | - inPureEvalMode |
152 | 151 | ; |
153 | 152 |
|
154 | 153 | in { |
@@ -754,18 +753,11 @@ in { |
754 | 753 | This directory must contain a `.git` file or subdirectory. |
755 | 754 | */ |
756 | 755 | path: |
757 | | - # See the gitTrackedWith implementation for more explanatory comments |
758 | | - let |
759 | | - fetchResult = builtins.fetchGit path; |
760 | | - in |
761 | | - if inPureEvalMode then |
762 | | - throw "lib.fileset.gitTracked: This function is currently not supported in pure evaluation mode, since it currently relies on `builtins.fetchGit`. See https://github.com/NixOS/nix/issues/9292." |
763 | | - else if ! isPath path then |
764 | | - throw "lib.fileset.gitTracked: Expected the argument to be a path, but it's a ${typeOf path} instead." |
765 | | - else if ! pathExists (path + "/.git") then |
766 | | - throw "lib.fileset.gitTracked: Expected the argument (${toString path}) to point to a local working tree of a Git repository, but it's not." |
767 | | - else |
768 | | - _mirrorStorePath path fetchResult.outPath; |
| 756 | + _fromFetchGit |
| 757 | + "gitTracked" |
| 758 | + "argument" |
| 759 | + path |
| 760 | + {}; |
769 | 761 |
|
770 | 762 | /* |
771 | 763 | Create a file set containing all [Git-tracked files](https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository) in a repository. |
@@ -807,35 +799,19 @@ in { |
807 | 799 | This directory must contain a `.git` file or subdirectory. |
808 | 800 | */ |
809 | 801 | path: |
810 | | - let |
811 | | - # This imports the files unnecessarily, which currently can't be avoided |
812 | | - # because `builtins.fetchGit` is the only function exposing which files are tracked by Git. |
813 | | - # With the [lazy trees PR](https://github.com/NixOS/nix/pull/6530), |
814 | | - # the unnecessarily import could be avoided. |
815 | | - # However a simpler alternative still would be [a builtins.gitLsFiles](https://github.com/NixOS/nix/issues/2944). |
816 | | - fetchResult = builtins.fetchGit { |
817 | | - url = path; |
818 | | - |
819 | | - # This is the only `fetchGit` parameter that makes sense in this context. |
820 | | - # We can't just pass `submodules = recurseSubmodules` here because |
821 | | - # this would fail for Nix versions that don't support `submodules`. |
822 | | - ${if recurseSubmodules then "submodules" else null} = true; |
823 | | - }; |
824 | | - in |
825 | | - if inPureEvalMode then |
826 | | - throw "lib.fileset.gitTrackedWith: This function is currently not supported in pure evaluation mode, since it currently relies on `builtins.fetchGit`. See https://github.com/NixOS/nix/issues/9292." |
827 | | - else if ! isBool recurseSubmodules then |
| 802 | + if ! isBool recurseSubmodules then |
828 | 803 | throw "lib.fileset.gitTrackedWith: Expected the attribute `recurseSubmodules` of the first argument to be a boolean, but it's a ${typeOf recurseSubmodules} instead." |
829 | 804 | else if recurseSubmodules && versionOlder nixVersion _fetchGitSubmodulesMinver then |
830 | 805 | throw "lib.fileset.gitTrackedWith: Setting the attribute `recurseSubmodules` to `true` is only supported for Nix version ${_fetchGitSubmodulesMinver} and after, but Nix version ${nixVersion} is used." |
831 | | - else if ! isPath path then |
832 | | - throw "lib.fileset.gitTrackedWith: Expected the second argument to be a path, but it's a ${typeOf path} instead." |
833 | | - # We can identify local working directories by checking for .git, |
834 | | - # see https://git-scm.com/docs/gitrepository-layout#_description. |
835 | | - # Note that `builtins.fetchGit` _does_ work for bare repositories (where there's no `.git`), |
836 | | - # even though `git ls-files` wouldn't return any files in that case. |
837 | | - else if ! pathExists (path + "/.git") then |
838 | | - throw "lib.fileset.gitTrackedWith: Expected the second argument (${toString path}) to point to a local working tree of a Git repository, but it's not." |
839 | 806 | else |
840 | | - _mirrorStorePath path fetchResult.outPath; |
| 807 | + _fromFetchGit |
| 808 | + "gitTrackedWith" |
| 809 | + "second argument" |
| 810 | + path |
| 811 | + # This is the only `fetchGit` parameter that makes sense in this context. |
| 812 | + # We can't just pass `submodules = recurseSubmodules` here because |
| 813 | + # this would fail for Nix versions that don't support `submodules`. |
| 814 | + (lib.optionalAttrs recurseSubmodules { |
| 815 | + submodules = true; |
| 816 | + }); |
841 | 817 | } |
0 commit comments