nixpkgs/nixos/modules/system/etc/make-etc.sh

46 lines
1.1 KiB
Bash
Raw Normal View History

source $stdenv/setup
mkdir -p $out/etc
set -f
sources_=($sources)
targets_=($targets)
modes_=($modes)
users_=($users)
groups_=($groups)
set +f
for ((i = 0; i < ${#targets_[@]}; i++)); do
source="${sources_[$i]}"
target="${targets_[$i]}"
if [[ "$source" =~ '*' ]]; then
# If the source name contains '*', perform globbing.
mkdir -p $out/etc/$target
for fn in $source; do
ln -s "$fn" $out/etc/$target/
done
else
2020-08-08 01:54:16 +01:00
mkdir -p $out/etc/$(dirname $target)
if ! [ -e $out/etc/$target ]; then
ln -s $source $out/etc/$target
else
2012-10-05 02:44:45 +01:00
echo "duplicate entry $target -> $source"
if test "$(readlink $out/etc/$target)" != "$source"; then
2012-10-05 02:44:45 +01:00
echo "mismatched duplicate entry $(readlink $out/etc/$target) <-> $source"
exit 1
fi
fi
2020-08-08 01:54:16 +01:00
if test "${modes_[$i]}" != symlink; then
echo "${modes_[$i]}" > $out/etc/$target.mode
echo "${users_[$i]}" > $out/etc/$target.uid
echo "${groups_[$i]}" > $out/etc/$target.gid
fi
2020-08-08 01:54:16 +01:00
fi
done