Skip to content

Commit

Permalink
nixos/systemd-lib: fix conflict with dbus.service.d directory
Browse files Browse the repository at this point in the history
When a package contains a directory in one of the systemd directories
(like flatpak does), it is symlinked into the *-units derivation.
Then later, the derivation will try to create the directory, which
will fail:

mkdir: cannot create directory '/nix/store/…-user-units/dbus.service.d': File exists
builder for '/nix/store/…-user-units.drv' failed with exit code 1

Closes: #33233
  • Loading branch information
jtojnar committed May 15, 2018
1 parent e0a42d9 commit 17dd7bc
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions nixos/modules/system/boot/systemd-lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

with lib;

let cfg = config.systemd; in

rec {
let
cfg = config.systemd;
lndir = "${pkgs.xorg.lndir}/bin/lndir";
in rec {

shellEscape = s: (replaceChars [ "\\" ] [ "\\\\" ] s);

Expand Down Expand Up @@ -136,7 +137,13 @@ rec {
for i in ${toString cfg.packages}; do
for fn in $i/etc/systemd/${type}/* $i/lib/systemd/${type}/*; do
if ! [[ "$fn" =~ .wants$ ]]; then
ln -s $fn $out/
if [[ -d "$fn" ]]; then
targetDir="$out/$(basename "$fn")"
mkdir -p "$targetDir"
${lndir} "$fn" "$targetDir"
else
ln -s $fn $out/
fi
fi
done
done
Expand All @@ -151,7 +158,7 @@ rec {
if [ "$(readlink -f $i/$fn)" = /dev/null ]; then
ln -sfn /dev/null $out/$fn
else
mkdir $out/$fn.d
mkdir -p $out/$fn.d
ln -s $i/$fn $out/$fn.d/overrides.conf
fi
else
Expand Down

0 comments on commit 17dd7bc

Please sign in to comment.