systemd: remove platform assertion
Allow modules to define systemd services on macOS. It won't actually have any effect, but it would allow modules to define both systemd services and launchd agents without boilerplate conditionals. As a consequence of this change, each module would have to check for compatibility with the OS target instead.
This commit is contained in:
parent
17dc593930
commit
edb3645383
|
@ -10,16 +10,6 @@ let
|
||||||
mkPathSafeName =
|
mkPathSafeName =
|
||||||
lib.replaceStrings [ "@" ":" "\\" "[" "]" ] [ "-" "-" "-" "" "" ];
|
lib.replaceStrings [ "@" ":" "\\" "[" "]" ] [ "-" "-" "-" "" "" ];
|
||||||
|
|
||||||
enabled = cfg.services != { } # \
|
|
||||||
|| cfg.slices != { } # \
|
|
||||||
|| cfg.sockets != { } # \
|
|
||||||
|| cfg.targets != { } # \
|
|
||||||
|| cfg.timers != { } # \
|
|
||||||
|| cfg.paths != { } # \
|
|
||||||
|| cfg.mounts != { } # \
|
|
||||||
|| cfg.automounts != { } # \
|
|
||||||
|| cfg.sessionVariables != { };
|
|
||||||
|
|
||||||
toSystemdIni = lib.generators.toINI {
|
toSystemdIni = lib.generators.toINI {
|
||||||
listsAsDuplicateKeys = true;
|
listsAsDuplicateKeys = true;
|
||||||
mkKeyValue = key: value:
|
mkKeyValue = key: value:
|
||||||
|
@ -239,28 +229,10 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkMerge [
|
|
||||||
{
|
|
||||||
assertions = [{
|
|
||||||
assertion = enabled -> pkgs.stdenv.isLinux;
|
|
||||||
message = let
|
|
||||||
names = lib.concatStringsSep ", " (lib.attrNames ( # \
|
|
||||||
cfg.services # \
|
|
||||||
// cfg.slices # \
|
|
||||||
// cfg.sockets # \
|
|
||||||
// cfg.targets # \
|
|
||||||
// cfg.timers # \
|
|
||||||
// cfg.paths # \
|
|
||||||
// cfg.mounts # \
|
|
||||||
// cfg.sessionVariables));
|
|
||||||
in "Must use Linux for modules that require systemd: " + names;
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
|
|
||||||
# If we run under a Linux system we assume that systemd is
|
# If we run under a Linux system we assume that systemd is
|
||||||
# available, in particular we assume that systemctl is in PATH.
|
# available, in particular we assume that systemctl is in PATH.
|
||||||
# Do not install any user services if username is root.
|
# Do not install any user services if username is root.
|
||||||
(mkIf (pkgs.stdenv.isLinux && config.home.username != "root") {
|
config = mkIf (pkgs.stdenv.isLinux && config.home.username != "root") {
|
||||||
xdg.configFile = mkMerge [
|
xdg.configFile = mkMerge [
|
||||||
(lib.listToAttrs ((buildServices "service" cfg.services)
|
(lib.listToAttrs ((buildServices "service" cfg.services)
|
||||||
++ (buildServices "slice" cfg.slices)
|
++ (buildServices "slice" cfg.slices)
|
||||||
|
@ -278,8 +250,7 @@ in {
|
||||||
# running this from the NixOS module then XDG_RUNTIME_DIR is not
|
# running this from the NixOS module then XDG_RUNTIME_DIR is not
|
||||||
# set and systemd commands will fail. We'll therefore have to
|
# set and systemd commands will fail. We'll therefore have to
|
||||||
# set it ourselves in that case.
|
# set it ourselves in that case.
|
||||||
home.activation.reloadSystemd = hm.dag.entryAfter [ "linkGeneration" ]
|
home.activation.reloadSystemd = hm.dag.entryAfter [ "linkGeneration" ] (let
|
||||||
(let
|
|
||||||
cmd = {
|
cmd = {
|
||||||
suggest = ''
|
suggest = ''
|
||||||
PATH=${dirOf cfg.systemctlPath}:$PATH \
|
PATH=${dirOf cfg.systemctlPath}:$PATH \
|
||||||
|
@ -325,6 +296,5 @@ in {
|
||||||
|
|
||||||
unset systemdStatus
|
unset systemdStatus
|
||||||
'');
|
'');
|
||||||
})
|
};
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue