fs: lift depends out of dir, to toplevel

This commit is contained in:
2023-01-04 04:32:20 +00:00
parent 68c2eb7363
commit 5533b586d7

View File

@@ -28,6 +28,14 @@ let
type = types.nullOr (symlinkEntryFor name);
default = null;
};
depends = mkOption {
type = types.listOf types.str;
description = ''
list of systemd units needed to be run before this directory can be made.
applies at the moment of dir or symlink creation.
'';
default = [];
};
unit = mkOption {
type = types.str;
description = "name of the systemd unit which ensures this entry";
@@ -39,7 +47,7 @@ let
dir.acl.mode = lib.mkDefault (parent-acl.mode or "0755");
# we put this here instead of as a `default` to ensure that users who specify additional
# dependencies still get a dep on the parent (unless they assign with `mkForce`).
dir.depends = if has-parent then [ parent-cfg.unit ] else [];
depends = if has-parent then [ parent-cfg.unit ] else [];
# if defaulted, this module is responsible for creating the directory
dir.unit = lib.mkDefault ((serviceNameFor name) + ".service");
@@ -62,11 +70,6 @@ let
acl = mkOption {
type = sane-types.acl;
};
depends = mkOption {
type = types.listOf types.str;
description = "list of systemd units needed to be run before this directory can be made";
default = [];
};
reverseDepends = mkOption {
type = types.listOf types.str;
description = "list of systemd units which should be made to depend on this unit (controls `wantedBy` and `before`)";
@@ -124,8 +127,8 @@ let
script = ensure-dir-script;
scriptArgs = "${path} ${opt.dir.acl.user} ${opt.dir.acl.group} ${opt.dir.acl.mode}";
after = opt.dir.depends;
wants = opt.dir.depends;
after = opt.depends;
wants = opt.depends;
# prevent systemd making this unit implicitly dependent on sysinit.target.
# see: <https://www.freedesktop.org/software/systemd/man/systemd.special.html>
unitConfig.DefaultDependencies = "no";
@@ -168,8 +171,8 @@ let
script = ensure-symlink-script;
scriptArgs = "${path} ${opt.target}";
after = opt.dir.depends;
wants = opt.dir.depends;
after = opt.depends;
wants = opt.depends;
# prevent systemd making this unit implicitly dependent on sysinit.target.
# see: <https://www.freedesktop.org/software/systemd/man/systemd.special.html>
unitConfig.DefaultDependencies = "no";