Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd: 255.9 -> 256.2 #307068

Merged
merged 7 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions nixos/lib/systemd-lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ in rec {
optional (attr ? ${name} && !isInt attr.${name})
"Systemd ${group} field `${name}' is not an integer";

assertRemoved = name: see: group: attr:
optional (attr ? ${name})
"Systemd ${group} field `${name}' has been removed. See ${see}";

checkUnitConfig = group: checks: attrs: let
# We're applied at the top-level type (attrsOf unitOption), so the actual
# unit options might contain attributes from mkOverride and mkIf that we need to
Expand Down
71 changes: 56 additions & 15 deletions nixos/lib/systemd-types.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,61 @@ let

inherit (lib.types)
attrsOf
coercedTo
enum
lines
listOf
nullOr
oneOf
package
path
singleLineStr
submodule
;

initrdStorePathModule = { config, ... }: {
options = {
enable = (mkEnableOption "copying of this file and symlinking it") // { default = true; };

target = mkOption {
type = nullOr path;
description = ''
Path of the symlink.
'';
default = null;
};

source = mkOption {
type = path;
description = "Path of the source file.";
};

dlopen = {
usePriority = mkOption {
type = enum [ "required" "recommended" "suggested" ];
default = "recommended";
description = ''
Priority of dlopen ELF notes to include. "required" is
minimal, "recommended" includes "required", and
"suggested" includes "recommended".

See: https://systemd.io/ELF_DLOPEN_METADATA/
'';
};

features = mkOption {
type = listOf singleLineStr;
default = [ ];
description = ''
Features to enable via dlopen ELF notes. These will be in
addition to anything included via 'usePriority',
regardless of their priority.
'';
};
};
};
};

in

{
Expand Down Expand Up @@ -86,31 +135,23 @@ in
automounts = listOf (submodule [ stage2AutomountOptions unitConfig automountConfig ]);
initrdAutomounts = attrsOf (submodule [ stage1AutomountOptions unitConfig automountConfig ]);

initrdStorePath = listOf (coercedTo
(oneOf [ singleLineStr package ])
(source: { inherit source; })
(submodule initrdStorePathModule));

initrdContents = attrsOf (submodule ({ config, options, name, ... }: {
imports = [ initrdStorePathModule ];
options = {
enable = (mkEnableOption "copying of this file and symlinking it") // { default = true; };

target = mkOption {
type = path;
description = ''
Path of the symlink.
'';
default = name;
};

text = mkOption {
default = null;
type = nullOr lines;
description = "Text of the file.";
};

source = mkOption {
type = path;
description = "Path of the source file.";
};
};

config = {
target = mkDefault name;
source = mkIf (config.text != null) (
let name' = "initrd-" + baseNameOf name;
in mkDerivedConfig options.text (pkgs.writeText name')
Expand Down
11 changes: 10 additions & 1 deletion nixos/modules/system/boot/networkd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ let
"ManageForeignRoutes"
"RouteTable"
"IPv6PrivacyExtensions"
"IPv4Forwarding"
"IPv6Forwarding"
])
(assertValueOneOf "SpeedMeter" boolValues)
(assertInt "SpeedMeterIntervalSec")
(assertValueOneOf "ManageForeignRoutingPolicyRules" boolValues)
(assertValueOneOf "ManageForeignRoutes" boolValues)
(assertValueOneOf "IPv6PrivacyExtensions" (boolValues ++ ["prefer-public" "kernel"]))
(assertValueOneOf "IPv4Forwarding" boolValues)
(assertValueOneOf "IPv6Forwarding" boolValues)
];

sectionDHCPv4 = checkUnitConfig "DHCPv4" [
Expand Down Expand Up @@ -652,6 +656,8 @@ let
"DNSDefaultRoute"
"NTP"
"IPForward"
"IPv4Forwarding"
"IPv6Forwarding"
"IPMasquerade"
"IPv6PrivacyExtensions"
"IPv6AcceptRA"
Expand Down Expand Up @@ -700,7 +706,9 @@ let
(assertValueOneOf "LLDP" (boolValues ++ ["routers-only"]))
(assertValueOneOf "EmitLLDP" (boolValues ++ ["nearest-bridge" "non-tpmr-bridge" "customer-bridge"]))
(assertValueOneOf "DNSDefaultRoute" boolValues)
(assertValueOneOf "IPForward" (boolValues ++ ["ipv4" "ipv6"]))
(assertRemoved "IPForward" "IPv4Forwarding and IPv6Forwarding in systemd.network(5) and networkd.conf(5)")
(assertValueOneOf "IPv4Forwarding" boolValues)
(assertValueOneOf "IPv6Forwarding" boolValues)
(assertValueOneOf "IPMasquerade" (boolValues ++ ["ipv4" "ipv6" "both"]))
(assertValueOneOf "IPv6PrivacyExtensions" (boolValues ++ ["prefer-public" "kernel"]))
(assertValueOneOf "IPv6AcceptRA" boolValues)
Expand Down Expand Up @@ -2835,6 +2843,7 @@ let
"systemd-networkd-wait-online.service"
"systemd-networkd.service"
"systemd-networkd.socket"
"systemd-networkd-persistent-storage.service"
nikstur marked this conversation as resolved.
Show resolved Hide resolved
];

environment.etc."systemd/networkd.conf" = renderConfig cfg.config;
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/system/boot/stage-1.nix
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ let

# Copy udev.
copy_bin_and_libs ${udev}/bin/udevadm
cp ${lib.getLib udev.kmod}/lib/libkmod.so* $out/lib
ElvishJerricco marked this conversation as resolved.
Show resolved Hide resolved
copy_bin_and_libs ${udev}/lib/systemd/systemd-sysctl
for BIN in ${udev}/lib/udev/*_id; do
copy_bin_and_libs $BIN
Expand Down
14 changes: 14 additions & 0 deletions nixos/modules/system/boot/systemd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ let
"cryptsetup.target"
"cryptsetup-pre.target"
"remote-cryptsetup.target"
] ++ optionals cfg.package.withTpm2Tss [
"tpm2.target"
nikstur marked this conversation as resolved.
Show resolved Hide resolved
] ++ [
"sigpwr.target"
"timers.target"
Expand Down Expand Up @@ -112,6 +114,7 @@ let
"sleep.target"
"hybrid-sleep.target"
"systemd-hibernate.service"
"systemd-hibernate-clear.service"
nikstur marked this conversation as resolved.
Show resolved Hide resolved
"systemd-hybrid-sleep.service"
"systemd-suspend.service"
"systemd-suspend-then-hibernate.service"
Expand All @@ -136,6 +139,16 @@ let
"systemd-ask-password-wall.path"
"systemd-ask-password-wall.service"

# Varlink APIs
"[email protected]"
nikstur marked this conversation as resolved.
Show resolved Hide resolved
"systemd-bootctl.socket"
nikstur marked this conversation as resolved.
Show resolved Hide resolved
"[email protected]"
nikstur marked this conversation as resolved.
Show resolved Hide resolved
"systemd-creds.socket"
nikstur marked this conversation as resolved.
Show resolved Hide resolved
] ++ lib.optional cfg.package.withTpm2Tss [
"[email protected]"
"systemd-pcrlock.socket"
nikstur marked this conversation as resolved.
Show resolved Hide resolved
] ++ [

# Slices / containers.
"slices.target"
] ++ optionals cfg.package.withImportd [
Expand All @@ -158,6 +171,7 @@ let
] ++ optionals cfg.package.withHostnamed [
"dbus-org.freedesktop.hostname1.service"
"systemd-hostnamed.service"
"systemd-hostnamed.socket"
nikstur marked this conversation as resolved.
Show resolved Hide resolved
] ++ optionals cfg.package.withPortabled [
"dbus-org.freedesktop.portable1.service"
"systemd-portabled.service"
Expand Down
13 changes: 8 additions & 5 deletions nixos/modules/system/boot/systemd/initrd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ let
"systemd-tmpfiles-setup-dev.service"
"systemd-tmpfiles-setup.service"
"timers.target"
"tpm2.target"
"umount.target"
"systemd-bsod.service"
] ++ cfg.additionalUpstreamUnits;
Expand Down Expand Up @@ -111,8 +112,7 @@ let
inherit (config.boot.initrd) compressor compressorArgs prepend;
inherit (cfg) strip;

contents = map (path: { object = path; symlink = ""; }) (subtractLists cfg.suppressedStorePaths cfg.storePaths)
++ mapAttrsToList (_: v: { object = v.source; symlink = v.target; }) (filterAttrs (_: v: v.enable) cfg.contents);
contents = lib.filter ({ source, ... }: !lib.elem source cfg.suppressedStorePaths) cfg.storePaths;
};

in {
Expand Down Expand Up @@ -171,7 +171,7 @@ in {
description = ''
Store paths to copy into the initrd as well.
'';
type = with types; listOf (oneOf [ singleLineStr package ]);
type = utils.systemdUtils.types.initrdStorePath;
default = [];
};

Expand Down Expand Up @@ -344,7 +344,8 @@ in {
};

enableTpm2 = mkOption {
default = true;
default = cfg.package.withTpm2Tss;
ElvishJerricco marked this conversation as resolved.
Show resolved Hide resolved
defaultText = "boot.initrd.systemd.package.withTpm2Tss";
type = types.bool;
description = ''
Whether to enable TPM2 support in the initrd.
Expand Down Expand Up @@ -460,6 +461,7 @@ in {
"${cfg.package}/lib/systemd/systemd-sulogin-shell"
"${cfg.package}/lib/systemd/systemd-sysctl"
"${cfg.package}/lib/systemd/systemd-bsod"
"${cfg.package}/lib/systemd/systemd-sysroot-fstab-check"

# generators
"${cfg.package}/lib/systemd/system-generators/systemd-debug-generator"
Expand All @@ -486,7 +488,8 @@ in {
# fido2 support
"${cfg.package}/lib/cryptsetup/libcryptsetup-token-systemd-fido2.so"
"${pkgs.libfido2}/lib/libfido2.so.1"
] ++ jobScripts;
] ++ jobScripts
++ map (c: builtins.removeAttrs c ["text"]) (builtins.attrValues cfg.contents);

targets.initrd.aliases = ["default.target"];
units =
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/system/boot/systemd/journald.nix
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ in {
"[email protected]"
"systemd-journal-flush.service"
"systemd-journal-catalog-update.service"
"[email protected]"
nikstur marked this conversation as resolved.
Show resolved Hide resolved
] ++ (optional (!config.boot.isContainer) "systemd-journald-audit.socket") ++ [
"systemd-journald-dev-log.socket"
"syslog.socket"
Expand Down
10 changes: 4 additions & 6 deletions nixos/modules/system/boot/systemd/shutdown.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

cfg = config.systemd.shutdownRamfs;

ramfsContents = let
storePaths = map (p: "${p}\n") cfg.storePaths;
contents = lib.mapAttrsToList (_: v: "${v.source}\n${v.target}") (lib.filterAttrs (_: v: v.enable) cfg.contents);
in pkgs.writeText "shutdown-ramfs-contents" (lib.concatStringsSep "\n" (storePaths ++ contents));
ramfsContents = pkgs.writeText "shutdown-ramfs-contents.json" (builtins.toJSON cfg.storePaths);

in {
options.systemd.shutdownRamfs = {
Expand All @@ -24,7 +21,7 @@ in {
description = ''
Store paths to copy into the shutdown ramfs as well.
'';
type = lib.types.listOf lib.types.singleLineStr;
type = utils.systemdUtils.types.initrdStorePath;
default = [];
};
};
Expand All @@ -35,7 +32,8 @@ in {
"/etc/initrd-release".source = config.environment.etc.os-release.source;
"/etc/os-release".source = config.environment.etc.os-release.source;
};
systemd.shutdownRamfs.storePaths = [pkgs.runtimeShell "${pkgs.coreutils}/bin"];
systemd.shutdownRamfs.storePaths = [pkgs.runtimeShell "${pkgs.coreutils}/bin"]
++ map (c: builtins.removeAttrs c ["text"]) (builtins.attrValues cfg.contents);

systemd.mounts = [{
what = "tmpfs";
Expand Down
3 changes: 2 additions & 1 deletion nixos/tests/rosenpass.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ in
enable = true;
networks."rosenpass" = {
matchConfig.Name = deviceName;
networkConfig.IPForward = true;
networkConfig.IPv4Forwarding = true;
networkConfig.IPv6Forwarding = true;
address = [ "${peer.ip}/64" ];
};

Expand Down
4 changes: 3 additions & 1 deletion nixos/tests/systemd-boot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,10 @@ in
"""
)

output = machine.succeed("/run/current-system/bin/switch-to-configuration boot")
output = machine.succeed("/run/current-system/bin/switch-to-configuration boot 2>&1")
assert "updating systemd-boot from 000.0-1-notnixos to " in output, "Couldn't find systemd-boot update message"
assert 'to "/boot/EFI/systemd/systemd-bootx64.efi"' in output, "systemd-boot not copied to to /boot/EFI/systemd/systemd-bootx64.efi"
assert 'to "/boot/EFI/BOOT/BOOTX64.EFI"' in output, "systemd-boot not copied to to /boot/EFI/BOOT/BOOTX64.EFI"
'';
};

Expand Down
2 changes: 0 additions & 2 deletions nixos/tests/systemd-networkd-dhcpserver-static-leases.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import ./make-test-python.nix ({ lib, ... }: {
"01-eth1" = {
name = "eth1";
networkConfig = {
# IPForward prevents dynamic address configuration
IPForward = true;
DHCPServer = true;
Address = "10.0.0.1/24";
};
Expand Down
3 changes: 2 additions & 1 deletion nixos/tests/systemd-networkd-ipv6-prefix-delegation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {
address = [
"2001:DB8::1/64"
];
networkConfig.IPForward = true;
networkConfig.IPv4Forwarding = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this setting (IPv4Forwarding) is actually needed for this IPv6 test.

networkConfig.IPv6Forwarding = true;
};
};
};
Expand Down
15 changes: 10 additions & 5 deletions nixos/tests/systemd-networkd-vrf.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: let
linkConfig.RequiredForOnline = "no";
networkConfig = {
Address = "192.168.${toString vlan}.${toString id}/24";
IPForward = "yes";
IPv4Forwarding = "yes";
IPv6Forwarding = "yes";
nikstur marked this conversation as resolved.
Show resolved Hide resolved
};
};
};
Expand Down Expand Up @@ -57,14 +58,16 @@ in {

networks."10-vrf1" = {
matchConfig.Name = "vrf1";
networkConfig.IPForward = "yes";
networkConfig.IPv4Forwarding = "yes";
networkConfig.IPv6Forwarding = "yes";
routes = [
{ Destination = "192.168.1.2"; Metric = 100; }
];
};
networks."10-vrf2" = {
matchConfig.Name = "vrf2";
networkConfig.IPForward = "yes";
networkConfig.IPv4Forwarding = "yes";
networkConfig.IPv6Forwarding = "yes";
routes = [
{ Destination = "192.168.2.3"; Metric = 100; }
];
Expand All @@ -76,7 +79,8 @@ in {
networkConfig = {
VRF = "vrf1";
Address = "192.168.1.1/24";
IPForward = "yes";
IPv4Forwarding = "yes";
IPv6Forwarding = "yes";
};
};
networks."10-eth2" = {
Expand All @@ -85,7 +89,8 @@ in {
networkConfig = {
VRF = "vrf2";
Address = "192.168.2.1/24";
IPForward = "yes";
IPv4Forwarding = "yes";
IPv6Forwarding = "yes";
};
};
};
Expand Down
Loading
Loading