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 goDeps handling to go-modules. #94585
Conversation
CI error. |
mkdir source | ||
${depCommand} | ||
${proxyCommand} & | ||
export "GOPROXY=http://localhost:8080" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will cause trouble if no sandbox is used because 8080 will be bound twice.
dep2src = goDep: | ||
{ | ||
inherit (goDep) goPackagePath; | ||
src = if goDep.fetch.type == "git" then | ||
fetchgit { | ||
inherit (goDep.fetch) url rev sha256; | ||
} | ||
else if goDep.fetch.type == "hg" then | ||
fetchhg { | ||
inherit (goDep.fetch) url rev sha256; | ||
} | ||
else if goDep.fetch.type == "bzr" then | ||
fetchbzr { | ||
inherit (goDep.fetch) url rev sha256; | ||
} | ||
else if goDep.fetch.type == "FromGitHub" then | ||
fetchFromGitHub { | ||
inherit (goDep.fetch) owner repo rev sha256; | ||
} | ||
else abort "Unrecognized package fetch type: ${goDep.fetch.type}"; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering we could not just accept file that is called with callPackage
.
The file would have all required fetchers in its header:
{ fetchgit, fetchhg }: {
"github.com/foo" = fetchgit { ... };
"somehost.com/foo" = fetchhg {};
}
Advantage is better extensibility. And we could replace/patch dependencies by its go path.
The patching could be even done with a global override file so it does not need to be done per package.
If we want to apply patches it might be with a global override file it might be beneficial to also have the version number/revision.
{ fetchgit, fetchhg }: [
{ path = "github.com/foo"; src = fetchgit { ... }; version = "1.0.0"; };
]
We could not just apply patches but also add extra build dependencies like pkg-config
or c libraries in a globally maintained override file:
{ sqlite, pkg-config }: {
"github.com/foo" = { version }: {
patches = lib.optional (lib.versionOlder version "0.9") [];
buildInputs = [ sqlite ];
nativeBuildInputs = [ pkg-config ];
};
}
This is similar to https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/ruby-modules/gem-config/default.nix#L63
As far as I can tell this works, but it appears the no goPackage has a valid deps file that works with go modules. I'm mostly putting this up so people can see how it works. I think the next step is a tool which correctly generate a deps.nix based on module information. (likely I'll add it to govendor form nix-community)
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)