How to get access to a private git repo in a nixos configuration (/etc/nixos/configuration.nix) ?
Thanks in advance for kind hearts…
fetchgit
supports adding a .netrc
file via impure env vars: https://github.com/NixOS/nixpkgs/blob/d7fbd8f0dce50bf6c2d630e8dcff59954044b582/pkgs/build-support/fetchgit/default.nix#L29
I haven’t used it in a while, something like this:
fetchgit {
# Skipping the repo set up...
netrcPhase = ''
echo "machine $MACHINE login $LOGIN password $PASSWORD" > .netrc
'';
netrcImpureEnvVars = ["MACHINE", "LOGIN", "PASSWORD"];
}
Then you just set those env vars in the shell that runs your builder, ideally without exposing them to anything other than nix.
1 Like