buildGoModule: alias vendorSha256 to vendorHash#225371
buildGoModule: alias vendorSha256 to vendorHash#225371zowoq merged 1 commit intoNixOS:masterfrom qowoz:go-hash-cleanup
Conversation
|
cc @NixOS/golang @ajs124 |
pkgs/build-support/go/module.nix
Outdated
There was a problem hiding this comment.
| } // lib.optionalAttrs (args' ? vendorSha256 || vendorHash == "") { | |
| outputHashAlgo = "sha256"; | |
| outputHashAlgo = if args' ? vendorSha256 || vendorHash == "" then "sha256" else null; |
Passing null would make the structure simpler than using lib.optionalAttrs.
|
Maybe a dumb question, but what's the advantage of doing this over a blanket change to |
|
Yeah, to outright remove it is kind of a hassle and really needs to be done with a deprecation over a release cycle. |
|
@ShamrockLee I'd like to merge this first as it'll make the subsequent PRs simpler if we don't need to handle _unset and only need vendorSha256 in a couple of places. |
pkgs/build-support/go/module.nix
Outdated
There was a problem hiding this comment.
| , vendorHash ? args'.vendorSha256 | |
| , vendorHash ? args'.vendorSha256 or throw "buildGoModule: vendorHash is missing" |
The default error message would be "vendorSha256 is missing" without the or throw
nix-repl> pkgs.buildGoModule { src = pkgs.emptyDirectory; name = "empty"; }
error: attribute 'vendorSha256' missing
at /data/data/com.termux.nix/files/home/Projects/NixOS/nixpkgs/pkgs/build-support/go/module.nix:22:16:
21| # rely on the vendor folder within the source.
22| , vendorHash ? args'.vendorSha256
| ^
23| # Whether to delete the vendor folder supplied with the source.
«derivation
Other than that, LGTM!
pkgs/build-support/go/module.nix
Outdated
There was a problem hiding this comment.
Sorry for yet another question.
How would vendorHash == "" (meaning go-modules.outputHash == "") be legal for a fixed-output derivation? Is that condition obsolete?
There was a problem hiding this comment.
It isn't allowed in derivations, it's a convenience for generating the go-modules hash otherwise it errors with an empty hash:
error: empty hash requires explicit hash type
Currently:
warning: found empty hash, assuming 'sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='
these 2 derivations will be built:
/nix/store/f9lqyz4nlzg4smd3qz45dg1vkxk8qzi0-fzf-0.40.0-go-modules.drv
/nix/store/3lpry8y4535gdhbvf6y78na1qphf5857-fzf-0.40.0.drv
building '/nix/store/f9lqyz4nlzg4smd3qz45dg1vkxk8qzi0-fzf-0.40.0-go-modules.drv'...
unpacking sources
unpacking source archive /nix/store/ph5jpqrhd05y17b94ig0pq3574f7c9ay-source
source root is source
patching sources
configuring
building
go: downloading golang.org/x/sys v0.7.0
go: downloading github.com/mattn/go-isatty v0.0.17
go: downloading github.com/mattn/go-runewidth v0.0.14
go: downloading github.com/rivo/uniseg v0.4.4
go: downloading github.com/gdamore/tcell/v2 v2.5.4
go: downloading github.com/mattn/go-shellwords v1.0.12
go: downloading github.com/saracen/walker v0.1.3
go: downloading golang.org/x/term v0.7.0
go: downloading golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
go: downloading golang.org/x/text v0.5.0
go: downloading github.com/gdamore/encoding v1.0.0
go: downloading github.com/lucasb-eyer/go-colorful v1.2.0
installing
error: hash mismatch in fixed-output derivation '/nix/store/f9lqyz4nlzg4smd3qz45dg1vkxk8qzi0-fzf-0.40.0-go-modules.drv':
specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
got: sha256-SSz4oHUgfMRbvpdIl1xepfckef1HDA1y646FWnyBp6o=
error: 1 dependencies of derivation '/nix/store/3lpry8y4535gdhbvf6y78na1qphf5857-fzf-0.40.0.drv' failed to build
Does that answer your question or have I misunderstood what you were asking?
There was a problem hiding this comment.
I see. That makes sense.
Description of changes
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)