From 9fbc2ee11f47810a58ce2c96ae51c2969f974fa1 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 12 Nov 2026 01:20:02 +0000 Subject: krops writeDeploy: pass --no-flake if /etc/nixos/flake.nix exists nixos-rebuild deploys /etc/nixos/flake.nix instead of NIX_PATH if that file exists, so deploying anything but a flake fails on such targets. Without writeDeploy's flake parameter, nixos-rebuild gets --no-flake if /etc/nixos/flake.nix exists on the build target. nixos-rebuild versions predating flakes neither know --no-flake nor look for that file, so they don't get it. The deploy VM test covers targets with and without that file. --- tests/scenarios.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests/scenarios.nix') diff --git a/tests/scenarios.nix b/tests/scenarios.nix index 429cff8..ce356b0 100644 --- a/tests/scenarios.nix +++ b/tests/scenarios.nix @@ -418,6 +418,7 @@ in { # writeDeploy's arguments to nixos-rebuild, which a stand-in records. deploy = matrix "deploy" { flake = [ false true ]; + etcFlake = [ false true ]; buildTarget = [ false true ]; } (flags: ctx: let target = targets.${ctx.targetKind} ctx.path; @@ -429,13 +430,21 @@ in { "--target-host" "${target.user}@${target.host}" ] ++ optional (flags.buildTarget && target.sudo) "--use-remote-sudo" - ++ optionals flags.flake [ "--flake" "${build.path}/x" ]; + ++ optionals flags.flake [ "--flake" "${build.path}/x" ] + ++ optional (flags.etcFlake && !flags.flake) "--no-flake"; in # The local target can't have another build target. if flags.buildTarget && ctx.targetKind == "local" then null else { node = if flags.buildTarget then "deployer" else null; + # Each scenario creates or removes /etc/nixos/flake.nix. prepare = '' rm -f /tmp/nixos-rebuild.log + ${if flags.etcFlake then '' + mkdir -p /etc/nixos + touch /etc/nixos/flake.nix + '' else '' + rm -f /etc/nixos/flake.nix + ''} ''; phases = twice { sources.x = -- cgit v1.3.1