diff options
author | Douglas Wilson <douglas.wilson@gmail.com> | 2019-02-19 07:10:04 +0000 |
---|---|---|
committer | Robert Helgesson <robert@rycee.net> | 2019-02-19 23:43:47 +0100 |
commit | 74811679b7f102a7e379e1f0f4160cc3c0643de6 (patch) | |
tree | ca61d4c929c5df6018e17fb5a3dff56ee09f14f1 /modules/systemd.nix | |
parent | 93f5fcae1e5c664050d3e75bd3cba5e6a6a95e53 (diff) |
systemd: sanitize unit derivation names
To allow a few special characters such as "@".
This is taken from
https://github.com/NixOS/nixpkgs/blob/c414e5bd080836376d3a0305535644423dc2cbbb/nixos/modules/system/boot/systemd-lib.nix#L14
Diffstat (limited to 'modules/systemd.nix')
-rw-r--r-- | modules/systemd.nix | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/systemd.nix b/modules/systemd.nix index ed630b3618a..f7325b41f1a 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -27,11 +27,17 @@ let buildService = style: name: serviceCfg: let filename = "${name}.${style}"; + pathSafeName = lib.replaceChars ["@" ":" "\\" "[" "]"] + ["-" "-" "-" "" "" ] + filename; # Needed because systemd derives unit names from the ultimate # link target. - source = pkgs.writeTextDir filename (toSystemdIni serviceCfg) - + "/" + filename; + source = pkgs.writeTextFile { + name = pathSafeName; + text = toSystemdIni serviceCfg; + destination = "/${filename}"; + } + "/${filename}"; wantedBy = target: { |