diff options
author | Nikolay Amiantov <ab@fmap.me> | 2017-02-02 00:51:16 +0300 |
---|---|---|
committer | Nikolay Amiantov <ab@fmap.me> | 2017-02-02 00:52:54 +0300 |
commit | 8ef14f80e3d4d27644dec3d6d47152ae4b40ab07 (patch) | |
tree | 7faf81d7e39760ffb85a3c3ea8ca651903dbfe3c /nixos/modules | |
parent | dd934beb9fce6345097008c0316e18880b052129 (diff) | |
download | nixpkgs-8ef14f80e3d4d27644dec3d6d47152ae4b40ab07.tar nixpkgs-8ef14f80e3d4d27644dec3d6d47152ae4b40ab07.tar.gz nixpkgs-8ef14f80e3d4d27644dec3d6d47152ae4b40ab07.tar.bz2 nixpkgs-8ef14f80e3d4d27644dec3d6d47152ae4b40ab07.tar.lz nixpkgs-8ef14f80e3d4d27644dec3d6d47152ae4b40ab07.tar.xz nixpkgs-8ef14f80e3d4d27644dec3d6d47152ae4b40ab07.tar.zst nixpkgs-8ef14f80e3d4d27644dec3d6d47152ae4b40ab07.zip |
systemd service: add aliases option
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/system/boot/systemd-lib.nix | 8 | ||||
-rw-r--r-- | nixos/modules/system/boot/systemd-unit-options.nix | 6 | ||||
-rw-r--r-- | nixos/modules/system/boot/systemd.nix | 16 |
3 files changed, 21 insertions, 9 deletions
diff --git a/nixos/modules/system/boot/systemd-lib.nix b/nixos/modules/system/boot/systemd-lib.nix index 997770b8bec..7dbf3b25cdb 100644 --- a/nixos/modules/system/boot/systemd-lib.nix +++ b/nixos/modules/system/boot/systemd-lib.nix @@ -159,7 +159,13 @@ rec { fi done - # Created .wants and .requires symlinks from the wantedBy and + # Create service aliases from aliases option. + ${concatStrings (mapAttrsToList (name: unit: + concatMapStrings (name2: '' + ln -sfn '${name}' $out/'${name2}' + '') unit.aliases) units)} + + # Create .wants and .requires symlinks from the wantedBy and # requiredBy options. ${concatStrings (mapAttrsToList (name: unit: concatMapStrings (name2: '' diff --git a/nixos/modules/system/boot/systemd-unit-options.nix b/nixos/modules/system/boot/systemd-unit-options.nix index 69af2398148..904e41b019f 100644 --- a/nixos/modules/system/boot/systemd-unit-options.nix +++ b/nixos/modules/system/boot/systemd-unit-options.nix @@ -52,6 +52,12 @@ in rec { description = "Units that want (i.e. depend on) this unit."; }; + aliases = mkOption { + default = []; + type = types.listOf types.str; + description = "Aliases of that unit."; + }; + }; concreteUnitOptions = sharedOptions // { diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix index a2ee5166971..79779d3b42f 100644 --- a/nixos/modules/system/boot/systemd.nix +++ b/nixos/modules/system/boot/systemd.nix @@ -301,7 +301,7 @@ let ''; targetToUnit = name: def: - { inherit (def) wantedBy requiredBy enable; + { inherit (def) aliases wantedBy requiredBy enable; text = '' [Unit] @@ -310,7 +310,7 @@ let }; serviceToUnit = name: def: - { inherit (def) wantedBy requiredBy enable; + { inherit (def) aliases wantedBy requiredBy enable; text = commonUnitText def + '' [Service] @@ -330,7 +330,7 @@ let }; socketToUnit = name: def: - { inherit (def) wantedBy requiredBy enable; + { inherit (def) aliases wantedBy requiredBy enable; text = commonUnitText def + '' [Socket] @@ -340,7 +340,7 @@ let }; timerToUnit = name: def: - { inherit (def) wantedBy requiredBy enable; + { inherit (def) aliases wantedBy requiredBy enable; text = commonUnitText def + '' [Timer] @@ -349,7 +349,7 @@ let }; pathToUnit = name: def: - { inherit (def) wantedBy requiredBy enable; + { inherit (def) aliases wantedBy requiredBy enable; text = commonUnitText def + '' [Path] @@ -358,7 +358,7 @@ let }; mountToUnit = name: def: - { inherit (def) wantedBy requiredBy enable; + { inherit (def) aliases wantedBy requiredBy enable; text = commonUnitText def + '' [Mount] @@ -367,7 +367,7 @@ let }; automountToUnit = name: def: - { inherit (def) wantedBy requiredBy enable; + { inherit (def) aliases wantedBy requiredBy enable; text = commonUnitText def + '' [Automount] @@ -376,7 +376,7 @@ let }; sliceToUnit = name: def: - { inherit (def) wantedBy requiredBy enable; + { inherit (def) aliases wantedBy requiredBy enable; text = commonUnitText def + '' [Slice] |