update networking foo a bit

This commit is contained in:
CherryKitten 2024-06-01 15:19:39 +02:00
parent 49b456a256
commit b2f62f7208
Signed by: sammy
GPG key ID: 98D8F75FB0658276
3 changed files with 44 additions and 23 deletions

View file

@ -30,29 +30,12 @@ in
inputs.home-manager.nixosModules.home-manager
] ++ builtins.attrValues self.nixosModules;
options.cherrykitten = {
primaryIPv4 = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default =
if (config.networking.interfaces ? eth0) then
(builtins.elemAt config.networking.interfaces.eth0.ipv4.addresses 0).address
else null;
};
primaryIPv6 = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default =
if (config.networking.interfaces ? eth0) then
(builtins.elemAt config.networking.interfaces.eth0.ipv6.addresses 0).address
else null;
};
};
config = {
networking.hostName = name;
networking.domain = "cherrykitten.xyz";
deployment = {
allowLocalDeployment = true;
allowLocalDeployment = true;
targetUser = lib.mkDefault "sammy";
tags = [ pkgs.stdenv.hostPlatform.system ];
};

View file

@ -1,4 +1,4 @@
{ lib, ... }: {
{ lib, config, ... }: {
imports = [
./gotosocial.nix
../../profiles/hcloud
@ -6,6 +6,12 @@
];
fileSystems."/" = { device = "/dev/sda1"; fsType = "ext4"; };
cherrykitten.backups.enable = true;
cherrykitten.network = {
public_IPv4 = "128.140.109.125";
public_IPv6 = "2a01:4f8:c2c:bd32::1";
internal_IPv4 = "10.69.0.5";
internal_IPv6 = "fe80::9400:3ff:fe24:677a";
};
networking = {
nameservers = [
@ -21,16 +27,22 @@
interfaces = {
eth0 = {
ipv4.addresses = [
{ address = "128.140.109.125"; prefixLength = 32; }
{ address = config.cherrykitten.network.public_IPv4; prefixLength = 32; }
];
ipv6.addresses = [
{ address = "2a01:4f8:c2c:bd32::1"; prefixLength = 64; }
{ address = "fe80::9400:3ff:fe24:677a"; prefixLength = 64; }
{ address = config.cherrykitten.network.public_IPv6; prefixLength = 64; }
];
ipv4.routes = [{ address = "172.31.1.1"; prefixLength = 32; }];
ipv6.routes = [{ address = "fe80::1"; prefixLength = 128; }];
};
eth1 = {
ipv4.addresses = [
{ address = config.cherrykitten.network.internal_IPv4; prefixLength = 32; }
];
ipv6.addresses = [
{ address = config.cherrykitten.network.internal_IPv6; prefixLength = 64; }
];
};
};
};
services.udev.extraRules = ''

View file

@ -0,0 +1,26 @@
{ config, lib, ... }:
let
cfg = config.cherrykitten;
in
{
options.cherrykitten = {
network = {
public_IPv4 = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
};
public_IPv6 = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
};
internal_IPv4 = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
};
internal_IPv6 = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
};
};
};
}