diff options
author | Elliot Cameron <nixpkgs-commits@deshaw.com> | 2023-11-10 14:52:31 -0500 |
---|---|---|
committer | Bjørn Forsman <bjorn.forsman@gmail.com> | 2023-11-11 19:34:54 +0100 |
commit | 3a99d1b6424cb4b9c431bec279ee6c832b16948f (patch) | |
tree | 038492c001a58f2cb9b3833a3b8eb61475345db2 | |
parent | 99298c3da07f53464bc1a24b4b7d0882f1acf060 (diff) | |
download | nixpkgs-3a99d1b6424cb4b9c431bec279ee6c832b16948f.tar nixpkgs-3a99d1b6424cb4b9c431bec279ee6c832b16948f.tar.gz nixpkgs-3a99d1b6424cb4b9c431bec279ee6c832b16948f.tar.bz2 nixpkgs-3a99d1b6424cb4b9c431bec279ee6c832b16948f.tar.lz nixpkgs-3a99d1b6424cb4b9c431bec279ee6c832b16948f.tar.xz nixpkgs-3a99d1b6424cb4b9c431bec279ee6c832b16948f.tar.zst nixpkgs-3a99d1b6424cb4b9c431bec279ee6c832b16948f.zip |
nix-prefetch-git: respect NETRC
This script needs to support being run both as part of a `fetchgit` derivation and as a standalone, command-line tool. The use of `$NIX_BUILD_TOP` only works when used in `fetchgit` but not when invoked as a standalone tool. Instead we try to respect `$NETRC` so that the command-line invocation behaves more like standard tools and the `fetchgit` derivation can explicitly set `$NETRC` when `netrcPhase` is used to avoid all ambiguity.
-rw-r--r-- | pkgs/build-support/fetchgit/default.nix | 1 | ||||
-rwxr-xr-x | pkgs/build-support/fetchgit/nix-prefetch-git | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/pkgs/build-support/fetchgit/default.nix b/pkgs/build-support/fetchgit/default.nix index 1d06ce44a91..66bb3b7c09f 100644 --- a/pkgs/build-support/fetchgit/default.nix +++ b/pkgs/build-support/fetchgit/default.nix @@ -90,6 +90,7 @@ stdenvNoCC.mkDerivation { ${netrcPhase} # required that git uses the netrc file mv {,.}netrc + export NETRC=$PWD/.netrc export HOME=$PWD ''; diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git index e02b2ea7fbc..ae3d28cc231 100755 --- a/pkgs/build-support/fetchgit/nix-prefetch-git +++ b/pkgs/build-support/fetchgit/nix-prefetch-git @@ -425,8 +425,8 @@ fi tmpHomePath="$(mktemp -d "${TMPDIR:-/tmp}/nix-prefetch-git-tmp-home-XXXXXXXXXX")" exit_handlers+=(remove_tmpHomePath) +ln -s "${NETRC:-$HOME/.netrc}" "$tmpHomePath/.netrc" HOME="$tmpHomePath" -ln -s "$NIX_BUILD_TOP/.netrc" "$HOME/" unset XDG_CONFIG_HOME export GIT_CONFIG_NOSYSTEM=1 |