From 5471d2a454038aabf67d9d21d48cc63a9717f20c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 7 Nov 2024 20:43:17 +0100 Subject: [PATCH] Fix tests.remoteBuilds_local_nix_2_18 This was broken since a03bb4455cee010bbfcf7e322b10ec7e35123032 because Nix 2.18 does not support broken $SHELL settings. So don't try a broken $SHELL on old Nix versions. (It's a mystery though why tests.remoteBuilds_local_nix_2_13 and tests.remoteBuilds_local_nix_2_3 didn't fail...) https://hydra.nixos.org/build/277366807 --- tests/nixos/remote-builds.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/nixos/remote-builds.nix b/tests/nixos/remote-builds.nix index ab159eaad..84e5176b7 100644 --- a/tests/nixos/remote-builds.nix +++ b/tests/nixos/remote-builds.nix @@ -34,6 +34,8 @@ let } ''; + supportsBadShell = lib.versionAtLeast config.nodes.client.nix.package.version "2.25pre"; + in { @@ -82,7 +84,7 @@ in nix.settings.substituters = lib.mkForce [ ]; programs.ssh.extraConfig = "ConnectTimeout 30"; environment.systemPackages = [ - # `bad-shell` is used to make sure Nix works an environment with a misbehaving shell. + # `bad-shell` is used to make sure Nix works in an environment with a misbehaving shell. # # More realistically, a bad shell would still run the command ("echo started") # but considering that our solution is to avoid this shell (set via $SHELL), we @@ -125,13 +127,15 @@ in 'echo hello world on $(hostname)' >&2 """) + ${lib.optionalString supportsBadShell '' # Check that SSH uses SHELL for LocalCommand, as expected, and check that # our test setup here is working. The next test will use this bad SHELL. client.succeed(f"SHELL=$(which bad-shell) ssh -oLocalCommand='true' -oPermitLocalCommand=yes {builder1.name} 'echo hello world' | grep -F 'Hello, I am a broken shell'") + ''} # Perform a build and check that it was performed on the builder. out = client.succeed( - "SHELL=$(which bad-shell) nix-build ${expr nodes.client 1} 2> build-output", + "${lib.optionalString supportsBadShell "SHELL=$(which bad-shell)"} nix-build ${expr nodes.client 1} 2> build-output", "grep -q Hello build-output" ) builder1.succeed(f"test -e {out}")