From 1dd511bd6920b428dbd48f36ac646da8463fcbdd Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 12 Nov 2026 02:33:43 +0000 Subject: populate: replace symlinks before syncing with rsync rsync follows a symlink at the target path, so a source switching from the flake or flake-input type to file, pass, passage, or pipe got written into the store path the link points to, and one switching from the symlink type into what that link points to, e.g. another source. Populate removes a symlink at the target path before syncing with rsync. The roots in .populate/flake-inputs/ of a source that is neither a flake nor a flake-input source anymore get removed as well. An edge case switches a flake source to a file source. --- tests/scenarios.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/scenarios.nix') diff --git a/tests/scenarios.nix b/tests/scenarios.nix index a738eca..38f8736 100644 --- a/tests/scenarios.nix +++ b/tests/scenarios.nix @@ -808,6 +808,25 @@ assert !(krops.isLocalTarget (targets.remote "/")); check = checkFlake { attr = "msg"; expected = "rel:lib"; }; }; }) + (s "flake-to-file" { + phases = [ + { + sources.x.flake = { flake = "/fixtures/top"; inherit fetchOnTarget; }; + check = roots 3; + mutate = '' + readlink "$T"/x > "$T"/old + ''; + } + { + sources.x.file = "/fixtures/alt"; + check = '' + test ! -L "$T"/x || fail "x is still a link to $(readlink "$T"/x)" + test -e "$T"/x/flake.nix || fail "flake.nix missing" + nix-store --verify-path "$(cat "$T"/old)" || fail "store path changed" + '' + roots 0; + } + ]; + }) ] ++ lib.optional (targetKind == "local") # The target has the path the input is locked to. (s "uselocal" { -- cgit v1.3.1