files: update script to support linked Nix store

(cherry picked from commit b1dd373f5a)
This commit is contained in:
Anton Plotnikov 2019-11-22 12:54:29 +03:00 committed by Robert Helgesson
parent 06f1b13c21
commit 415f12bae5
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -236,6 +236,9 @@ in
(''
mkdir -p $out
# Needed in case /nix is a symbolic link.
realOut="$(realpath -m "$out")"
function insertFile() {
local source="$1"
local relTarget="$2"
@ -244,10 +247,10 @@ in
# Figure out the real absolute path to the target.
local target
target="$(realpath -m "$out/$relTarget")"
target="$(realpath -m "$realOut/$relTarget")"
# Target path must be within $HOME.
if [[ ! $target == $out* ]] ; then
if [[ ! $target == $realOut* ]] ; then
echo "Error installing file '$relTarget' outside \$HOME" >&2
exit 1
fi