mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 05:05:29 +03:00
nixos/systemd-initrd: Remove unit options that don't work
This commit is contained in:
parent
1e5261f31c
commit
b7c62b8238
4 changed files with 300 additions and 188 deletions
|
@ -273,9 +273,9 @@ in rec {
|
||||||
{ Conflicts = toString config.conflicts; }
|
{ Conflicts = toString config.conflicts; }
|
||||||
// optionalAttrs (config.requisite != [])
|
// optionalAttrs (config.requisite != [])
|
||||||
{ Requisite = toString config.requisite; }
|
{ Requisite = toString config.requisite; }
|
||||||
// optionalAttrs (config.restartTriggers != [])
|
// optionalAttrs (config ? restartTriggers && config.restartTriggers != [])
|
||||||
{ X-Restart-Triggers = toString config.restartTriggers; }
|
{ X-Restart-Triggers = toString config.restartTriggers; }
|
||||||
// optionalAttrs (config.reloadTriggers != [])
|
// optionalAttrs (config ? reloadTriggers && config.reloadTriggers != [])
|
||||||
{ X-Reload-Triggers = toString config.reloadTriggers; }
|
{ X-Reload-Triggers = toString config.reloadTriggers; }
|
||||||
// optionalAttrs (config.description != "") {
|
// optionalAttrs (config.description != "") {
|
||||||
Description = config.description; }
|
Description = config.description; }
|
||||||
|
@ -291,36 +291,8 @@ in rec {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
serviceConfig = { name, config, ... }: {
|
serviceConfig = { config, ... }: {
|
||||||
config = mkMerge
|
config.environment.PATH = mkIf (config.path != []) "${makeBinPath config.path}:${makeSearchPathOutput "bin" "sbin" config.path}";
|
||||||
[ {
|
|
||||||
environment.PATH = mkIf (config.path != []) "${makeBinPath config.path}:${makeSearchPathOutput "bin" "sbin" config.path}";
|
|
||||||
}
|
|
||||||
(mkIf (config ? preStart && config.preStart != "")
|
|
||||||
{ serviceConfig.ExecStartPre =
|
|
||||||
[ (makeJobScript "${name}-pre-start" config.preStart) ];
|
|
||||||
})
|
|
||||||
(mkIf (config ? script && config.script != "")
|
|
||||||
{ serviceConfig.ExecStart =
|
|
||||||
makeJobScript "${name}-start" config.script + " " + config.scriptArgs;
|
|
||||||
})
|
|
||||||
(mkIf (config ? postStart && config.postStart != "")
|
|
||||||
{ serviceConfig.ExecStartPost =
|
|
||||||
[ (makeJobScript "${name}-post-start" config.postStart) ];
|
|
||||||
})
|
|
||||||
(mkIf (config ? reload && config.reload != "")
|
|
||||||
{ serviceConfig.ExecReload =
|
|
||||||
makeJobScript "${name}-reload" config.reload;
|
|
||||||
})
|
|
||||||
(mkIf (config ? preStop && config.preStop != "")
|
|
||||||
{ serviceConfig.ExecStop =
|
|
||||||
makeJobScript "${name}-pre-stop" config.preStop;
|
|
||||||
})
|
|
||||||
(mkIf (config ? postStart && config.postStop != "")
|
|
||||||
{ serviceConfig.ExecStopPost =
|
|
||||||
makeJobScript "${name}-post-stop" config.postStop;
|
|
||||||
})
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
stage2ServiceConfig = {
|
stage2ServiceConfig = {
|
||||||
|
@ -384,12 +356,12 @@ in rec {
|
||||||
# systemd max line length is now 1MiB
|
# systemd max line length is now 1MiB
|
||||||
# https://github.com/systemd/systemd/commit/e6dde451a51dc5aaa7f4d98d39b8fe735f73d2af
|
# https://github.com/systemd/systemd/commit/e6dde451a51dc5aaa7f4d98d39b8fe735f73d2af
|
||||||
in if stringLength s >= 1048576 then throw "The value of the environment variable ‘${n}’ in systemd service ‘${name}.service’ is too long." else s) (attrNames env)}
|
in if stringLength s >= 1048576 then throw "The value of the environment variable ‘${n}’ in systemd service ‘${name}.service’ is too long." else s) (attrNames env)}
|
||||||
${if def.reloadIfChanged then ''
|
${if def ? reloadIfChanged && def.reloadIfChanged then ''
|
||||||
X-ReloadIfChanged=true
|
X-ReloadIfChanged=true
|
||||||
'' else if !def.restartIfChanged then ''
|
'' else if (def ? restartIfChanged && !def.restartIfChanged) then ''
|
||||||
X-RestartIfChanged=false
|
X-RestartIfChanged=false
|
||||||
'' else ""}
|
'' else ""}
|
||||||
${optionalString (!def.stopIfChanged) "X-StopIfChanged=false"}
|
${optionalString (def ? stopIfChanged && !def.stopIfChanged) "X-StopIfChanged=false"}
|
||||||
${attrsToSection def.serviceConfig}
|
${attrsToSection def.serviceConfig}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,20 +11,27 @@ rec {
|
||||||
config = { unit = mkDefault (systemdUtils.lib.makeUnit name config); };
|
config = { unit = mkDefault (systemdUtils.lib.makeUnit name config); };
|
||||||
}));
|
}));
|
||||||
|
|
||||||
services = with types; attrsOf (submodule [ { options = serviceOptions; } unitConfig stage2ServiceConfig ]);
|
services = with types; attrsOf (submodule [ stage2ServiceOptions unitConfig stage2ServiceConfig ]);
|
||||||
initrdServices = with types; attrsOf (submodule [ { options = serviceOptions; } unitConfig stage1ServiceConfig ]);
|
initrdServices = with types; attrsOf (submodule [ stage1ServiceOptions unitConfig stage1ServiceConfig ]);
|
||||||
|
|
||||||
targets = with types; attrsOf (submodule [ { options = targetOptions; } unitConfig ]);
|
targets = with types; attrsOf (submodule [ stage2CommonUnitOptions unitConfig ]);
|
||||||
|
initrdTargets = with types; attrsOf (submodule [ stage1CommonUnitOptions unitConfig ]);
|
||||||
|
|
||||||
sockets = with types; attrsOf (submodule [ { options = socketOptions; } unitConfig ]);
|
sockets = with types; attrsOf (submodule [ stage2SocketOptions unitConfig ]);
|
||||||
|
initrdSockets = with types; attrsOf (submodule [ stage1SocketOptions unitConfig ]);
|
||||||
|
|
||||||
timers = with types; attrsOf (submodule [ { options = timerOptions; } unitConfig ]);
|
timers = with types; attrsOf (submodule [ stage2TimerOptions unitConfig ]);
|
||||||
|
initrdTimers = with types; attrsOf (submodule [ stage1TimerOptions unitConfig ]);
|
||||||
|
|
||||||
paths = with types; attrsOf (submodule [ { options = pathOptions; } unitConfig ]);
|
paths = with types; attrsOf (submodule [ stage2PathOptions unitConfig ]);
|
||||||
|
initrdPaths = with types; attrsOf (submodule [ stage1PathOptions unitConfig ]);
|
||||||
|
|
||||||
slices = with types; attrsOf (submodule [ { options = sliceOptions; } unitConfig ]);
|
slices = with types; attrsOf (submodule [ stage2SliceOptions unitConfig ]);
|
||||||
|
initrdSlices = with types; attrsOf (submodule [ stage1SliceOptions unitConfig ]);
|
||||||
|
|
||||||
mounts = with types; listOf (submodule [ { options = mountOptions; } unitConfig mountConfig ]);
|
mounts = with types; listOf (submodule [ stage2MountOptions unitConfig mountConfig ]);
|
||||||
|
initrdMounts = with types; listOf (submodule [ stage1MountOptions unitConfig mountConfig ]);
|
||||||
|
|
||||||
automounts = with types; listOf (submodule [ { options = automountOptions; } unitConfig automountConfig ]);
|
automounts = with types; listOf (submodule [ stage2AutomountOptions unitConfig automountConfig ]);
|
||||||
|
initrdAutomounts = with types; attrsOf (submodule [ stage1AutomountOptions unitConfig automountConfig ]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ in rec {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
commonUnitOptions = sharedOptions // {
|
commonUnitOptions = { options = (sharedOptions // {
|
||||||
|
|
||||||
description = mkOption {
|
description = mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
|
@ -191,27 +191,6 @@ in rec {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
restartTriggers = mkOption {
|
|
||||||
default = [];
|
|
||||||
type = types.listOf types.unspecified;
|
|
||||||
description = ''
|
|
||||||
An arbitrary list of items such as derivations. If any item
|
|
||||||
in the list changes between reconfigurations, the service will
|
|
||||||
be restarted.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
reloadTriggers = mkOption {
|
|
||||||
default = [];
|
|
||||||
type = types.listOf unitOption;
|
|
||||||
description = ''
|
|
||||||
An arbitrary list of items such as derivations. If any item
|
|
||||||
in the list changes between reconfigurations, the service will
|
|
||||||
be reloaded. If anything but a reload trigger changes in the
|
|
||||||
unit file, the unit will be restarted instead.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
onFailure = mkOption {
|
onFailure = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = types.listOf unitNameType;
|
type = types.listOf unitNameType;
|
||||||
|
@ -239,10 +218,39 @@ in rec {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}); };
|
||||||
|
|
||||||
|
stage2CommonUnitOptions = {
|
||||||
|
imports = [
|
||||||
|
commonUnitOptions
|
||||||
|
];
|
||||||
|
|
||||||
|
options = {
|
||||||
|
restartTriggers = mkOption {
|
||||||
|
default = [];
|
||||||
|
type = types.listOf types.unspecified;
|
||||||
|
description = ''
|
||||||
|
An arbitrary list of items such as derivations. If any item
|
||||||
|
in the list changes between reconfigurations, the service will
|
||||||
|
be restarted.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
reloadTriggers = mkOption {
|
||||||
|
default = [];
|
||||||
|
type = types.listOf unitOption;
|
||||||
|
description = ''
|
||||||
|
An arbitrary list of items such as derivations. If any item
|
||||||
|
in the list changes between reconfigurations, the service will
|
||||||
|
be reloaded. If anything but a reload trigger changes in the
|
||||||
|
unit file, the unit will be restarted instead.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
stage1CommonUnitOptions = commonUnitOptions;
|
||||||
|
|
||||||
serviceOptions = commonUnitOptions // {
|
serviceOptions = { options = {
|
||||||
|
|
||||||
environment = mkOption {
|
environment = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
|
@ -276,6 +284,15 @@ in rec {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}; };
|
||||||
|
|
||||||
|
stage2ServiceOptions = { name, config, ... }: {
|
||||||
|
imports = [
|
||||||
|
stage2CommonUnitOptions
|
||||||
|
serviceOptions
|
||||||
|
];
|
||||||
|
|
||||||
|
options = {
|
||||||
script = mkOption {
|
script = mkOption {
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
default = "";
|
default = "";
|
||||||
|
@ -386,11 +403,45 @@ in rec {
|
||||||
'';
|
'';
|
||||||
apply = v: if isList v then v else [ v ];
|
apply = v: if isList v then v else [ v ];
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkMerge
|
||||||
|
[ (mkIf (config.preStart != "")
|
||||||
|
{ serviceConfig.ExecStartPre =
|
||||||
|
[ (makeJobScript "${name}-pre-start" config.preStart) ];
|
||||||
|
})
|
||||||
|
(mkIf (config.script != "")
|
||||||
|
{ serviceConfig.ExecStart =
|
||||||
|
makeJobScript "${name}-start" config.script + " " + config.scriptArgs;
|
||||||
|
})
|
||||||
|
(mkIf (config.postStart != "")
|
||||||
|
{ serviceConfig.ExecStartPost =
|
||||||
|
[ (makeJobScript "${name}-post-start" config.postStart) ];
|
||||||
|
})
|
||||||
|
(mkIf (config.reload != "")
|
||||||
|
{ serviceConfig.ExecReload =
|
||||||
|
makeJobScript "${name}-reload" config.reload;
|
||||||
|
})
|
||||||
|
(mkIf (config.preStop != "")
|
||||||
|
{ serviceConfig.ExecStop =
|
||||||
|
makeJobScript "${name}-pre-stop" config.preStop;
|
||||||
|
})
|
||||||
|
(mkIf (config.postStop != "")
|
||||||
|
{ serviceConfig.ExecStopPost =
|
||||||
|
makeJobScript "${name}-post-stop" config.postStop;
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
stage1ServiceOptions = {
|
||||||
|
imports = [
|
||||||
|
stage1CommonUnitOptions
|
||||||
|
serviceOptions
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
socketOptions = commonUnitOptions // {
|
socketOptions = { options = {
|
||||||
|
|
||||||
listenStreams = mkOption {
|
listenStreams = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
|
@ -424,10 +475,24 @@ in rec {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}; };
|
||||||
|
|
||||||
|
stage2SocketOptions = {
|
||||||
|
imports = [
|
||||||
|
stage2CommonUnitOptions
|
||||||
|
socketOptions
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
stage1SocketOptions = {
|
||||||
|
imports = [
|
||||||
|
stage1CommonUnitOptions
|
||||||
|
socketOptions
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
timerOptions = commonUnitOptions // {
|
timerOptions = { options = {
|
||||||
|
|
||||||
timerConfig = mkOption {
|
timerConfig = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
|
@ -443,10 +508,24 @@ in rec {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}; };
|
||||||
|
|
||||||
|
stage2TimerOptions = {
|
||||||
|
imports = [
|
||||||
|
stage2CommonUnitOptions
|
||||||
|
timerOptions
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
stage1TimerOptions = {
|
||||||
|
imports = [
|
||||||
|
stage1CommonUnitOptions
|
||||||
|
timerOptions
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
pathOptions = commonUnitOptions // {
|
pathOptions = { options = {
|
||||||
|
|
||||||
pathConfig = mkOption {
|
pathConfig = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
|
@ -460,10 +539,24 @@ in rec {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}; };
|
||||||
|
|
||||||
|
stage2PathOptions = {
|
||||||
|
imports = [
|
||||||
|
stage2CommonUnitOptions
|
||||||
|
pathOptions
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
stage1PathOptions = {
|
||||||
|
imports = [
|
||||||
|
stage1CommonUnitOptions
|
||||||
|
pathOptions
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
mountOptions = commonUnitOptions // {
|
mountOptions = { options = {
|
||||||
|
|
||||||
what = mkOption {
|
what = mkOption {
|
||||||
example = "/dev/sda1";
|
example = "/dev/sda1";
|
||||||
|
@ -505,9 +598,23 @@ in rec {
|
||||||
<manvolnum>5</manvolnum></citerefentry> for details.
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
}; };
|
||||||
|
|
||||||
|
stage2MountOptions = {
|
||||||
|
imports = [
|
||||||
|
stage2CommonUnitOptions
|
||||||
|
mountOptions
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
automountOptions = commonUnitOptions // {
|
stage1MountOptions = {
|
||||||
|
imports = [
|
||||||
|
stage1CommonUnitOptions
|
||||||
|
mountOptions
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
automountOptions = { options = {
|
||||||
|
|
||||||
where = mkOption {
|
where = mkOption {
|
||||||
example = "/mnt";
|
example = "/mnt";
|
||||||
|
@ -529,11 +636,23 @@ in rec {
|
||||||
<manvolnum>5</manvolnum></citerefentry> for details.
|
<manvolnum>5</manvolnum></citerefentry> for details.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
}; };
|
||||||
|
|
||||||
|
stage2AutomountOptions = {
|
||||||
|
imports = [
|
||||||
|
stage2CommonUnitOptions
|
||||||
|
automountOptions
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
targetOptions = commonUnitOptions;
|
stage1AutomountOptions = {
|
||||||
|
imports = [
|
||||||
|
stage1CommonUnitOptions
|
||||||
|
automountOptions
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
sliceOptions = commonUnitOptions // {
|
sliceOptions = { options = {
|
||||||
|
|
||||||
sliceConfig = mkOption {
|
sliceConfig = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
|
@ -547,6 +666,20 @@ in rec {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}; };
|
||||||
|
|
||||||
|
stage2SliceOptions = {
|
||||||
|
imports = [
|
||||||
|
stage2CommonUnitOptions
|
||||||
|
sliceOptions
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
stage1SliceOptions = {
|
||||||
|
imports = [
|
||||||
|
stage1CommonUnitOptions
|
||||||
|
sliceOptions
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,7 +231,7 @@ in {
|
||||||
targets = mkOption {
|
targets = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
visible = false;
|
visible = false;
|
||||||
type = systemdUtils.types.targets;
|
type = systemdUtils.types.initrdTargets;
|
||||||
description = "Definition of systemd target units.";
|
description = "Definition of systemd target units.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -244,28 +244,28 @@ in {
|
||||||
|
|
||||||
sockets = mkOption {
|
sockets = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
type = systemdUtils.types.sockets;
|
type = systemdUtils.types.initrdSockets;
|
||||||
visible = false;
|
visible = false;
|
||||||
description = "Definition of systemd socket units.";
|
description = "Definition of systemd socket units.";
|
||||||
};
|
};
|
||||||
|
|
||||||
timers = mkOption {
|
timers = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
type = systemdUtils.types.timers;
|
type = systemdUtils.types.initrdTimers;
|
||||||
visible = false;
|
visible = false;
|
||||||
description = "Definition of systemd timer units.";
|
description = "Definition of systemd timer units.";
|
||||||
};
|
};
|
||||||
|
|
||||||
paths = mkOption {
|
paths = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
type = systemdUtils.types.paths;
|
type = systemdUtils.types.initrdPaths;
|
||||||
visible = false;
|
visible = false;
|
||||||
description = "Definition of systemd path units.";
|
description = "Definition of systemd path units.";
|
||||||
};
|
};
|
||||||
|
|
||||||
mounts = mkOption {
|
mounts = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
type = systemdUtils.types.mounts;
|
type = systemdUtils.types.initrdMounts;
|
||||||
visible = false;
|
visible = false;
|
||||||
description = ''
|
description = ''
|
||||||
Definition of systemd mount units.
|
Definition of systemd mount units.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue