mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 13:40:28 +03:00
systemd: add a name option to all systemd units
This allows us to set things like dependencies in a way that we can catch typos at eval time. So instead of ```nix systemd.services.foo.wants = [ "bar.service" ]; ``` we can write ```nix systemd.services.foo.wants = [ config.systemd.services.bar.name ]; ``` which will throw an error if no such service has been defined. Not all cases can be done like this (eg template services), but in a lot of cases this will allow to avoid typos. There is a matching option on the unit option (`systemd.units."foo.service".name`) as well.
This commit is contained in:
parent
b432281d97
commit
9258f57625
8 changed files with 124 additions and 63 deletions
|
@ -490,18 +490,18 @@ in {
|
|||
|
||||
targets.initrd.aliases = ["default.target"];
|
||||
units =
|
||||
mapAttrs' (n: v: nameValuePair "${n}.path" (pathToUnit n v)) cfg.paths
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.service" (serviceToUnit n v)) cfg.services
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.slice" (sliceToUnit n v)) cfg.slices
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.socket" (socketToUnit n v)) cfg.sockets
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.target" (targetToUnit n v)) cfg.targets
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.timer" (timerToUnit n v)) cfg.timers
|
||||
mapAttrs' (n: v: nameValuePair "${n}.path" (pathToUnit v)) cfg.paths
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.service" (serviceToUnit v)) cfg.services
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.slice" (sliceToUnit v)) cfg.slices
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.socket" (socketToUnit v)) cfg.sockets
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.target" (targetToUnit v)) cfg.targets
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.timer" (timerToUnit v)) cfg.timers
|
||||
// listToAttrs (map
|
||||
(v: let n = escapeSystemdPath v.where;
|
||||
in nameValuePair "${n}.mount" (mountToUnit n v)) cfg.mounts)
|
||||
in nameValuePair "${n}.mount" (mountToUnit v)) cfg.mounts)
|
||||
// listToAttrs (map
|
||||
(v: let n = escapeSystemdPath v.where;
|
||||
in nameValuePair "${n}.automount" (automountToUnit n v)) cfg.automounts);
|
||||
in nameValuePair "${n}.automount" (automountToUnit v)) cfg.automounts);
|
||||
|
||||
# make sure all the /dev nodes are set up
|
||||
services.systemd-tmpfiles-setup-dev.wantedBy = ["sysinit.target"];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue