From 6ea379dbf3aad696f3aab3a145a877c4986e64e3 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 24 Nov 2026 04:52:13 +0000 Subject: populate symlink: replace a directory at the target path ln -f replaces files and links, but not directories, so a symlink source failed where a directory was, e.g. the Git work tree of a source that had another type: "cannot overwrite directory". The symlink script removes what isn't a link first, with remove_tree, which also copes with directories that aren't writable. --- pkgs/populate/tests/scenarios.nix | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'pkgs/populate/tests') diff --git a/pkgs/populate/tests/scenarios.nix b/pkgs/populate/tests/scenarios.nix index 33a2171..0c0ce9e 100644 --- a/pkgs/populate/tests/scenarios.nix +++ b/pkgs/populate/tests/scenarios.nix @@ -1096,6 +1096,28 @@ in } ]; })) + # A symlink source where a directory is, e.g. a source that had another + # type: ln -f doesn't replace directories. + (s "symlink-replaces-directory" { + phases = [ + { + sources.x.file = "/fixtures/alt"; + check = '' + test -d "$T"/x || fail "x isn't a directory" + ''; + } + { + sources = { + a.file = "/fixtures/alt"; + x.symlink = "a"; + }; + check = '' + expect_eq x "$(readlink "$T"/x)" a + test -e "$T"/x/flake.nix || fail "flake.nix missing" + ''; + } + ]; + }) (s "cycle" { phases = [{ sources = { -- cgit v1.3.1