At work, we have a GitLab instance that users can pull from using SSH. I am currently setting up a Gitlab Runner to build “Project A” with Nix. This project depends on another “Project B” in the same private Gitlab.
So somewhere in the Project A default.nix
, I have
project-b = import (fetchGit {
url = "git@gitlab.example.com/group/project-b.git";
rev = "326ce97a6c46bef4d44cf2a18573cb083e7440d4";
});
Now, when I run nix-build
locally, I am prompted for the password for my SSH key and everything works as expected.
I would prefer not to place SSH keys on the Gitlab Runner. But what I can do before nix-build
is, so I thought:
nix-prefetch-git https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.example.com/group/project-b.git 326ce97a6c46bef4d44cf2a18573cb083e7440d4
This will fetch the repository just fine, but the fetchGit
does not use it. What is the reason for that, and how do I solve it?
What I will try next is to replace fetchGit
with fetchgit
. This allows me to specify a hash and maybe then the source will be reused, but it will also force me to import nixpkgs everywhere and I will lose the comfort of being able to provide my personal SSH key password when building locally.
Alex