diff --git a/modules/files.nix b/modules/files.nix index 9efa0a9de..3c4a84b53 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -297,6 +297,7 @@ in local relTarget="$2" local executable="$3" local recursive="$4" + local ignorelinks="$5" # If the target already exists then we have a collision. Note, this # should not happen due to the assertion found in the 'files' module. @@ -321,7 +322,11 @@ in if [[ -d $source ]]; then if [[ $recursive ]]; then mkdir -p "$target" - lndir -silent "$source" "$target" + if [[ $ignorelinks ]]; then + lndir -silent -ignorelinks "$source" "$target" + else + lndir -silent "$source" "$target" + fi else ln -s "$source" "$target" fi @@ -357,6 +362,7 @@ in v.target (if v.executable == null then "inherit" else toString v.executable) (toString v.recursive) + (toString v.ignorelinks) ] } '') cfg diff --git a/modules/lib/file-type.nix b/modules/lib/file-type.nix index f877c31b2..96e714bb4 100644 --- a/modules/lib/file-type.nix +++ b/modules/lib/file-type.nix @@ -102,6 +102,18 @@ in ''; }; + ignorelinks = mkOption { + type = types.bool; + default = false; + description = '' + When `recursive` is enabled, adds `-ignorelinks` flag to lndir + + It causes lndir to not treat symbolic links in the source directory specially. + The link created in the target directory will point back to the corresponding + (symbolic link) file in the source directory. If the link is to a directory + ''; + }; + onChange = mkOption { type = types.lines; default = "";