From 1a89cfae1f0fa83238ffdabf4f06dd435bd45108 Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Thu, 25 May 2023 22:49:02 +0800 Subject: [PATCH] buildGoModule: simplify go-module attribute structure without rebuild --- pkgs/build-support/go/module.nix | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pkgs/build-support/go/module.nix b/pkgs/build-support/go/module.nix index 9bfb5858ad40..2b63d9e9f533 100644 --- a/pkgs/build-support/go/module.nix +++ b/pkgs/build-support/go/module.nix @@ -54,7 +54,8 @@ assert (args' ? vendorHash && args' ? vendorSha256) -> throw "both `vendorHash` let args = removeAttrs args' [ "overrideModAttrs" "vendorSha256" "vendorHash" ]; - go-modules = if (vendorHash != null) then stdenv.mkDerivation (let modArgs = { + go-modules = if (vendorHash == null) then "" else + (stdenv.mkDerivation { name = "${name}-go-modules"; @@ -138,13 +139,11 @@ let ''; dontFixup = true; - }; in modArgs // ( - { - outputHashMode = "recursive"; - outputHash = vendorHash; - outputHashAlgo = if args' ? vendorSha256 || vendorHash == "" then "sha256" else null; - } - ) // overrideModAttrs modArgs) else ""; + + outputHashMode = "recursive"; + outputHash = vendorHash; + outputHashAlgo = if args' ? vendorSha256 || vendorHash == "" then "sha256" else null; + }).overrideAttrs overrideModAttrs; package = stdenv.mkDerivation (args // { nativeBuildInputs = [ go ] ++ nativeBuildInputs;