Update ivabus-dev.nix and router.nix

This commit is contained in:
Ivan Bushchik 2023-10-22 08:59:33 +03:00
parent 0661a15294
commit 2afc93ad94
No known key found for this signature in database
GPG key ID: 2F16FBF3262E090C
2 changed files with 33 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{ pkgs ? import <nixpkgs> { }, bundlerEnv, ... }: { pkgs ? import <nixpkgs> { }, bundlerEnv, ... }:
let let
version = "8a9a1364bc2111ea4889134f8ca18f10699f26ef"; version = "79511faa094e7447aa1179b87a4d4687440b18f6";
repo = builtins.fetchGit { repo = builtins.fetchGit {
url = "https://github.com/ivabus/website"; url = "https://github.com/ivabus/website";
rev = version; rev = version;

View file

@ -1,6 +1,11 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let cfg = config.my.roles.router; let
cfg = config.my.roles.router;
ipv6_subnet = "2a05:3580:e41a:d600";
ipv6_prefix = 64;
ipv4_subnet = "192.168";
ipv4_prefix = 24;
in { in {
options.my.roles.router.enable = options.my.roles.router.enable =
lib.mkEnableOption "Enable router capabilities"; lib.mkEnableOption "Enable router capabilities";
@ -19,6 +24,13 @@ in {
LAN interface name. LAN interface name.
''; '';
}; };
options.my.roles.router.addresses.ipv4.subnet = lib.mkOption {
type = lib.types.str;
default = "192.168";
description = ''
IPv4 subnet to allocate (currently only with /24 mask)
'';
};
config = lib.mkIf (cfg.enable) { config = lib.mkIf (cfg.enable) {
boot.kernel.sysctl = lib.mkForce { boot.kernel.sysctl = lib.mkForce {
@ -57,12 +69,30 @@ in {
''; '';
}; };
}; };
networking = { networking = {
useNetworkd = false;
useDHCP = false;
interfaces = {
"${cfg.interfaces.lan}" = {
ipv4.addresses = [
{
address = "${ipv4_subnet}.0.1";
prefixLength = 24;
}
{
address = "${ipv4_subnet}.1.1";
prefixLength = 24;
}
];
};
"${cfg.interfaces.wan}".useDHCP = true;
};
nat = { nat = {
enable = true; enable = true;
externalInterface = "${cfg.interfaces.wan}"; externalInterface = "${cfg.interfaces.wan}";
internalInterfaces = [ "${cfg.interfaces.lan}" ]; internalInterfaces = [ "${cfg.interfaces.lan}" ];
internalIPs = [ "192.168.0.0/24" "192.168.1.0" /24 ]; internalIPs = [ "192.168.0.0/24" "192.168.1.0/24" ];
}; };
}; };
}; };