Merge pull request #153035 from cherryblossom000/elvish-reproducible

elvish: properly set buildinfo via `ldflags`
This commit is contained in:
Anderson Torres 2022-01-03 11:28:26 -03:00 committed by GitHub
commit 0fbaa4132f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,4 @@
{ lib, buildGoModule, fetchFromGitHub }:
{ lib, buildGoModule, fetchFromGitHub, runCommand }:
buildGoModule rec {
pname = "elvish";
@ -6,7 +6,7 @@ buildGoModule rec {
subPackages = [ "cmd/elvish" ];
ldflags = [ "-s" "-w" "-X github.com/elves/elvish/pkg/buildinfo.Version==${version}" "-X github.com/elves/elvish/pkg/buildinfo.Reproducible=true" ];
ldflags = [ "-s" "-w" "-X src.elv.sh/pkg/buildinfo.Version==${version}" "-X src.elv.sh/pkg/buildinfo.Reproducible=true" ];
src = fetchFromGitHub {
owner = "elves";
@ -19,6 +19,25 @@ buildGoModule rec {
doCheck = false;
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
$out${passthru.shellPath} -c "
fn expect {|key expected|
var actual = \$buildinfo[\$key]
if (not-eq \$actual \$expected) {
fail '\$buildinfo['\$key']: expected '(to-string \$expected)', got '(to-string \$actual)
}
}
expect version ${version}
expect reproducible \$true
"
runHook postInstallCheck
'';
meta = with lib; {
description = "A friendly and expressive command shell";
longDescription = ''
@ -31,7 +50,5 @@ buildGoModule rec {
maintainers = with maintainers; [ vrthra AndersonTorres ];
};
passthru = {
shellPath = "/bin/elvish";
};
passthru.shellPath = "/bin/elvish";
}