-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add sources to override sources fetcher #123
base: master
Are you sure you want to change the base?
Conversation
Hi, this works for my private repositories. Would also be interested in knowing what the maintainers think of this solution. |
It would be nice to have support to pass in packages of private go modules so they can be easily re-used between derivations. |
Anyway we can have this merged? |
@marcusramberg: You merged some PRs recently. Maybe there is a chance you could have a look at that as well, since @adisbladis seems out of office? |
I went down a huge path to get this working for myself and I landed on this as the cleanest way, imo test = pkgs.buildGoModule {
name = "test";
src = gitignore.lib.gitignoreSource ./.;
doCheck = false;
ldFlags = "-mod=mod";
vendorHash = "sha256-ZKp4eeZRFWbogDadB8ZJfBXhSYyVYq1uPpz2WekvtPg=";
CGO_ENABLED = 0;
overrideModAttrs = (oldAttrs: {
impureEnvVars = oldAttrs.impureEnvVars or [ ] ++ [
"NIX_GITLAB_TOKEN"
];
preBuild = /* bash */ ''
export HOME=$(mktemp -d)
cat > ~/.netrc <<EOF
machine YOUR_PRIVATE_REPO
login oauth2
password $NIX_GITLAB_TOKEN
EOF
export GOPRIVATE=YOUR_PRIVATE_REPO/*
export GONOSUMDB=YOUR_PRIVATE_REPO
'';
preferLocalBuild = true;
});
}; Maybe we can use this as a way to inspire something that will support private repos? I actually don't even mind having to update the vendorHash when depends change with this method. |
nix-community#123 Signed-off-by: Anthony Rabbito <[email protected]>
@juliens can you rebase this branch? |
40969a6
to
0984963
Compare
nix-community#123 Signed-off-by: Anthony Rabbito <[email protected]>
Thanks @juliens! I am noticing an issue in build:
I assume this is because the go.mod in So inside the vendor directory |
This PR is a proposition to be able to override the source fetcher.
This can collide with #42 but I think it's a simpler solution to the problem.
User needs to define by itself how to fetch the dependency, but with that it works with all repository etc.. (no guessing).
The usage is pretty simple:
I just wonder if it is a problem that we don't verify the origin sha of the dependency and that we move the responsability of the "sha" on the
fetchGit
WDYT?