about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorSergei Trofimovich <slyich@gmail.com>2023-12-29 21:45:14 +0000
committerzowoq <59103226+zowoq@users.noreply.github.com>2023-12-30 12:03:28 +1000
commita1422a7f8f12b68e307b92b7daa254f412e9ff96 (patch)
treede2c5f36e663a4bcb6d88dc3d94b60a19884004e /pkgs/build-support
parent7b4bde6b2b52c226fb56a21f42bb5ccd95457dac (diff)
downloadnixlib-a1422a7f8f12b68e307b92b7daa254f412e9ff96.tar
nixlib-a1422a7f8f12b68e307b92b7daa254f412e9ff96.tar.gz
nixlib-a1422a7f8f12b68e307b92b7daa254f412e9ff96.tar.bz2
nixlib-a1422a7f8f12b68e307b92b7daa254f412e9ff96.tar.lz
nixlib-a1422a7f8f12b68e307b92b7daa254f412e9ff96.tar.xz
nixlib-a1422a7f8f12b68e307b92b7daa254f412e9ff96.tar.zst
nixlib-a1422a7f8f12b68e307b92b7daa254f412e9ff96.zip
build-support/go: fix eval of `vendorSha256` accesses
Before the change there was no way to poll for presence of
`vendorSha256` attribute:

    $ nix-instantiate --strict --eval --expr 'with import ./. {}; _3mux.vendorSha256 or "no hash"'
       error: attribute 'vendorSha256' missing
          292|     passthru = passthru // { inherit go goModules vendorHash; } // { inherit (args') vendorSha256; };
             |                                                                     ^

After the change the poll happens as expected:

    $ nix-instantiate --strict --eval --expr 'with import ./. {}; _3mux.vendorSha256 or "no hash"'
    "no hash"
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/go/module.nix3
1 files changed, 2 insertions, 1 deletions
diff --git a/pkgs/build-support/go/module.nix b/pkgs/build-support/go/module.nix
index d0fd8928c91a..2fb59c634829 100644
--- a/pkgs/build-support/go/module.nix
+++ b/pkgs/build-support/go/module.nix
@@ -289,7 +289,8 @@ let
 
     disallowedReferences = lib.optional (!allowGoReference) go;
 
-    passthru = passthru // { inherit go goModules vendorHash; } // { inherit (args') vendorSha256; };
+    passthru = passthru // { inherit go goModules vendorHash; }
+                        // lib.optionalAttrs (args' ? vendorSha256 ) { inherit (args') vendorSha256; };
 
     meta = {
       # Add default meta information