0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

nixos/systemd: Handle template overrides

Adding template overrides allows for custom behavior for specific
instances of a template. Previously, it was not possible to provide
bind mounts for systemd-nspawn. This change allows it.
This commit is contained in:
Adrian Parvin D. Ouano 2021-03-09 23:04:58 +08:00
parent 102eb68cee
commit e3b90b6ccc
2 changed files with 53 additions and 1 deletions

View file

@ -182,7 +182,18 @@ in rec {
# upstream unit.
for i in ${toString (mapAttrsToList (n: v: v.unit) units)}; do
fn=$(basename $i/*)
if [ -e $out/$fn ]; then
case $fn in
# if file name is a template specialization, use the template's name
*@?*.service)
# remove @foo.service and replace it with @.service
ofn="''${fn%@*.service}@.service"
;;
*)
ofn="$fn"
esac
if [ -e $out/$ofn ]; then
if [ "$(readlink -f $i/$fn)" = /dev/null ]; then
ln -sfn /dev/null $out/$fn
else