New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
cosign: use buildFlagsArray #120034
cosign: use buildFlagsArray #120034
Conversation
Ah sorry, I had a look for the PR but I missed it 馃槄 |
And add myself as a maintainer
@@ -21,13 +21,15 @@ buildGoModule rec { | |||
|
|||
subPackages = [ "cmd/cosign" ]; | |||
|
|||
buildFlagsArray = [ "-ldflags=-s -w -X github.com/sigstore/cosign/cmd/cosign/cli.gitVersion=${version}" ]; | |||
preBuild = '' | |||
buildFlagsArray+=("-ldflags" "-s -w -X github.com/sigstore/cosign/cmd/cosign/cli.gitVersion=v${version}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a difference with buildFlagsArray
?
It seems the documentation recommends its usage:
nixpkgs/doc/languages-frameworks/go.section.md
Lines 115 to 132 in 80b3950
### `buildFlagsArray` and `buildFlags`: {#ex-goBuildFlags-noarray} | |
These attributes set build flags supported by `go build`. We recommend using `buildFlagsArray`. The most common use case of these attributes is to make the resulting executable aware of its own version. For example: | |
```nix | |
buildFlagsArray = [ | |
# Note: single quotes are not needed. | |
"-ldflags=-X main.Version=${version} -X main.Commit=${version}" | |
]; | |
``` | |
```nix | |
buildFlagsArray = '' | |
-ldflags= | |
-X main.Version=${version} | |
-X main.Commit=${version} | |
''; | |
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation, should not the Go documentation be updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It should be.
Motivation for this change
Bump cosign toBump already done, details below still apply to what was changed in #1200290.3.1
Add ldflags to make the release smaller (21 MB -> 19 MB) and version info
The upstream release looks like follows:
Left out the other parts that are commonly skipped in nixpkgs like date etc as they're better left as the default
Move the ldflags change to set buildArrayFlags directly within bash. I was going to link the linter that catches this & the reason behind this change but I can't find it now 馃檭 @SuperSandro2000 do you remember?
I've also added myself as a maintainer if you dont mind @LeSuisse
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)