From 27981ab4a2cd979ec9a973498ff83a2ef11422c9 Mon Sep 17 00:00:00 2001 From: niacdoial Date: Sun, 18 Sep 2022 15:47:30 +0200 Subject: [PATCH] Files: allow target to be the home directory, for recursively-linked directories In order to create assorted symlinks directly in the home directory, it might be necessary to have a `home.file` directive which targets the home directory directly. This is only allowed for recursively-linked directories, as even a simply-linked directory would cause the system to break (due to a readonly ~/.nix-profile, among others) --- modules/files.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index a7fd67f57..3edd1f964 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -343,8 +343,13 @@ in # We therefore simply log the conflict and otherwise ignore it, mainly # to make the `files-target-config` test work as expected. if [[ -e "$realOut/$relTarget" ]]; then - echo "File conflict for file '$relTarget'" >&2 - return + if [[ -d "$realOut/$relTarget" && $(realpath "$realOut/$relTarget") == $realOut && $recursive ]]; then + # exception: allow a "collision" for a recureively linked home *directory* + : + else + echo "File conflict for file '$relTarget'" >&2 + return + fi fi # Figure out the real absolute path to the target.