2014-04-14 14:26:48 +00:00
|
|
|
|
{ config, lib, pkgs, utils, ... }:
|
2012-06-02 00:15:07 +00:00
|
|
|
|
|
2013-01-01 13:42:43 +00:00
|
|
|
|
with utils;
|
2021-11-20 17:34:13 +00:00
|
|
|
|
with systemdUtils.unitOptions;
|
2014-05-05 19:52:33 +00:00
|
|
|
|
with lib;
|
2012-06-02 00:15:07 +00:00
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
2013-01-16 11:33:18 +00:00
|
|
|
|
cfg = config.systemd;
|
2012-06-18 03:31:21 +00:00
|
|
|
|
|
2022-03-13 15:09:36 +00:00
|
|
|
|
inherit (systemdUtils.lib)
|
2022-03-13 15:11:28 +00:00
|
|
|
|
generateUnits
|
2022-03-13 15:09:36 +00:00
|
|
|
|
targetToUnit
|
|
|
|
|
serviceToUnit
|
|
|
|
|
socketToUnit
|
|
|
|
|
timerToUnit
|
|
|
|
|
pathToUnit
|
|
|
|
|
mountToUnit
|
|
|
|
|
automountToUnit
|
|
|
|
|
sliceToUnit;
|
|
|
|
|
|
2014-04-17 22:38:40 +00:00
|
|
|
|
upstreamSystemUnits =
|
2012-06-14 22:44:56 +00:00
|
|
|
|
[ # Targets.
|
2012-06-02 00:15:07 +00:00
|
|
|
|
"basic.target"
|
2013-01-08 16:26:51 +00:00
|
|
|
|
"sysinit.target"
|
2012-06-02 00:15:07 +00:00
|
|
|
|
"sockets.target"
|
2017-01-26 00:52:38 +00:00
|
|
|
|
"exit.target"
|
2012-06-14 22:44:56 +00:00
|
|
|
|
"graphical.target"
|
|
|
|
|
"multi-user.target"
|
|
|
|
|
"network.target"
|
2014-12-02 01:19:06 +00:00
|
|
|
|
"network-pre.target"
|
2013-07-16 09:55:12 +00:00
|
|
|
|
"network-online.target"
|
2012-06-14 22:44:56 +00:00
|
|
|
|
"nss-lookup.target"
|
|
|
|
|
"nss-user-lookup.target"
|
|
|
|
|
"time-sync.target"
|
2022-05-10 17:01:48 +00:00
|
|
|
|
] ++ optionals cfg.package.withCryptsetup [
|
2019-08-19 00:08:46 +00:00
|
|
|
|
"cryptsetup.target"
|
2021-10-22 13:01:55 +00:00
|
|
|
|
"cryptsetup-pre.target"
|
|
|
|
|
"remote-cryptsetup.target"
|
2022-05-10 17:01:48 +00:00
|
|
|
|
] ++ [
|
2012-08-14 22:14:48 +00:00
|
|
|
|
"sigpwr.target"
|
2013-03-27 12:58:12 +00:00
|
|
|
|
"timers.target"
|
|
|
|
|
"paths.target"
|
2014-04-15 22:59:26 +00:00
|
|
|
|
"rpcbind.target"
|
2012-06-14 22:44:56 +00:00
|
|
|
|
|
2013-01-21 20:01:48 +00:00
|
|
|
|
# Rescue mode.
|
2013-01-08 17:24:06 +00:00
|
|
|
|
"rescue.target"
|
|
|
|
|
"rescue.service"
|
|
|
|
|
|
2024-03-28 09:50:01 +00:00
|
|
|
|
# systemd-debug-generator
|
|
|
|
|
"debug-shell.service"
|
|
|
|
|
|
2012-06-15 17:09:22 +00:00
|
|
|
|
# Udev.
|
2023-08-22 02:14:36 +00:00
|
|
|
|
"systemd-tmpfiles-setup-dev-early.service"
|
2012-07-16 21:47:11 +00:00
|
|
|
|
"systemd-udevd-control.socket"
|
|
|
|
|
"systemd-udevd-kernel.socket"
|
2014-04-17 16:52:31 +00:00
|
|
|
|
"systemd-udevd.service"
|
2012-06-15 17:09:22 +00:00
|
|
|
|
"systemd-udev-settle.service"
|
2023-09-28 16:11:41 +00:00
|
|
|
|
] ++ (optional (!config.boot.isContainer) "systemd-udev-trigger.service") ++ [
|
2017-02-08 18:42:07 +00:00
|
|
|
|
# hwdb.bin is managed by NixOS
|
|
|
|
|
# "systemd-hwdb-update.service"
|
2012-06-15 17:09:22 +00:00
|
|
|
|
|
2014-04-17 16:52:31 +00:00
|
|
|
|
# Consoles.
|
|
|
|
|
"getty.target"
|
2018-02-11 22:43:24 +00:00
|
|
|
|
"getty-pre.target"
|
2014-04-17 16:52:31 +00:00
|
|
|
|
"getty@.service"
|
|
|
|
|
"serial-getty@.service"
|
2017-01-26 00:52:38 +00:00
|
|
|
|
"console-getty.service"
|
2014-04-17 16:52:31 +00:00
|
|
|
|
"container-getty@.service"
|
|
|
|
|
"systemd-vconsole-setup.service"
|
|
|
|
|
|
2012-08-14 22:14:48 +00:00
|
|
|
|
# Hardware (started by udev when a relevant device is plugged in).
|
|
|
|
|
"sound.target"
|
|
|
|
|
"bluetooth.target"
|
|
|
|
|
"printer.target"
|
|
|
|
|
"smartcard.target"
|
|
|
|
|
|
2012-08-06 20:52:08 +00:00
|
|
|
|
# Kernel module loading.
|
2014-04-17 16:52:31 +00:00
|
|
|
|
"systemd-modules-load.service"
|
|
|
|
|
"kmod-static-nodes.service"
|
2021-03-04 20:05:16 +00:00
|
|
|
|
"modprobe@.service"
|
2012-08-06 20:52:08 +00:00
|
|
|
|
|
2012-06-02 00:15:07 +00:00
|
|
|
|
# Filesystems.
|
2012-07-16 21:47:11 +00:00
|
|
|
|
"systemd-fsck@.service"
|
|
|
|
|
"systemd-fsck-root.service"
|
2023-03-05 19:05:00 +00:00
|
|
|
|
"systemd-growfs@.service"
|
|
|
|
|
"systemd-growfs-root.service"
|
2012-06-14 22:44:56 +00:00
|
|
|
|
"systemd-remount-fs.service"
|
2020-12-01 23:54:35 +00:00
|
|
|
|
"systemd-pstore.service"
|
2012-06-02 00:15:07 +00:00
|
|
|
|
"local-fs.target"
|
|
|
|
|
"local-fs-pre.target"
|
|
|
|
|
"remote-fs.target"
|
|
|
|
|
"remote-fs-pre.target"
|
|
|
|
|
"swap.target"
|
2012-06-14 22:44:56 +00:00
|
|
|
|
"dev-hugepages.mount"
|
2012-06-02 00:15:07 +00:00
|
|
|
|
"dev-mqueue.mount"
|
2014-04-28 07:13:57 +00:00
|
|
|
|
"sys-fs-fuse-connections.mount"
|
2020-08-06 02:12:57 +00:00
|
|
|
|
] ++ (optional (!config.boot.isContainer) "sys-kernel-config.mount") ++ [
|
2012-06-14 22:44:56 +00:00
|
|
|
|
"sys-kernel-debug.mount"
|
|
|
|
|
|
2014-04-15 22:59:26 +00:00
|
|
|
|
# Maintaining state across reboots.
|
|
|
|
|
"systemd-random-seed.service"
|
2024-03-06 10:08:48 +00:00
|
|
|
|
] ++ (optional cfg.package.withBootloader "systemd-boot-random-seed.service") ++ [
|
2014-04-18 17:37:15 +00:00
|
|
|
|
"systemd-backlight@.service"
|
2015-10-07 19:48:30 +00:00
|
|
|
|
"systemd-rfkill.service"
|
2017-01-26 00:52:38 +00:00
|
|
|
|
"systemd-rfkill.socket"
|
2014-04-15 22:59:26 +00:00
|
|
|
|
|
2012-06-14 22:44:56 +00:00
|
|
|
|
# Hibernate / suspend.
|
|
|
|
|
"hibernate.target"
|
|
|
|
|
"suspend.target"
|
2019-08-26 09:04:10 +00:00
|
|
|
|
"suspend-then-hibernate.target"
|
2012-06-14 22:44:56 +00:00
|
|
|
|
"sleep.target"
|
2013-03-27 12:58:12 +00:00
|
|
|
|
"hybrid-sleep.target"
|
2012-07-20 19:40:50 +00:00
|
|
|
|
"systemd-hibernate.service"
|
2013-03-27 12:58:12 +00:00
|
|
|
|
"systemd-hybrid-sleep.service"
|
2017-01-26 00:52:38 +00:00
|
|
|
|
"systemd-suspend.service"
|
2019-08-26 09:04:10 +00:00
|
|
|
|
"systemd-suspend-then-hibernate.service"
|
2012-06-02 00:15:07 +00:00
|
|
|
|
|
|
|
|
|
# Reboot stuff.
|
|
|
|
|
"reboot.target"
|
2012-07-16 21:47:11 +00:00
|
|
|
|
"systemd-reboot.service"
|
2012-06-02 00:15:07 +00:00
|
|
|
|
"poweroff.target"
|
2012-07-16 21:47:11 +00:00
|
|
|
|
"systemd-poweroff.service"
|
2012-06-02 00:15:07 +00:00
|
|
|
|
"halt.target"
|
2012-07-16 21:47:11 +00:00
|
|
|
|
"systemd-halt.service"
|
2012-06-02 00:15:07 +00:00
|
|
|
|
"shutdown.target"
|
|
|
|
|
"umount.target"
|
|
|
|
|
"final.target"
|
2012-08-14 22:14:48 +00:00
|
|
|
|
"kexec.target"
|
2013-09-16 15:15:42 +00:00
|
|
|
|
"systemd-kexec.service"
|
2022-09-19 11:45:01 +00:00
|
|
|
|
] ++ lib.optional cfg.package.withUtmp "systemd-update-utmp.service" ++ [
|
2012-06-14 22:44:56 +00:00
|
|
|
|
|
2012-06-19 21:02:54 +00:00
|
|
|
|
# Password entry.
|
|
|
|
|
"systemd-ask-password-console.path"
|
|
|
|
|
"systemd-ask-password-console.service"
|
|
|
|
|
"systemd-ask-password-wall.path"
|
|
|
|
|
"systemd-ask-password-wall.service"
|
2014-04-15 22:59:26 +00:00
|
|
|
|
|
|
|
|
|
# Slices / containers.
|
|
|
|
|
"slices.target"
|
2022-05-10 17:01:48 +00:00
|
|
|
|
] ++ optionals cfg.package.withImportd [
|
|
|
|
|
"systemd-importd.service"
|
|
|
|
|
] ++ optionals cfg.package.withMachined [
|
2014-04-15 22:59:26 +00:00
|
|
|
|
"machine.slice"
|
2017-01-26 00:52:38 +00:00
|
|
|
|
"machines.target"
|
2014-04-15 22:59:26 +00:00
|
|
|
|
"systemd-machined.service"
|
2022-05-10 17:01:48 +00:00
|
|
|
|
] ++ [
|
2016-06-09 13:45:55 +00:00
|
|
|
|
"systemd-nspawn@.service"
|
2014-04-17 11:23:06 +00:00
|
|
|
|
|
2014-04-17 16:52:31 +00:00
|
|
|
|
# Misc.
|
|
|
|
|
"systemd-sysctl.service"
|
2022-05-10 17:01:48 +00:00
|
|
|
|
] ++ optionals cfg.package.withTimedated [
|
2015-12-06 13:30:18 +00:00
|
|
|
|
"dbus-org.freedesktop.timedate1.service"
|
|
|
|
|
"systemd-timedated.service"
|
2022-05-10 17:01:48 +00:00
|
|
|
|
] ++ optionals cfg.package.withLocaled [
|
|
|
|
|
"dbus-org.freedesktop.locale1.service"
|
2015-12-06 13:30:18 +00:00
|
|
|
|
"systemd-localed.service"
|
2022-05-10 17:01:48 +00:00
|
|
|
|
] ++ optionals cfg.package.withHostnamed [
|
|
|
|
|
"dbus-org.freedesktop.hostname1.service"
|
2015-12-06 13:30:18 +00:00
|
|
|
|
"systemd-hostnamed.service"
|
2022-09-29 10:36:05 +00:00
|
|
|
|
] ++ optionals cfg.package.withPortabled [
|
|
|
|
|
"dbus-org.freedesktop.portable1.service"
|
|
|
|
|
"systemd-portabled.service"
|
2022-05-10 17:01:48 +00:00
|
|
|
|
] ++ [
|
2017-01-26 00:52:38 +00:00
|
|
|
|
"systemd-exit.service"
|
2018-02-11 22:43:24 +00:00
|
|
|
|
"systemd-update-done.service"
|
2018-05-26 23:49:08 +00:00
|
|
|
|
] ++ cfg.additionalUpstreamSystemUnits;
|
2012-06-02 00:15:07 +00:00
|
|
|
|
|
2014-04-17 22:38:40 +00:00
|
|
|
|
upstreamSystemWants =
|
2017-01-26 00:52:38 +00:00
|
|
|
|
[ "sysinit.target.wants"
|
2012-06-14 22:44:56 +00:00
|
|
|
|
"sockets.target.wants"
|
|
|
|
|
"local-fs.target.wants"
|
|
|
|
|
"multi-user.target.wants"
|
2013-03-27 12:58:12 +00:00
|
|
|
|
"timers.target.wants"
|
2012-06-14 22:44:56 +00:00
|
|
|
|
];
|
|
|
|
|
|
2019-12-11 08:34:35 +00:00
|
|
|
|
proxy_env = config.networking.proxy.envVars;
|
|
|
|
|
|
2012-06-02 00:15:07 +00:00
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
{
|
2012-06-14 22:44:56 +00:00
|
|
|
|
###### interface
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
options.systemd = {
|
2012-06-14 22:44:56 +00:00
|
|
|
|
|
2023-11-21 16:27:57 +00:00
|
|
|
|
package = mkPackageOption pkgs "systemd" {};
|
2013-01-16 12:17:57 +00:00
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
units = mkOption {
|
2023-11-21 17:10:23 +00:00
|
|
|
|
description = "Definition of systemd units; see {manpage}`systemd.unit(5)`.";
|
2012-06-18 03:31:21 +00:00
|
|
|
|
default = {};
|
2022-03-19 08:02:39 +00:00
|
|
|
|
type = systemdUtils.types.units;
|
2012-06-18 19:28:31 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
packages = mkOption {
|
2012-08-21 15:28:47 +00:00
|
|
|
|
default = [];
|
|
|
|
|
type = types.listOf types.package;
|
2021-10-03 16:06:03 +00:00
|
|
|
|
example = literalExpression "[ pkgs.systemd-cryptsetup-generator ]";
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = "Packages providing systemd units and hooks.";
|
2012-08-21 15:28:47 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
targets = mkOption {
|
2012-10-01 22:58:11 +00:00
|
|
|
|
default = {};
|
2022-03-19 08:02:39 +00:00
|
|
|
|
type = systemdUtils.types.targets;
|
2023-11-21 17:10:23 +00:00
|
|
|
|
description = "Definition of systemd target units; see {manpage}`systemd.target(5)`";
|
2012-10-01 22:58:11 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
services = mkOption {
|
2012-06-18 19:28:31 +00:00
|
|
|
|
default = {};
|
2022-03-19 08:02:39 +00:00
|
|
|
|
type = systemdUtils.types.services;
|
2023-11-21 17:10:23 +00:00
|
|
|
|
description = "Definition of systemd service units; see {manpage}`systemd.service(5)`.";
|
2012-10-01 22:58:11 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
sockets = mkOption {
|
2012-10-01 22:58:11 +00:00
|
|
|
|
default = {};
|
2022-03-19 08:02:39 +00:00
|
|
|
|
type = systemdUtils.types.sockets;
|
2023-11-21 17:10:23 +00:00
|
|
|
|
description = "Definition of systemd socket units; see {manpage}`systemd.socket(5)`.";
|
2012-06-14 22:44:56 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
timers = mkOption {
|
2013-03-02 00:03:13 +00:00
|
|
|
|
default = {};
|
2022-03-19 08:02:39 +00:00
|
|
|
|
type = systemdUtils.types.timers;
|
2023-11-21 17:10:23 +00:00
|
|
|
|
description = "Definition of systemd timer units; see {manpage}`systemd.timer(5)`.";
|
2013-03-02 00:03:13 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
paths = mkOption {
|
2014-03-31 10:23:27 +00:00
|
|
|
|
default = {};
|
2022-03-19 08:02:39 +00:00
|
|
|
|
type = systemdUtils.types.paths;
|
2023-11-21 17:10:23 +00:00
|
|
|
|
description = "Definition of systemd path units; see {manpage}`systemd.path(5)`.";
|
2014-03-31 10:23:27 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
mounts = mkOption {
|
2012-12-28 12:29:53 +00:00
|
|
|
|
default = [];
|
2022-03-19 08:02:39 +00:00
|
|
|
|
type = systemdUtils.types.mounts;
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = ''
|
2023-11-21 17:10:23 +00:00
|
|
|
|
Definition of systemd mount units; see {manpage}`systemd.mount(5)`.
|
2023-11-21 17:11:01 +00:00
|
|
|
|
|
|
|
|
|
This is a list instead of an attrSet, because systemd mandates
|
|
|
|
|
the names to be derived from the `where` attribute.
|
2012-12-28 12:29:53 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
automounts = mkOption {
|
2013-09-23 20:56:05 +00:00
|
|
|
|
default = [];
|
2022-03-19 08:02:39 +00:00
|
|
|
|
type = systemdUtils.types.automounts;
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = ''
|
2023-11-21 17:10:23 +00:00
|
|
|
|
Definition of systemd automount units; see {manpage}`systemd.automount(5)`.
|
|
|
|
|
|
|
|
|
|
This is a list instead of an attrSet, because systemd mandates
|
|
|
|
|
the names to be derived from the `where` attribute.
|
2013-09-23 20:56:05 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
slices = mkOption {
|
2016-12-20 06:21:52 +00:00
|
|
|
|
default = {};
|
2022-03-19 08:02:39 +00:00
|
|
|
|
type = systemdUtils.types.slices;
|
2023-11-21 17:10:23 +00:00
|
|
|
|
description = "Definition of slice configurations; see {manpage}`systemd.slice(5)`.";
|
2016-12-20 06:21:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
generators = mkOption {
|
2015-09-26 16:34:36 +00:00
|
|
|
|
type = types.attrsOf types.path;
|
|
|
|
|
default = {};
|
2019-08-13 21:52:01 +00:00
|
|
|
|
example = { systemd-gpt-auto-generator = "/dev/null"; };
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = ''
|
2023-11-21 17:10:23 +00:00
|
|
|
|
Definition of systemd generators; see {manpage}`systemd.generator(5)`.
|
|
|
|
|
|
2022-07-20 10:32:04 +00:00
|
|
|
|
For each `NAME = VALUE` pair of the attrSet, a link is generated from
|
|
|
|
|
`/etc/systemd/system-generators/NAME` to `VALUE`.
|
2015-09-26 16:34:36 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
shutdown = mkOption {
|
2019-07-25 13:27:28 +00:00
|
|
|
|
type = types.attrsOf types.path;
|
|
|
|
|
default = {};
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = ''
|
2019-07-25 13:27:28 +00:00
|
|
|
|
Definition of systemd shutdown executables.
|
2022-07-20 10:32:04 +00:00
|
|
|
|
For each `NAME = VALUE` pair of the attrSet, a link is generated from
|
|
|
|
|
`/etc/systemd/system-shutdown/NAME` to `VALUE`.
|
2019-07-25 13:27:28 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
defaultUnit = mkOption {
|
2012-06-18 03:31:21 +00:00
|
|
|
|
default = "multi-user.target";
|
2013-10-30 10:02:04 +00:00
|
|
|
|
type = types.str;
|
2023-11-21 17:10:23 +00:00
|
|
|
|
description = ''
|
|
|
|
|
Default unit started when the system boots; see {manpage}`systemd.special(7)`.
|
|
|
|
|
'';
|
2012-06-18 03:31:21 +00:00
|
|
|
|
};
|
2012-07-19 21:32:50 +00:00
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
ctrlAltDelUnit = mkOption {
|
2016-07-19 07:42:53 +00:00
|
|
|
|
default = "reboot.target";
|
|
|
|
|
type = types.str;
|
|
|
|
|
example = "poweroff.target";
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = ''
|
2023-11-21 17:10:23 +00:00
|
|
|
|
Target that should be started when Ctrl-Alt-Delete is pressed;
|
|
|
|
|
see {manpage}`systemd.special(7)`.
|
2016-07-19 07:42:53 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
globalEnvironment = mkOption {
|
2019-08-08 21:35:52 +00:00
|
|
|
|
type = with types; attrsOf (nullOr (oneOf [ str path package ]));
|
2012-10-30 16:27:14 +00:00
|
|
|
|
default = {};
|
|
|
|
|
example = { TZ = "CET"; };
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = ''
|
2022-07-20 10:32:04 +00:00
|
|
|
|
Environment variables passed to *all* systemd units.
|
2012-10-30 16:27:14 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
managerEnvironment = mkOption {
|
2022-03-23 14:56:23 +00:00
|
|
|
|
type = with types; attrsOf (nullOr (oneOf [ str path package ]));
|
|
|
|
|
default = {};
|
|
|
|
|
example = { SYSTEMD_LOG_LEVEL = "debug"; };
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = ''
|
2022-03-23 14:56:23 +00:00
|
|
|
|
Environment variables of PID 1. These variables are
|
2022-07-20 10:32:04 +00:00
|
|
|
|
*not* passed to started units.
|
2022-03-23 14:56:23 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
enableCgroupAccounting = mkOption {
|
2019-08-19 15:50:29 +00:00
|
|
|
|
default = true;
|
2018-03-10 21:23:42 +00:00
|
|
|
|
type = types.bool;
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = ''
|
2023-11-21 17:10:23 +00:00
|
|
|
|
Whether to enable cgroup accounting; see {manpage}`cgroups(7)`.
|
2018-03-10 21:23:42 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
enableUnifiedCgroupHierarchy = mkOption {
|
2020-11-17 20:54:26 +00:00
|
|
|
|
default = true;
|
|
|
|
|
type = types.bool;
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = ''
|
2023-11-21 17:10:23 +00:00
|
|
|
|
Whether to enable the unified cgroup hierarchy (cgroupsv2); see {manpage}`cgroups(7)`.
|
2020-11-17 20:54:26 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
extraConfig = mkOption {
|
2013-11-15 18:49:01 +00:00
|
|
|
|
default = "";
|
|
|
|
|
type = types.lines;
|
|
|
|
|
example = "DefaultLimitCORE=infinity";
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = ''
|
2023-11-21 17:10:23 +00:00
|
|
|
|
Extra config options for systemd. See {manpage}`systemd-system.conf(5)` man page
|
2022-10-03 03:10:46 +00:00
|
|
|
|
for available options.
|
2013-11-15 18:49:01 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
sleep.extraConfig = mkOption {
|
2020-02-03 16:31:46 +00:00
|
|
|
|
default = "";
|
|
|
|
|
type = types.lines;
|
|
|
|
|
example = "HibernateDelaySec=1h";
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = ''
|
2020-02-03 16:31:46 +00:00
|
|
|
|
Extra config options for systemd sleep state logic.
|
2023-11-21 17:10:23 +00:00
|
|
|
|
See {manpage}`sleep.conf.d(5)` man page for available options.
|
2020-02-03 16:31:46 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
additionalUpstreamSystemUnits = mkOption {
|
2014-07-25 18:05:57 +00:00
|
|
|
|
default = [ ];
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
example = [ "debug-shell.service" "systemd-quotacheck.service" ];
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = ''
|
2014-07-25 18:05:57 +00:00
|
|
|
|
Additional units shipped with systemd that shall be enabled.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
suppressedSystemUnits = mkOption {
|
2019-04-18 10:40:48 +00:00
|
|
|
|
default = [ ];
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
example = [ "systemd-backlight@.service" ];
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = ''
|
2022-03-22 11:11:54 +00:00
|
|
|
|
A list of units to skip when generating system systemd configuration directory. This has
|
2022-07-20 10:32:04 +00:00
|
|
|
|
priority over upstream units, {option}`systemd.units`, and
|
|
|
|
|
{option}`systemd.additionalUpstreamSystemUnits`. The main purpose of this is to
|
2022-03-22 11:11:54 +00:00
|
|
|
|
prevent a upstream systemd unit from being added to the initrd with any modifications made to it
|
|
|
|
|
by other NixOS modules.
|
2019-04-18 10:40:48 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
watchdog.device = mkOption {
|
2020-07-12 10:14:16 +00:00
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
|
default = null;
|
2020-07-09 01:43:12 +00:00
|
|
|
|
example = "/dev/watchdog";
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = ''
|
2020-07-09 01:43:12 +00:00
|
|
|
|
The path to a hardware watchdog device which will be managed by systemd.
|
2023-11-21 17:11:01 +00:00
|
|
|
|
If not specified, systemd will default to `/dev/watchdog`.
|
2020-07-09 01:43:12 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
watchdog.runtimeTime = mkOption {
|
2020-07-12 10:14:16 +00:00
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2020-07-09 01:43:12 +00:00
|
|
|
|
example = "30s";
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = ''
|
2020-07-09 01:43:12 +00:00
|
|
|
|
The amount of time which can elapse before a watchdog hardware device
|
2023-11-21 17:10:23 +00:00
|
|
|
|
will automatically reboot the system.
|
|
|
|
|
|
|
|
|
|
Valid time units include "ms", "s", "min", "h", "d", and "w";
|
|
|
|
|
see {manpage}`systemd.time(7)`.
|
2020-07-09 01:43:12 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
watchdog.rebootTime = mkOption {
|
2020-07-12 10:14:16 +00:00
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2020-07-09 01:43:12 +00:00
|
|
|
|
example = "10m";
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = ''
|
2020-07-09 01:43:12 +00:00
|
|
|
|
The amount of time which can elapse after a reboot has been triggered
|
|
|
|
|
before a watchdog hardware device will automatically reboot the system.
|
2023-11-21 17:10:23 +00:00
|
|
|
|
If left `null`, systemd will use its default of 10 minutes;
|
|
|
|
|
see {manpage}`systemd-system.conf(5)`.
|
|
|
|
|
|
|
|
|
|
Valid time units include "ms", "s", "min", "h", "d", and "w";
|
|
|
|
|
see also {manpage}`systemd.time(7)`.
|
2020-07-09 01:43:12 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-21 16:22:50 +00:00
|
|
|
|
watchdog.kexecTime = mkOption {
|
2020-07-12 10:14:16 +00:00
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2020-07-09 01:43:12 +00:00
|
|
|
|
example = "10m";
|
2023-11-21 16:22:50 +00:00
|
|
|
|
description = ''
|
2023-11-21 17:11:01 +00:00
|
|
|
|
The amount of time which can elapse when `kexec` is being executed before
|
2020-07-09 01:43:12 +00:00
|
|
|
|
a watchdog hardware device will automatically reboot the system. This
|
2023-11-21 17:10:23 +00:00
|
|
|
|
option should only be enabled if `reloadTime` is also enabled;
|
|
|
|
|
see {manpage}`kexec(8)`.
|
|
|
|
|
|
|
|
|
|
Valid time units include "ms", "s", "min", "h", "d", and "w";
|
|
|
|
|
see also {manpage}`systemd.time(7)`.
|
2020-07-09 01:43:12 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
2012-06-14 22:44:56 +00:00
|
|
|
|
};
|
|
|
|
|
|
2012-08-06 15:45:59 +00:00
|
|
|
|
|
2012-06-02 00:15:07 +00:00
|
|
|
|
###### implementation
|
|
|
|
|
|
2015-04-19 19:05:12 +00:00
|
|
|
|
config = {
|
2012-06-02 00:15:07 +00:00
|
|
|
|
|
2024-01-25 19:23:56 +00:00
|
|
|
|
warnings = let
|
|
|
|
|
mkOneNetOnlineWarn = typeStr: name: def: lib.optional
|
|
|
|
|
(lib.elem "network-online.target" def.after && !(lib.elem "network-online.target" (def.wants ++ def.requires ++ def.bindsTo)))
|
|
|
|
|
"${name}.${typeStr} is ordered after 'network-online.target' but doesn't depend on it";
|
|
|
|
|
mkNetOnlineWarns = typeStr: defs: lib.concatLists (lib.mapAttrsToList (mkOneNetOnlineWarn typeStr) defs);
|
|
|
|
|
mkMountNetOnlineWarns = typeStr: defs: lib.concatLists (map (m: mkOneNetOnlineWarn typeStr m.what m) defs);
|
|
|
|
|
in concatLists (
|
2020-10-31 15:50:25 +00:00
|
|
|
|
mapAttrsToList
|
|
|
|
|
(name: service:
|
|
|
|
|
let
|
|
|
|
|
type = service.serviceConfig.Type or "";
|
|
|
|
|
restart = service.serviceConfig.Restart or "no";
|
2020-10-31 08:25:51 +00:00
|
|
|
|
hasDeprecated = builtins.hasAttr "StartLimitInterval" service.serviceConfig;
|
2020-10-31 15:50:25 +00:00
|
|
|
|
in
|
|
|
|
|
concatLists [
|
|
|
|
|
(optional (type == "oneshot" && (restart == "always" || restart == "on-success"))
|
|
|
|
|
"Service '${name}.service' with 'Type=oneshot' cannot have 'Restart=always' or 'Restart=on-success'"
|
|
|
|
|
)
|
2020-10-31 08:25:51 +00:00
|
|
|
|
(optional hasDeprecated
|
|
|
|
|
"Service '${name}.service' uses the attribute 'StartLimitInterval' in the Service section, which is deprecated. See https://github.com/NixOS/nixpkgs/issues/45786."
|
|
|
|
|
)
|
2022-01-29 22:01:24 +00:00
|
|
|
|
(optional (service.reloadIfChanged && service.reloadTriggers != [])
|
|
|
|
|
"Service '${name}.service' has both 'reloadIfChanged' and 'reloadTriggers' set. This is probably not what you want, because 'reloadTriggers' behave the same whay as 'restartTriggers' if 'reloadIfChanged' is set."
|
|
|
|
|
)
|
2020-10-31 15:50:25 +00:00
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
cfg.services
|
2024-01-25 19:23:56 +00:00
|
|
|
|
)
|
|
|
|
|
++ (mkNetOnlineWarns "target" cfg.targets)
|
|
|
|
|
++ (mkNetOnlineWarns "service" cfg.services)
|
|
|
|
|
++ (mkNetOnlineWarns "socket" cfg.sockets)
|
|
|
|
|
++ (mkNetOnlineWarns "timer" cfg.timers)
|
|
|
|
|
++ (mkNetOnlineWarns "path" cfg.paths)
|
|
|
|
|
++ (mkMountNetOnlineWarns "mount" cfg.mounts)
|
|
|
|
|
++ (mkMountNetOnlineWarns "automount" cfg.automounts)
|
|
|
|
|
++ (mkNetOnlineWarns "slice" cfg.slices);
|
|
|
|
|
|
|
|
|
|
assertions = concatLists (
|
|
|
|
|
mapAttrsToList
|
|
|
|
|
(name: service:
|
|
|
|
|
map (message: {
|
|
|
|
|
assertion = false;
|
|
|
|
|
inherit message;
|
|
|
|
|
}) (concatLists [
|
|
|
|
|
(optional ((builtins.elem "network-interfaces.target" service.after) || (builtins.elem "network-interfaces.target" service.wants))
|
|
|
|
|
"Service '${name}.service' is using the deprecated target network-interfaces.target, which no longer exists. Using network.target is recommended instead."
|
|
|
|
|
)
|
|
|
|
|
])
|
|
|
|
|
)
|
|
|
|
|
cfg.services
|
2020-10-31 15:50:25 +00:00
|
|
|
|
);
|
2014-04-10 04:55:17 +00:00
|
|
|
|
|
2014-04-17 22:38:40 +00:00
|
|
|
|
system.build.units = cfg.units;
|
2012-06-16 04:19:43 +00:00
|
|
|
|
|
2022-06-09 15:28:13 +00:00
|
|
|
|
system.nssModules = [ cfg.package.out ];
|
2020-05-05 22:24:38 +00:00
|
|
|
|
system.nssDatabases = {
|
2020-05-05 13:03:14 +00:00
|
|
|
|
hosts = (mkMerge [
|
nixos/systemd: fix NSS database ordering
- The order of NSS (host) modules has been brought in line with upstream
recommendations:
- The `myhostname` module is placed before the `resolve` (optional) and `dns`
entries, but after `file` (to allow overriding via `/etc/hosts` /
`networking.extraHosts`, and prevent ISPs with catchall-DNS resolvers from
hijacking `.localhost` domains)
- The `mymachines` module, which provides hostname resolution for local
containers (registered with `systemd-machined`) is placed to the front, to
make sure its mappings are preferred over other resolvers.
- If systemd-networkd is enabled, the `resolve` module is placed before
`files` and `myhostname`, as it provides the same logic internally, with
caching.
- The `mdns(_minimal)` module has been updated to the new priorities.
If you use your own NSS host modules, make sure to update your priorities
according to these rules:
- NSS modules which should be queried before `resolved` DNS resolution should
use mkBefore.
- NSS modules which should be queried after `resolved`, `files` and
`myhostname`, but before `dns` should use the default priority
- NSS modules which should come after `dns` should use mkAfter.
2021-07-17 17:41:45 +00:00
|
|
|
|
(mkOrder 400 ["mymachines"]) # 400 to ensure it comes before resolve (which is mkBefore'd)
|
|
|
|
|
(mkOrder 999 ["myhostname"]) # after files (which is 998), but before regular nss modules
|
2020-05-05 13:03:14 +00:00
|
|
|
|
]);
|
|
|
|
|
passwd = (mkMerge [
|
|
|
|
|
(mkAfter [ "systemd" ])
|
|
|
|
|
]);
|
2020-05-05 22:06:40 +00:00
|
|
|
|
group = (mkMerge [
|
2022-12-08 08:49:12 +00:00
|
|
|
|
(mkAfter [ "[success=merge] systemd" ]) # need merge so that NSS won't stop at file-based groups
|
2020-05-05 22:06:40 +00:00
|
|
|
|
]);
|
2020-05-05 13:03:14 +00:00
|
|
|
|
};
|
|
|
|
|
|
2022-06-09 15:28:13 +00:00
|
|
|
|
environment.systemPackages = [ cfg.package ];
|
2012-08-06 15:45:59 +00:00
|
|
|
|
|
2016-03-24 14:27:47 +00:00
|
|
|
|
environment.etc = let
|
2024-06-03 09:15:59 +00:00
|
|
|
|
# generate contents for /etc/systemd/${dir} from attrset of links and packages
|
|
|
|
|
hooks = dir: links: pkgs.runCommand "${dir}" {
|
2018-11-08 10:59:03 +00:00
|
|
|
|
preferLocalBuild = true;
|
2019-07-26 09:11:44 +00:00
|
|
|
|
packages = cfg.packages;
|
2019-07-25 13:27:28 +00:00
|
|
|
|
} ''
|
|
|
|
|
set -e
|
2016-03-25 11:45:54 +00:00
|
|
|
|
mkdir -p $out
|
|
|
|
|
for package in $packages
|
|
|
|
|
do
|
2024-06-03 09:15:59 +00:00
|
|
|
|
for hook in $package/lib/systemd/${dir}/*
|
2019-07-25 13:27:28 +00:00
|
|
|
|
do
|
|
|
|
|
ln -s $hook $out/
|
|
|
|
|
done
|
|
|
|
|
done
|
|
|
|
|
${concatStrings (mapAttrsToList (exec: target: "ln -s ${target} $out/${exec};\n") links)}
|
2016-03-25 11:45:54 +00:00
|
|
|
|
'';
|
2019-04-18 10:40:48 +00:00
|
|
|
|
|
|
|
|
|
enabledUpstreamSystemUnits = filter (n: ! elem n cfg.suppressedSystemUnits) upstreamSystemUnits;
|
|
|
|
|
enabledUnits = filterAttrs (n: v: ! elem n cfg.suppressedSystemUnits) cfg.units;
|
2022-03-23 14:56:23 +00:00
|
|
|
|
|
2016-03-24 14:27:47 +00:00
|
|
|
|
in ({
|
2022-03-20 02:58:38 +00:00
|
|
|
|
"systemd/system".source = generateUnits {
|
|
|
|
|
type = "system";
|
|
|
|
|
units = enabledUnits;
|
|
|
|
|
upstreamUnits = enabledUpstreamSystemUnits;
|
|
|
|
|
upstreamWants = upstreamSystemWants;
|
|
|
|
|
};
|
2014-04-17 22:38:40 +00:00
|
|
|
|
|
2015-09-26 16:34:36 +00:00
|
|
|
|
"systemd/system.conf".text = ''
|
2013-05-09 14:21:42 +00:00
|
|
|
|
[Manager]
|
2022-03-23 14:56:23 +00:00
|
|
|
|
ManagerEnvironment=${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "${n}=${lib.escapeShellArg v}") cfg.managerEnvironment)}
|
2023-11-21 16:23:15 +00:00
|
|
|
|
${optionalString cfg.enableCgroupAccounting ''
|
2018-03-10 21:23:42 +00:00
|
|
|
|
DefaultCPUAccounting=yes
|
|
|
|
|
DefaultIOAccounting=yes
|
|
|
|
|
DefaultBlockIOAccounting=yes
|
2019-08-19 15:43:57 +00:00
|
|
|
|
DefaultIPAccounting=yes
|
2018-03-10 21:23:42 +00:00
|
|
|
|
''}
|
2019-08-16 09:29:41 +00:00
|
|
|
|
DefaultLimitCORE=infinity
|
2023-11-21 16:23:15 +00:00
|
|
|
|
${optionalString (cfg.watchdog.device != null) ''
|
|
|
|
|
WatchdogDevice=${cfg.watchdog.device}
|
2020-07-09 01:43:12 +00:00
|
|
|
|
''}
|
2023-11-21 16:23:15 +00:00
|
|
|
|
${optionalString (cfg.watchdog.runtimeTime != null) ''
|
|
|
|
|
RuntimeWatchdogSec=${cfg.watchdog.runtimeTime}
|
2020-07-09 01:43:12 +00:00
|
|
|
|
''}
|
2023-11-21 16:23:15 +00:00
|
|
|
|
${optionalString (cfg.watchdog.rebootTime != null) ''
|
|
|
|
|
RebootWatchdogSec=${cfg.watchdog.rebootTime}
|
2020-07-09 01:43:12 +00:00
|
|
|
|
''}
|
2023-11-21 16:23:15 +00:00
|
|
|
|
${optionalString (cfg.watchdog.kexecTime != null) ''
|
|
|
|
|
KExecWatchdogSec=${cfg.watchdog.kexecTime}
|
2020-07-09 01:43:12 +00:00
|
|
|
|
''}
|
|
|
|
|
|
2023-11-21 16:23:15 +00:00
|
|
|
|
${cfg.extraConfig}
|
2013-05-09 14:21:42 +00:00
|
|
|
|
'';
|
|
|
|
|
|
2015-09-26 16:34:36 +00:00
|
|
|
|
"systemd/sleep.conf".text = ''
|
2013-05-09 14:25:24 +00:00
|
|
|
|
[Sleep]
|
2023-11-21 16:23:15 +00:00
|
|
|
|
${cfg.sleep.extraConfig}
|
2013-05-09 14:25:24 +00:00
|
|
|
|
'';
|
|
|
|
|
|
2024-06-03 09:15:59 +00:00
|
|
|
|
"systemd/user-generators" = { source = hooks "user-generators" cfg.user.generators; };
|
|
|
|
|
"systemd/system-generators" = { source = hooks "system-generators" cfg.generators; };
|
|
|
|
|
"systemd/system-shutdown" = { source = hooks "system-shutdown" cfg.shutdown; };
|
2016-03-25 11:45:54 +00:00
|
|
|
|
});
|
2015-09-26 16:34:36 +00:00
|
|
|
|
|
2016-03-07 01:38:53 +00:00
|
|
|
|
services.dbus.enable = true;
|
|
|
|
|
|
2021-08-08 12:00:00 +00:00
|
|
|
|
users.users.systemd-network = {
|
|
|
|
|
uid = config.ids.uids.systemd-network;
|
|
|
|
|
group = "systemd-network";
|
|
|
|
|
};
|
2018-06-29 23:58:35 +00:00
|
|
|
|
users.groups.systemd-network.gid = config.ids.gids.systemd-network;
|
2021-08-08 12:00:00 +00:00
|
|
|
|
users.users.systemd-resolve = {
|
|
|
|
|
uid = config.ids.uids.systemd-resolve;
|
|
|
|
|
group = "systemd-resolve";
|
|
|
|
|
};
|
2018-06-29 23:58:35 +00:00
|
|
|
|
users.groups.systemd-resolve.gid = config.ids.gids.systemd-resolve;
|
2015-05-11 13:54:16 +00:00
|
|
|
|
|
2012-11-01 22:32:12 +00:00
|
|
|
|
# Target for ‘charon send-keys’ to hook into.
|
2018-06-29 23:58:35 +00:00
|
|
|
|
users.groups.keys.gid = config.ids.gids.keys;
|
2014-02-11 12:00:10 +00:00
|
|
|
|
|
2013-01-16 11:33:18 +00:00
|
|
|
|
systemd.targets.keys =
|
2012-11-01 22:32:12 +00:00
|
|
|
|
{ description = "Security Keys";
|
2014-02-26 18:35:04 +00:00
|
|
|
|
unitConfig.X-StopOnReconfiguration = true;
|
2012-11-01 22:32:12 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-11-25 20:31:09 +00:00
|
|
|
|
# This target only exists so that services ordered before sysinit.target
|
|
|
|
|
# are restarted in the correct order, notably BEFORE the other services,
|
|
|
|
|
# when switching configurations.
|
|
|
|
|
systemd.targets.sysinit-reactivation = {
|
|
|
|
|
description = "Reactivate sysinit units";
|
|
|
|
|
};
|
|
|
|
|
|
2013-01-16 11:33:18 +00:00
|
|
|
|
systemd.units =
|
2024-03-21 13:52:12 +00:00
|
|
|
|
let
|
|
|
|
|
withName = cfgToUnit: cfg: lib.nameValuePair cfg.name (cfgToUnit cfg);
|
|
|
|
|
in
|
|
|
|
|
mapAttrs' (_: withName pathToUnit) cfg.paths
|
|
|
|
|
// mapAttrs' (_: withName serviceToUnit) cfg.services
|
|
|
|
|
// mapAttrs' (_: withName sliceToUnit) cfg.slices
|
|
|
|
|
// mapAttrs' (_: withName socketToUnit) cfg.sockets
|
|
|
|
|
// mapAttrs' (_: withName targetToUnit) cfg.targets
|
|
|
|
|
// mapAttrs' (_: withName timerToUnit) cfg.timers
|
|
|
|
|
// listToAttrs (map (withName mountToUnit) cfg.mounts)
|
|
|
|
|
// listToAttrs (map (withName automountToUnit) cfg.automounts);
|
2012-06-14 22:44:56 +00:00
|
|
|
|
|
2022-03-23 14:56:23 +00:00
|
|
|
|
# Environment of PID 1
|
|
|
|
|
systemd.managerEnvironment = {
|
|
|
|
|
# Doesn't contain systemd itself - everything works so it seems to use the compiled-in value for its tools
|
2022-11-15 22:50:20 +00:00
|
|
|
|
# util-linux is needed for the main fsck utility wrapping the fs-specific ones
|
|
|
|
|
PATH = lib.makeBinPath (config.system.fsPackages ++ [cfg.package.util-linux]);
|
2022-03-23 14:56:23 +00:00
|
|
|
|
LOCALE_ARCHIVE = "/run/current-system/sw/lib/locale/locale-archive";
|
|
|
|
|
TZDIR = "/etc/zoneinfo";
|
|
|
|
|
# If SYSTEMD_UNIT_PATH ends with an empty component (":"), the usual unit load path will be appended to the contents of the variable
|
|
|
|
|
SYSTEMD_UNIT_PATH = lib.mkIf (config.boot.extraSystemdUnitPaths != []) "${builtins.concatStringsSep ":" config.boot.extraSystemdUnitPaths}:";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2014-04-30 11:53:12 +00:00
|
|
|
|
system.requiredKernelConfig = map config.lib.kernelConfig.isEnabled
|
|
|
|
|
[ "DEVTMPFS" "CGROUPS" "INOTIFY_USER" "SIGNALFD" "TIMERFD" "EPOLL" "NET"
|
2018-03-22 19:16:30 +00:00
|
|
|
|
"SYSFS" "PROC_FS" "FHANDLE" "CRYPTO_USER_API_HASH" "CRYPTO_HMAC"
|
2023-10-19 23:44:13 +00:00
|
|
|
|
"CRYPTO_SHA256" "DMIID" "AUTOFS_FS" "TMPFS_POSIX_ACL"
|
2014-04-30 11:53:12 +00:00
|
|
|
|
"TMPFS_XATTR" "SECCOMP"
|
|
|
|
|
];
|
2012-11-29 17:51:44 +00:00
|
|
|
|
|
2013-10-09 12:28:35 +00:00
|
|
|
|
# Generate timer units for all services that have a ‘startAt’ value.
|
|
|
|
|
systemd.timers =
|
|
|
|
|
mapAttrs (name: service:
|
|
|
|
|
{ wantedBy = [ "timers.target" ];
|
|
|
|
|
timerConfig.OnCalendar = service.startAt;
|
|
|
|
|
})
|
2016-10-19 00:10:46 +00:00
|
|
|
|
(filterAttrs (name: service: service.enable && service.startAt != []) cfg.services);
|
2013-10-09 12:28:35 +00:00
|
|
|
|
|
2015-05-11 10:39:37 +00:00
|
|
|
|
# Some overrides to upstream units.
|
|
|
|
|
systemd.services."systemd-backlight@".restartIfChanged = false;
|
2017-04-04 14:29:24 +00:00
|
|
|
|
systemd.services."systemd-fsck@".restartIfChanged = false;
|
2023-06-18 10:00:11 +00:00
|
|
|
|
systemd.services."systemd-fsck@".path = [ pkgs.util-linux ] ++ config.system.fsPackages;
|
2023-05-29 20:14:18 +00:00
|
|
|
|
systemd.services."systemd-makefs@" = {
|
|
|
|
|
restartIfChanged = false;
|
|
|
|
|
path = [ pkgs.util-linux ] ++ config.system.fsPackages;
|
|
|
|
|
# Since there is no /etc/systemd/system/systemd-makefs@.service
|
|
|
|
|
# file, the units generated in /run/systemd/generator would
|
|
|
|
|
# override anything we put here. But by forcing the use of a
|
|
|
|
|
# drop-in in /etc, it does apply.
|
|
|
|
|
overrideStrategy = "asDropin";
|
|
|
|
|
};
|
2023-07-29 18:01:11 +00:00
|
|
|
|
systemd.services."systemd-mkswap@" = {
|
|
|
|
|
restartIfChanged = false;
|
|
|
|
|
path = [ pkgs.util-linux ];
|
|
|
|
|
overrideStrategy = "asDropin";
|
|
|
|
|
};
|
2015-05-11 10:39:37 +00:00
|
|
|
|
systemd.services.systemd-random-seed.restartIfChanged = false;
|
|
|
|
|
systemd.services.systemd-remount-fs.restartIfChanged = false;
|
|
|
|
|
systemd.services.systemd-update-utmp.restartIfChanged = false;
|
2019-01-05 12:55:27 +00:00
|
|
|
|
systemd.services.systemd-udev-settle.restartIfChanged = false; # Causes long delays in nixos-rebuild
|
2015-05-11 10:39:37 +00:00
|
|
|
|
systemd.targets.local-fs.unitConfig.X-StopOnReconfiguration = true;
|
|
|
|
|
systemd.targets.remote-fs.unitConfig.X-StopOnReconfiguration = true;
|
2024-01-25 19:23:56 +00:00
|
|
|
|
systemd.targets.network-online.wantedBy = [ "multi-user.target" ];
|
2019-12-11 08:34:35 +00:00
|
|
|
|
systemd.services.systemd-importd.environment = proxy_env;
|
2020-12-01 23:54:35 +00:00
|
|
|
|
systemd.services.systemd-pstore.wantedBy = [ "sysinit.target" ]; # see #81138
|
2014-07-11 21:33:40 +00:00
|
|
|
|
|
2022-06-30 09:54:47 +00:00
|
|
|
|
# NixOS has kernel modules in a different location, so override that here.
|
|
|
|
|
systemd.services.kmod-static-nodes.unitConfig.ConditionFileNotEmpty = [
|
|
|
|
|
"" # required to unset the previous value!
|
|
|
|
|
"/run/booted-system/kernel-modules/lib/modules/%v/modules.devname"
|
|
|
|
|
];
|
|
|
|
|
|
2015-05-11 13:48:45 +00:00
|
|
|
|
# Don't bother with certain units in containers.
|
|
|
|
|
systemd.services.systemd-remount-fs.unitConfig.ConditionVirtualization = "!container";
|
2019-10-07 18:24:29 +00:00
|
|
|
|
|
2021-04-03 08:11:52 +00:00
|
|
|
|
# Increase numeric PID range (set directly instead of copying a one-line file from systemd)
|
|
|
|
|
# https://github.com/systemd/systemd/pull/12226
|
|
|
|
|
boot.kernel.sysctl."kernel.pid_max" = mkIf pkgs.stdenv.is64bit (lib.mkDefault 4194304);
|
|
|
|
|
|
2020-11-17 20:54:26 +00:00
|
|
|
|
boot.kernelParams = optional (!cfg.enableUnifiedCgroupHierarchy) "systemd.unified_cgroup_hierarchy=0";
|
2022-02-11 08:09:52 +00:00
|
|
|
|
|
2022-11-29 13:20:25 +00:00
|
|
|
|
# Avoid potentially degraded system state due to
|
|
|
|
|
# "Userspace Out-Of-Memory (OOM) Killer was skipped because of a failed condition check (ConditionControlGroupController=v2)."
|
2023-03-08 23:39:12 +00:00
|
|
|
|
systemd.oomd.enable = mkIf (!cfg.enableUnifiedCgroupHierarchy) false;
|
2022-11-29 13:20:25 +00:00
|
|
|
|
|
2022-02-28 21:54:12 +00:00
|
|
|
|
services.logrotate.settings = {
|
2022-02-11 08:09:52 +00:00
|
|
|
|
"/var/log/btmp" = mapAttrs (_: mkDefault) {
|
|
|
|
|
frequency = "monthly";
|
2022-02-28 21:54:12 +00:00
|
|
|
|
rotate = 1;
|
|
|
|
|
create = "0660 root ${config.users.groups.utmp.name}";
|
|
|
|
|
minsize = "1M";
|
2022-02-11 08:09:52 +00:00
|
|
|
|
};
|
|
|
|
|
"/var/log/wtmp" = mapAttrs (_: mkDefault) {
|
|
|
|
|
frequency = "monthly";
|
2022-02-28 21:54:12 +00:00
|
|
|
|
rotate = 1;
|
|
|
|
|
create = "0664 root ${config.users.groups.utmp.name}";
|
|
|
|
|
minsize = "1M";
|
2022-02-11 08:09:52 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
2015-04-19 19:05:12 +00:00
|
|
|
|
};
|
2014-11-19 21:11:30 +00:00
|
|
|
|
|
2015-10-14 16:05:50 +00:00
|
|
|
|
# FIXME: Remove these eventually.
|
|
|
|
|
imports =
|
|
|
|
|
[ (mkRenamedOptionModule [ "boot" "systemd" "sockets" ] [ "systemd" "sockets" ])
|
|
|
|
|
(mkRenamedOptionModule [ "boot" "systemd" "targets" ] [ "systemd" "targets" ])
|
|
|
|
|
(mkRenamedOptionModule [ "boot" "systemd" "services" ] [ "systemd" "services" ])
|
2019-12-10 01:51:19 +00:00
|
|
|
|
(mkRenamedOptionModule [ "jobs" ] [ "systemd" "services" ])
|
|
|
|
|
(mkRemovedOptionModule [ "systemd" "generator-packages" ] "Use systemd.packages instead.")
|
2015-10-14 16:05:50 +00:00
|
|
|
|
];
|
2012-06-02 00:15:07 +00:00
|
|
|
|
}
|