nixos/systemd: point various systemd daemons to /etc/static (#491802)

This commit is contained in:
nikstur
2026-02-23 13:07:04 +00:00
committed by GitHub
2 changed files with 27 additions and 2 deletions
+25
View File
@@ -807,6 +807,31 @@ in
# Don't bother with certain units in containers.
systemd.services.systemd-remount-fs.unitConfig.ConditionVirtualization = "!container";
# When using the classic /etc mechanism, we set certain paths in /etc to
# /etc/static so that systemd cannot change them (as they are symlinks to
# the read-only Nix Store). This is only done so that these services cannot
# change the values. All other parts of systemd should read them from their
# canonical locations.
#
# If you use the overlay mechanism to manage /etc, this is unnecessary
# because either the overlay is mutable (and users can legitimately change
# values without them being overridden) or it is immutable and systemd will
# suggest to only make runtime changes.
systemd.services."systemd-localed".environment = lib.mkIf (!config.system.etc.overlay.enable) {
SYSTEMD_ETC_LOCALE_CONF = "/etc/static/locale.conf";
SYSTEMD_ETC_VCONSOLE_CONF = "/etc/static/vconsole.conf";
};
systemd.services."systemd-timedated".environment =
lib.mkIf (!config.system.etc.overlay.enable && config.time.timeZone != null)
{
SYSTEMD_ETC_LOCALTIME = "/etc/static/localtime";
SYSTEMD_ETC_ADJTIME = "/etc/static/adjtime";
};
systemd.services."systemd-hostnamed".environment = lib.mkIf (!config.system.etc.overlay.enable) {
SYSTEMD_ETC_HOSTNAME = "/etc/static/hostname";
SYSTEMD_ETC_MACHINE_INFO = "/etc/static/machine-info";
};
# 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.hostPlatform.is64bit (lib.mkDefault 4194304);
+2 -2
View File
@@ -109,10 +109,10 @@
machine.wait_for_unit("first-boot-complete.target")
machine.succeed(
"journalctl --system -o cat --grep 'systemd ${lib.escapeRegex pkgs.systemd.version} running'"
"journalctl --system -o cat --grep 'systemd ${lib.escapeRegex nodes.machine.systemd.package.version} running'"
)
assert "systemd ${lib.versions.major pkgs.systemd.version} (${pkgs.systemd.version})" in machine.succeed(
assert "systemd ${lib.versions.major nodes.machine.systemd.package.version} (${nodes.machine.systemd.package.version})" in machine.succeed(
"systemctl --version"
)