default: use fetchGit when in git repository

This commit is contained in:
Wroclaw 2025-05-04 16:19:06 +02:00
parent 3c9a6ebd7d
commit 3abc719c76
2 changed files with 21 additions and 13 deletions

View file

@ -13,19 +13,25 @@ let
storePathLength = builtins.stringLength (builtins.toString builtins.storeDir); storePathLength = builtins.stringLength (builtins.toString builtins.storeDir);
evaluatingInStore = (builtins.substring 0 storePathLength currentFilePath) == builtins.storeDir; evaluatingInStore = (builtins.substring 0 storePathLength currentFilePath) == builtins.storeDir;
selfInStore = builtins.path { gitlessSelfInStore = {
path = ./.; outPath = builtins.path {
name = "source"; path = ./.;
filter = path: type: name = "source";
let filter = path: type:
selfPath = builtins.dirOf currentFilePath; let
gitIgnoreFilters = lib.parseGitignore selfPath path; selfPath = builtins.dirOf currentFilePath;
result = type != "unknown" gitIgnoreFilters = lib.parseGitignore selfPath path;
&& type != "symlink" result = type != "unknown"
&& builtins.baseNameOf path != ".git" && type != "symlink"
&& lib.runGitignoreFilter gitIgnoreFilters path type; && builtins.baseNameOf path != ".git"
in result; && lib.runGitignoreFilter gitIgnoreFilters path type;
in result;
};
}; };
gitfullSelfInStore = builtins.fetchGit "file://${builtins.toString ./.}";
selfInStore' = builtins.tryEval gitfullSelfInStore;
selfInStore = if selfInStore'.success then selfInStore'.value else gitlessSelfInStore;
in in
if !(evaluatingInStore) then { ... }@args: import selfInStore ({ selfPath = selfInStore; } // args ) if !(evaluatingInStore) then { ... }@args: import selfInStore ({ selfPath = selfInStore; } // args )
else { ... }@args: import ./outputs.nix ({ selfPath = selfInStore; } // args) else { ... }@args: import ./outputs.nix ({ selfPath = selfInStore; } // args)

View file

@ -1,7 +1,9 @@
{ {
inputsPath ? ./inputs.nix, inputsPath ? ./inputs.nix,
inputs ? import inputsPath {}, inputs ? import inputsPath {},
selfPath ? builtins.toString ./., selfPath ? {
outPath = builtins.toString ./.;
},
}: }:
let let