mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +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
|
@ -35,7 +35,8 @@ let
|
|||
inherit (lib.strings) toJSON normalizePath escapeC;
|
||||
in
|
||||
|
||||
rec {
|
||||
let
|
||||
utils = rec {
|
||||
|
||||
# Copy configuration files to avoid having the entire sources in the system closure
|
||||
copyFile = filePath: pkgs.runCommand (builtins.unsafeDiscardStringContext (baseNameOf filePath)) {} ''
|
||||
|
@ -262,11 +263,12 @@ rec {
|
|||
filter (x: !(elem (getName x) namesToRemove)) packages;
|
||||
|
||||
systemdUtils = {
|
||||
lib = import ./systemd-lib.nix { inherit lib config pkgs; };
|
||||
lib = import ./systemd-lib.nix { inherit lib config pkgs utils; };
|
||||
unitOptions = import ./systemd-unit-options.nix { inherit lib systemdUtils; };
|
||||
types = import ./systemd-types.nix { inherit lib systemdUtils pkgs; };
|
||||
network = {
|
||||
units = import ./systemd-network-units.nix { inherit lib systemdUtils; };
|
||||
};
|
||||
};
|
||||
}
|
||||
};
|
||||
in utils
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue