buildGoModule: add goSum attribute to make goModules rebuild (#399532)
This commit is contained in:
parent
5b2a429966
commit
902d4f604f
@ -37,6 +37,9 @@ lib.extendMkDerivation {
|
|||||||
"buildGoModule: vendorHash is missing"
|
"buildGoModule: vendorHash is missing"
|
||||||
),
|
),
|
||||||
|
|
||||||
|
# The go.sum file to track which can cause rebuilds.
|
||||||
|
goSum ? null,
|
||||||
|
|
||||||
# Whether to delete the vendor folder supplied with the source.
|
# Whether to delete the vendor folder supplied with the source.
|
||||||
deleteVendor ? false,
|
deleteVendor ? false,
|
||||||
|
|
||||||
@ -69,13 +72,24 @@ lib.extendMkDerivation {
|
|||||||
vendorHash
|
vendorHash
|
||||||
deleteVendor
|
deleteVendor
|
||||||
proxyVendor
|
proxyVendor
|
||||||
|
goSum
|
||||||
;
|
;
|
||||||
goModules =
|
goModules =
|
||||||
if (finalAttrs.vendorHash == null) then
|
if (finalAttrs.vendorHash == null) then
|
||||||
""
|
""
|
||||||
else
|
else
|
||||||
(stdenv.mkDerivation {
|
(stdenv.mkDerivation {
|
||||||
name = "${finalAttrs.name or "${finalAttrs.pname}-${finalAttrs.version}"}-go-modules";
|
name =
|
||||||
|
let
|
||||||
|
prefix = "${finalAttrs.name or "${finalAttrs.pname}-${finalAttrs.version}"}-";
|
||||||
|
|
||||||
|
# If "goSum" is supplied then it can cause "goModules" to rebuild.
|
||||||
|
# Attach the hash name of the "go.sum" file so we can rebuild when it changes.
|
||||||
|
suffix = lib.optionalString (
|
||||||
|
finalAttrs.goSum != null
|
||||||
|
) "-${(lib.removeSuffix "-go.sum" (lib.removePrefix "${builtins.storeDir}/" finalAttrs.goSum))}";
|
||||||
|
in
|
||||||
|
"${prefix}go-modules${suffix}";
|
||||||
|
|
||||||
nativeBuildInputs = (finalAttrs.nativeBuildInputs or [ ]) ++ [
|
nativeBuildInputs = (finalAttrs.nativeBuildInputs or [ ]) ++ [
|
||||||
go
|
go
|
||||||
@ -83,7 +97,7 @@ lib.extendMkDerivation {
|
|||||||
cacert
|
cacert
|
||||||
];
|
];
|
||||||
|
|
||||||
inherit (finalAttrs) src modRoot;
|
inherit (finalAttrs) src modRoot goSum;
|
||||||
|
|
||||||
# The following inheritance behavior is not trivial to expect, and some may
|
# The following inheritance behavior is not trivial to expect, and some may
|
||||||
# argue it's not ideal. Changing it may break vendor hashes in Nixpkgs and
|
# argue it's not ideal. Changing it may break vendor hashes in Nixpkgs and
|
||||||
|
Loading…
x
Reference in New Issue
Block a user