mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
home-environment: fail if a home.file is outside $HOME
(cherry picked from commit 6ecf9e091c
)
This commit is contained in:
parent
c2ab3bc95c
commit
3c6453b32d
1 changed files with 10 additions and 2 deletions
|
@ -416,11 +416,19 @@ in
|
||||||
concatStringsSep "\n" (
|
concatStringsSep "\n" (
|
||||||
mapAttrsToList (n: v:
|
mapAttrsToList (n: v:
|
||||||
''
|
''
|
||||||
|
target="$(realpath -m "$out/${v.target}")"
|
||||||
|
|
||||||
|
# Target file must be within $HOME.
|
||||||
|
if [[ ! "$target" =~ "$out" ]] ; then
|
||||||
|
echo "Error installing file '${v.target}' outside \$HOME" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -d "${v.source}" ]; then
|
if [ -d "${v.source}" ]; then
|
||||||
mkdir -pv "$(dirname "$out/${v.target}")"
|
mkdir -pv "$(dirname "$out/${v.target}")"
|
||||||
ln -sv "${v.source}" "$out/${v.target}"
|
ln -sv "${v.source}" "$target"
|
||||||
else
|
else
|
||||||
install -D -m${v.mode} "${v.source}" "$out/${v.target}"
|
install -D -m${v.mode} "${v.source}" "$target"
|
||||||
fi
|
fi
|
||||||
''
|
''
|
||||||
) cfg.file
|
) cfg.file
|
||||||
|
|
Loading…
Reference in a new issue