Get Private git repo in nixos configuration

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:

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