default: use fetchGit
when in git repository
This commit is contained in:
parent
3c9a6ebd7d
commit
3abc719c76
2 changed files with 21 additions and 13 deletions
30
default.nix
30
default.nix
|
@ -13,19 +13,25 @@ let
|
|||
storePathLength = builtins.stringLength (builtins.toString builtins.storeDir);
|
||||
evaluatingInStore = (builtins.substring 0 storePathLength currentFilePath) == builtins.storeDir;
|
||||
|
||||
selfInStore = builtins.path {
|
||||
path = ./.;
|
||||
name = "source";
|
||||
filter = path: type:
|
||||
let
|
||||
selfPath = builtins.dirOf currentFilePath;
|
||||
gitIgnoreFilters = lib.parseGitignore selfPath path;
|
||||
result = type != "unknown"
|
||||
&& type != "symlink"
|
||||
&& builtins.baseNameOf path != ".git"
|
||||
&& lib.runGitignoreFilter gitIgnoreFilters path type;
|
||||
in result;
|
||||
gitlessSelfInStore = {
|
||||
outPath = builtins.path {
|
||||
path = ./.;
|
||||
name = "source";
|
||||
filter = path: type:
|
||||
let
|
||||
selfPath = builtins.dirOf currentFilePath;
|
||||
gitIgnoreFilters = lib.parseGitignore selfPath path;
|
||||
result = type != "unknown"
|
||||
&& type != "symlink"
|
||||
&& builtins.baseNameOf path != ".git"
|
||||
&& 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
|
||||
if !(evaluatingInStore) then { ... }@args: import selfInStore ({ selfPath = selfInStore; } // args )
|
||||
else { ... }@args: import ./outputs.nix ({ selfPath = selfInStore; } // args)
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
{
|
||||
inputsPath ? ./inputs.nix,
|
||||
inputs ? import inputsPath {},
|
||||
selfPath ? builtins.toString ./.,
|
||||
selfPath ? {
|
||||
outPath = builtins.toString ./.;
|
||||
},
|
||||
}:
|
||||
|
||||
let
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue