mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-11-10 17:54:53 +01:00
80 lines
1.9 KiB
Nix
80 lines
1.9 KiB
Nix
let
|
|
mkIfStateConfig = id: {
|
|
enable = true;
|
|
settings.interfaces.eth1 = {
|
|
addresses = [ "2001:0db8::${builtins.toString id}/64" ];
|
|
link = {
|
|
state = "up";
|
|
kind = "physical";
|
|
};
|
|
};
|
|
};
|
|
in
|
|
{
|
|
name = "ifstate-initrd-partial-broken-config";
|
|
|
|
nodes = {
|
|
server =
|
|
{ lib, ... }:
|
|
{
|
|
imports = [ ../../modules/profiles/minimal.nix ];
|
|
|
|
virtualisation.interfaces.eth1.vlan = 1;
|
|
|
|
# Initrd IfState enforces stage 2 ifstate using assertion.
|
|
networking.ifstate = {
|
|
enable = true;
|
|
settings.interfaces = { };
|
|
};
|
|
|
|
boot.initrd = {
|
|
network = {
|
|
enable = true;
|
|
ifstate = lib.mkMerge [
|
|
(mkIfStateConfig 1)
|
|
{
|
|
allowIfstateToDrasticlyIncreaseInitrdSize = true;
|
|
|
|
# non-existent interface; ifstate should apply eth1 and do not distrupt the boot process
|
|
settings.interfaces.eth2 = {
|
|
addresses = [ "2001:0db8:b::dead:beef/64" ];
|
|
link = {
|
|
state = "up";
|
|
kind = "physical";
|
|
};
|
|
};
|
|
}
|
|
];
|
|
};
|
|
systemd = {
|
|
enable = true;
|
|
network.enable = false;
|
|
services.boot-blocker = {
|
|
before = [ "initrd.target" ];
|
|
wantedBy = [ "initrd.target" ];
|
|
script = "sleep infinity";
|
|
serviceConfig.Type = "oneshot";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
client = {
|
|
imports = [ ../../modules/profiles/minimal.nix ];
|
|
|
|
virtualisation.interfaces.eth1.vlan = 1;
|
|
|
|
networking.ifstate = mkIfStateConfig 2;
|
|
};
|
|
};
|
|
|
|
testScript = # python
|
|
''
|
|
start_all()
|
|
client.wait_for_unit("network.target")
|
|
|
|
# try to ping the server from the client
|
|
client.wait_until_succeeds("ping -c 1 2001:0db8::1")
|
|
'';
|
|
}
|