diff --git a/flake.nix b/flake.nix index ed2f36e..e502406 100644 --- a/flake.nix +++ b/flake.nix @@ -20,8 +20,15 @@ in { nixosConfigurations = { - tailscale-proxy = kclib.mkHost "tailscale-proxy" "x86_64-linux"; - entrypoint = kclib.mkHost "entrypoint" "x86_64-linux"; + tailscale-proxy = kclib.mkHost { + name = "tailscale-proxy"; + }; + entrypoint = kclib.mkHost { + name = "entrypoint"; + }; + hydra = kclib.mkHost { + name = "hydra"; + }; }; formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style; }; diff --git a/hosts/hydra.nix b/hosts/hydra.nix new file mode 100644 index 0000000..20a8624 --- /dev/null +++ b/hosts/hydra.nix @@ -0,0 +1,12 @@ +{ ... }: +{ + kropcloud = { + networking = { + ipv4 = { + enable = true; + address = "192.168.1.160"; + prefixLength = 24; + }; + }; + }; +} diff --git a/lib.nix b/lib.nix index f45f642..671253d 100644 --- a/lib.nix +++ b/lib.nix @@ -4,7 +4,10 @@ }: { mkHost = - name: arch: + { + name, + arch ? "x86_64-linux", + }: nixpkgs.lib.nixosSystem { system = arch; modules = [ diff --git a/nixosModules/networking/default.nix b/nixosModules/networking/default.nix index cf6ae06..e589863 100644 --- a/nixosModules/networking/default.nix +++ b/nixosModules/networking/default.nix @@ -14,13 +14,50 @@ in default = true; example = false; }; + # TODO: fix this madness + ipv4 = { + enable = lib.mkEnableOption "Whence to enable IPv4 configuration"; + address = lib.mkOption { + type = lib.types.nullOr lib.types.str; + description = "The server IPv4 address"; + example = "192.168.1.155"; + default = null; + }; + prefixLength = lib.mkOption { + type = lib.types.int; + description = "The server IPv4 address prefix length"; + default = 24; + example = 24; + }; + }; }; config = lib.mkIf cfg.enable { + + assertions = [ + { + assertion = !(cfg.ipv4.enable && (cfg.ipv4.address == null || cfg.ipv4.address == "" || cfg.ipv4.prefixLength == null)); + message = '' + You need to provide valid values for both `address` and `prefixLength` in `kropcloud.networking.ipv4` + when `kropcloud.networking.ipv4.enable` is true. + ''; + } + ]; + networking = { nftables.enable = true; firewall = { checkReversePath = "loose"; }; + interfaces = { + ens18 = { + ipv4.addresses = lib.mkIf cfg.ipv4.enable [ + { + address = cfg.ipv4.address; + prefixLength = cfg.ipv4.prefixLength; + } + ]; + }; + }; }; }; }