From 5773043ac1445a0e9904d6618d337b32891db210 Mon Sep 17 00:00:00 2001 From: cherryblossom <31467609+cherryblossom000@users.noreply.github.com> Date: Sat, 1 Jan 2022 14:27:38 +1100 Subject: [PATCH 1/2] elvish: properly set buildinfo via `ldflags` As of [this commit][1] (v0.16.0), the module path of Elvish changed from `github.com/elves/elvish` to `src.elv.sh`. This is also reflected in the updated [packaging instructions][2]. This commit updates the `ldflags` in the derivation to use the new module path so that `buildinfo.Reproducible` is correctly set to `true`. [1]: https://github.com/elves/elvish/commit/196eea21d4f185d6ac203e7f9a4fa9a9c4d680f4 [2]: https://github.com/elves/elvish/blob/master/PACKAGING.md --- pkgs/shells/elvish/default.nix | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pkgs/shells/elvish/default.nix b/pkgs/shells/elvish/default.nix index e94354d68045..66d14b9b9ff5 100644 --- a/pkgs/shells/elvish/default.nix +++ b/pkgs/shells/elvish/default.nix @@ -1,4 +1,4 @@ -{ lib, buildGoModule, fetchFromGitHub }: +{ lib, buildGoModule, fetchFromGitHub, runCommand, elvish }: 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"; @@ -33,5 +33,20 @@ buildGoModule rec { passthru = { shellPath = "/bin/elvish"; + tests = runCommand "${pname}-buildinfo-test" {} '' + mkdir $out + + ${elvish}/bin/elvish -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 + " + ''; }; } From fae46e66a5df220327b45e0d7c27c6961cf922ce Mon Sep 17 00:00:00 2001 From: cherryblossom <31467609+cherryblossom000@users.noreply.github.com> Date: Tue, 4 Jan 2022 00:29:36 +1100 Subject: [PATCH 2/2] elvish: move test to `installCheckPhase` --- pkgs/shells/elvish/default.nix | 40 ++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/pkgs/shells/elvish/default.nix b/pkgs/shells/elvish/default.nix index 66d14b9b9ff5..ba03ffb4f455 100644 --- a/pkgs/shells/elvish/default.nix +++ b/pkgs/shells/elvish/default.nix @@ -1,4 +1,4 @@ -{ lib, buildGoModule, fetchFromGitHub, runCommand, elvish }: +{ lib, buildGoModule, fetchFromGitHub, runCommand }: buildGoModule rec { pname = "elvish"; @@ -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,22 +50,5 @@ buildGoModule rec { maintainers = with maintainers; [ vrthra AndersonTorres ]; }; - passthru = { - shellPath = "/bin/elvish"; - tests = runCommand "${pname}-buildinfo-test" {} '' - mkdir $out - - ${elvish}/bin/elvish -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 - " - ''; - }; + passthru.shellPath = "/bin/elvish"; }