From 5c065e6e0e6625cfb493ddaf273bbfea0b3ccc3d Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Sat, 2 Dec 2017 22:52:35 +0100 Subject: [PATCH] systemd: remove filename hack --- modules/files.nix | 8 +------- modules/systemd.nix | 9 ++++++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index 08d226da..31137148 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -254,13 +254,7 @@ in # i.e., if the executable bit of the source is the same we # expect for the target. Otherwise, we copy the file and # set the executable bit to the expected value. - # - # Note, as a special case we always copy systemd units - # because it derives the unit name from the ultimate link - # target, which may be a store path with the hash - # included. - if [[ ($executable == inherit || $isExecutable == $executable) \ - && $relTarget != *"/systemd/user/"* ]]; then + if [[ $executable == inherit || $isExecutable == $executable ]]; then ln -s "$source" "$target" else cp "$source" "$target" diff --git a/modules/systemd.nix b/modules/systemd.nix index 778912a1..554f5201 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -24,16 +24,19 @@ let buildService = style: name: serviceCfg: let - source = pkgs.writeText "${name}.${style}" (toSystemdIni serviceCfg); + filename = "${name}.${style}"; + + # Needed because systemd derives unit names from the ultimate link target + source = "${pkgs.writeTextDir filename (toSystemdIni serviceCfg)}/${filename}"; wantedBy = target: { - name = "systemd/user/${target}.wants/${name}.${style}"; + name = "systemd/user/${target}.wants/${filename}"; value = { inherit source; }; }; in singleton { - name = "systemd/user/${name}.${style}"; + name = "systemd/user/${filename}"; value = { inherit source; }; } ++