No description
Find a file
2025-09-29 09:07:24 +02:00
checks checks/ping: use docs prefix 2025-08-18 20:39:54 +02:00
.gitignore Initial Commit 2024-01-17 07:41:48 +01:00
flake.lock flake.lock: Update 2025-09-29 08:43:58 +02:00
flake.nix nix: update to nixos 25.05 2025-07-01 22:38:09 +02:00
LICENSE Initial Commit 2024-01-17 07:41:48 +01:00
module.nix nix: disable upstream ifstate module 2025-07-30 08:30:11 +02:00
package.nix ifstate: 1.13.8 -> 1.13.9 2025-09-29 09:07:24 +02:00
README.md checks: init ping 2024-10-20 15:06:25 +02:00

IfState.nix

Nix Module for IfState.

Usage

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
    ifstate = {
      url = "git+https://codeberg.org/m4rc3l/ifstate.nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, ifstate, ... }: {
    nixosConfigurations = {
      hostname = nixpkgs.lib.nixosSystem {
        modules = [
          ifstate.nixosModules.default
        ];
      };
    };
  };
}

Example interface configuration. See the Json Schema for deails.

networking.ifstate = {
  enable = true;
  settings = {
    interfaces = [{
      name = "eth0";
      addresses = [ "10.44.1.2/24" "fd44:1::2/64" ];
      link = {
        state = "up";
        kind = "physical";
        address = "2e:28:00:60:c2:1b";
      };
    }];
    routing.routes = [
      { to = "0.0.0.0/0"; via = "10.44.1.1"; }
      { to = "fd44::/16"; via = "fd44:1::1"; }
    ];
  };
};

initrd

  • Don't forget to configure the necessary networking kernel modules.
  • IfState in initrd has colored output and WireGuard support disabled by default. Use networking.ifstate.initrd.package to modify this behavior.
networking.ifstate = {
  # ifstate automatly reuses the configuration declared above
  initrd.enable = true;
  # use different configuration in initrd
  # initrd.settings = { ... };
};

boot.initrd.network = {
  # needed, otherwiese ssh.enable gets ignored
  enable = true;
  
  # configure ssh daemon for initrd
  ssh = {
    enable = true;
    hostKeys = [ /etc/ssh/ssh_host_ed25519_key ];
    authorizedKeys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK255EY8KUx5cMXSuoERXJSzVnkDUM+y8sMAVrRoDBnn marcel" ];
  };

  # example for zfs remote decryption
  postCommands = ''
    zpool import -a
    echo "zfs load-key -a; killall zfs" >> /root/.profile
  '';
};