Files
nixpkgs/nixos/tests/ifstate/initrd.nix
NAHO a2ed7e8d88 nixos: remove optional builtins prefixes from prelude functions
Remove optional builtins prefixes from prelude functions by running:

    builtins=(
      abort
      baseNameOf
      break
      derivation
      derivationStrict
      dirOf
      false
      fetchGit
      fetchMercurial
      fetchTarball
      fetchTree
      fromTOML
      import
      isNull
      map
      null
      placeholder
      removeAttrs
      scopedImport
      throw
      toString
      true
    )

    fd \
      --exclude doc/manual/release-notes \
      --type file \
      . \
      nixos \
      --exec-batch sed --in-place --regexp-extended "
        s/\<builtins\.($(
          printf '%s\n' "${builtins[@]}" |
            paste --delimiter '|' --serial -
        ))\>/\1/g
      "

    nix fmt
2026-01-15 16:07:55 +01:00

70 lines
1.5 KiB
Nix

let
mkIfStateConfig = id: {
enable = true;
settings.interfaces.eth1 = {
addresses = [ "2001:0db8::${toString id}/64" ];
link = {
state = "up";
kind = "physical";
};
};
};
in
{
name = "ifstate-initrd";
nodes = {
server = {
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 = {
# otherwise the interfaces do not get created
kernelModules = [ "virtio_net" ];
network = {
enable = true;
ifstate = mkIfStateConfig 1 // {
allowIfstateToDrasticlyIncreaseInitrdSize = true;
};
};
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")
'';
}