-
Notifications
You must be signed in to change notification settings - Fork 185
Open
Description
As with the Rust situation, gotest
fails in pre-commit drvs because it can't grab dependencies.
Workaround:
{ config, ... }:
let
deps = (pkgs.buildGoModule {
name = "go-deps";
src = config.rootSrc;
vendorHash = "...";
}).goModules;
goSetupHook = pkgs.makeSetupHook {
name = "go-setup-hook";
substitutions = {
shell = lib.getExe pkgs.bash;
inherit deps;
};
} (pkgs.writeScript "go-setup-hook.sh" ''
#!@shell@
goSetupPostUnpackHook() {
echo "copying go deps"
cp -r --reflink=auto @deps@ "$sourceRoot/vendor"
}
postUnpackHooks+=(goSetupPostUnpackHook)
'');
in
{
hooks.gotest.enable = true;
hooks.gotest.package = pkgs.go; # not strictly required, but good to keep the deps FOD Go ver in sync with this one
hooks.gotest.extraPackages = [ goSetupHook ];
We can easily fix it by just copying the Rust work around, but this does beg two larger questions worth pondering:
- Is there a better way to handle this in the hook module, generically? e.g. a
setupHooks
option that can propagate to the check drv, but does not propagate toenabledPackages
like above does. (Technically there's ways to makeenabledPackages
work now even in that case, but they're obviously not ideal.) - Should more test cases be added? 99% of the hooks here are not tested in CI, leading lots of pretty glaring bugs like this just lurking.
Happy to help with the implementation(s) of any of these points. :)
Metadata
Metadata
Assignees
Labels
No labels