mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-08-26 18:24:53 +00:00
pkgs.systemd does not respect config.systemd.package and config.boot.initrd.systemd.package overrides. Fix references to the systemd package to ensure that the udevadm used is copied into the initrd.
96 lines
2.6 KiB
Nix
96 lines
2.6 KiB
Nix
{
|
|
system ? builtins.currentSystem,
|
|
config ? { },
|
|
pkgs ? import ../.. { inherit system config; },
|
|
}:
|
|
|
|
let
|
|
inherit (import ../lib/testing-python.nix { inherit system pkgs; }) makeTest;
|
|
testCombinations = pkgs.lib.cartesianProduct {
|
|
predictable = [
|
|
true
|
|
false
|
|
];
|
|
withNetworkd = [
|
|
true
|
|
false
|
|
];
|
|
systemdStage1 = [
|
|
true
|
|
false
|
|
];
|
|
};
|
|
in
|
|
pkgs.lib.listToAttrs (
|
|
map (
|
|
{
|
|
predictable,
|
|
withNetworkd,
|
|
systemdStage1,
|
|
}:
|
|
{
|
|
name =
|
|
pkgs.lib.optionalString (!predictable) "un"
|
|
+ "predictable"
|
|
+ pkgs.lib.optionalString withNetworkd "Networkd"
|
|
+ pkgs.lib.optionalString systemdStage1 "SystemdStage1";
|
|
value = makeTest {
|
|
name =
|
|
pkgs.lib.optionalString (!predictable) "un"
|
|
+ "predictableInterfaceNames"
|
|
+ pkgs.lib.optionalString withNetworkd "-with-networkd"
|
|
+ pkgs.lib.optionalString systemdStage1 "-systemd-stage-1";
|
|
meta = { };
|
|
|
|
nodes.machine =
|
|
{
|
|
config,
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
script = ''
|
|
${lib.getExe' config.boot.initrd.systemd.package "udevadm"} settle --timeout=180
|
|
ip link
|
|
if ${lib.optionalString predictable "!"} ip link show eth0; then
|
|
echo Success
|
|
else
|
|
exit 1
|
|
fi
|
|
'';
|
|
in
|
|
{
|
|
networking.usePredictableInterfaceNames = lib.mkForce predictable;
|
|
networking.useNetworkd = withNetworkd;
|
|
networking.dhcpcd.enable = !withNetworkd;
|
|
networking.useDHCP = !withNetworkd;
|
|
|
|
# Check if predictable interface names are working in stage-1
|
|
boot.initrd.postDeviceCommands = lib.mkIf (!systemdStage1) script;
|
|
|
|
boot.initrd.systemd = lib.mkMerge [
|
|
{ enable = systemdStage1; }
|
|
(lib.mkIf systemdStage1 {
|
|
initrdBin = [ pkgs.iproute2 ];
|
|
services.systemd-udev-settle.wantedBy = [ "initrd.target" ];
|
|
services.check-interfaces = {
|
|
requiredBy = [ "initrd.target" ];
|
|
after = [ "systemd-udev-settle.service" ];
|
|
serviceConfig.Type = "oneshot";
|
|
path = [ pkgs.iproute2 ];
|
|
inherit script;
|
|
};
|
|
})
|
|
];
|
|
};
|
|
|
|
testScript = ''
|
|
print(machine.succeed("ip link"))
|
|
machine.${if predictable then "fail" else "succeed"}("ip link show eth0")
|
|
'';
|
|
};
|
|
}
|
|
) testCombinations
|
|
)
|