fetchgit: add a gitConfigFile argument
Passing a `gitConfigFile` argument as a string allows setting a custom git config (as `$GIT_CONFIG_GLOBAL`). The most obvious use is to override URLs with custom mirrors, but others are possible too.
This commit is contained in:
committed by
Silvan Mosberger
parent
1cc72b6eaa
commit
296399ec68
@@ -8,6 +8,11 @@ echo "exporting $url (rev $rev) into $out"
|
||||
|
||||
runHook preFetch
|
||||
|
||||
if [ -n "$gitConfigFile" ]; then
|
||||
echo "using GIT_CONFIG_GLOBAL=$gitConfigFile"
|
||||
export GIT_CONFIG_GLOBAL="$gitConfigFile"
|
||||
fi
|
||||
|
||||
$SHELL $fetcher --builder --url "$url" --out "$out" --rev "$rev" --name "$name" \
|
||||
${leaveDotGit:+--leave-dotGit} \
|
||||
${fetchLFS:+--fetch-lfs} \
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
lib,
|
||||
stdenvNoCC,
|
||||
writeText,
|
||||
git,
|
||||
git-lfs,
|
||||
cacert,
|
||||
@@ -64,6 +65,8 @@ lib.makeOverridable (
|
||||
fetchTags ? false,
|
||||
# make this subdirectory the root of the result
|
||||
rootDir ? "",
|
||||
# GIT_CONFIG_GLOBAL (as a file)
|
||||
gitConfigFile ? null,
|
||||
}:
|
||||
|
||||
/*
|
||||
@@ -148,6 +151,7 @@ lib.makeOverridable (
|
||||
postFetch
|
||||
fetchTags
|
||||
rootDir
|
||||
gitConfigFile
|
||||
;
|
||||
rev = revWithTag;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
cacert,
|
||||
nix,
|
||||
closureInfo,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
@@ -194,4 +195,14 @@
|
||||
rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a";
|
||||
hash = "sha256-7DszvbCNTjpzGRmpIVAWXk20P0/XTrWZ79KSOGLrUWY=";
|
||||
};
|
||||
|
||||
withGitConfig = testers.invalidateFetcherByDrvHash fetchgit {
|
||||
name = "fetchgit-with-config";
|
||||
url = "https://doesntexist.forsure/NixOS/nix";
|
||||
rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a";
|
||||
sha256 = "sha256-7DszvbCNTjpzGRmpIVAWXk20P0/XTrWZ79KSOGLrUWY=";
|
||||
gitConfigFile = builtins.toFile "gitconfig" (lib.generators.toGitINI {
|
||||
url."https://github.com".insteadOf = "https://doesntexist.forsure";
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user