diff --git a/modules/files.nix b/modules/files.nix index 78554230..b8efd886 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -237,13 +237,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 9e0c04d2..49ad82a0 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -24,16 +24,21 @@ 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; }; } ++