Compare commits
5 Commits
84e196cea0
...
router/hom
| Author | SHA1 | Date | |
|---|---|---|---|
|
4a007aeaa9
|
|||
|
15dc8dd7c4
|
|||
|
2bd88d7a93
|
|||
|
5ec716919d
|
|||
|
47c9cff8f5
|
12
flake.lock
generated
12
flake.lock
generated
@@ -7,11 +7,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1749178927,
|
"lastModified": 1750650909,
|
||||||
"narHash": "sha256-bXcEx1aZUNm5hMLVJeuofcOrZyOiapzvQ7K36HYK3YQ=",
|
"narHash": "sha256-HRNJuqo15PRKezyBjhNf2Tjj05EcSJ8q6xJyDDbmDXE=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "91287a0e9d42570754487b7e38c6697e15a9aab2",
|
"rev": "520fc4b50af1b365014c3748c126d3f52edb2f3b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -58,11 +58,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1748929857,
|
"lastModified": 1750506804,
|
||||||
"narHash": "sha256-lcZQ8RhsmhsK8u7LIFsJhsLh/pzR9yZ8yqpTzyGdj+Q=",
|
"narHash": "sha256-VLFNc4egNjovYVxDGyBYTrvVCgDYgENp5bVi9fPTDYc=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "c2a03962b8e24e669fb37b7df10e7c79531ff1a4",
|
"rev": "4206c4cb56751df534751b058295ea61357bbbaa",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
27
flake.nix
27
flake.nix
@@ -37,6 +37,19 @@
|
|||||||
# Optionally, use home-manager.extraSpecialArgs to pass
|
# Optionally, use home-manager.extraSpecialArgs to pass
|
||||||
# arguments to home.nix
|
# arguments to home.nix
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mkRouter = hostFile: nixpkgs.lib.nixosSystem {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
modules = [
|
||||||
|
secrix.nixosModules.default
|
||||||
|
./modules
|
||||||
|
./modules/router
|
||||||
|
./hosts/common.nix
|
||||||
|
hostFile
|
||||||
|
./users/cazzzer
|
||||||
|
(hmModule ./home/common.nix)
|
||||||
|
];
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
apps.x86_64-linux.secrix = secrix.secrix self;
|
apps.x86_64-linux.secrix = secrix.secrix self;
|
||||||
@@ -77,17 +90,9 @@
|
|||||||
(hmModule ./home/cazzzer-pc.nix)
|
(hmModule ./home/cazzzer-pc.nix)
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
router = nixpkgs.lib.nixosSystem {
|
router = mkRouter ./hosts/router;
|
||||||
system = "x86_64-linux";
|
router-1 = mkRouter ./hosts/router-1;
|
||||||
modules = [
|
router-2 = mkRouter ./hosts/router-2;
|
||||||
secrix.nixosModules.default
|
|
||||||
./modules
|
|
||||||
./hosts/common.nix
|
|
||||||
./hosts/router
|
|
||||||
./users/cazzzer
|
|
||||||
(hmModule ./home/common.nix)
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
# https://github.com/nix-community/nixos-generators?tab=readme-ov-file#using-in-a-flake
|
# https://github.com/nix-community/nixos-generators?tab=readme-ov-file#using-in-a-flake
|
||||||
packages.x86_64-linux = {
|
packages.x86_64-linux = {
|
||||||
|
|||||||
24
hosts/router-1/default.nix
Normal file
24
hosts/router-1/default.nix
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
imports = [
|
||||||
|
../hw-vm.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
router = {
|
||||||
|
enableDesktop = false;
|
||||||
|
enableDhcpClient = false;
|
||||||
|
wanMAC = "bc:24:11:af:bd:84";
|
||||||
|
lanMAC = "bc:24:11:38:b1:91";
|
||||||
|
wanLL = "fe80::be24:11ff:feaf:bd84";
|
||||||
|
lanLL = "fe80::be24:11ff:fe38:b191";
|
||||||
|
defaultToken = 251;
|
||||||
|
|
||||||
|
pdFromWan = "fd46:fbbe:ca55:100";
|
||||||
|
wanAddr4 = "192.168.1.63";
|
||||||
|
wanGw4 = "192.168.1.254";
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.hostName = "grouty";
|
||||||
|
|
||||||
|
# override hw-vm.nix default
|
||||||
|
networking.useDHCP = false;
|
||||||
|
}
|
||||||
24
hosts/router-2/default.nix
Normal file
24
hosts/router-2/default.nix
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
imports = [
|
||||||
|
../hw-vm.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
router = {
|
||||||
|
enableDesktop = false;
|
||||||
|
enableDhcpClient = false;
|
||||||
|
wanMAC = "bc:24:11:bc:db:c1";
|
||||||
|
lanMAC = "bc:24:11:19:2a:96";
|
||||||
|
wanLL = "fe80::be24:11ff:febc:dbc1";
|
||||||
|
lanLL = "fe80::be24:11ff:fe19:2a96";
|
||||||
|
defaultToken = 252;
|
||||||
|
|
||||||
|
pdFromWan = "fd46:fbbe:ca55:100";
|
||||||
|
wanAddr4 = "192.168.1.64";
|
||||||
|
wanGw4 = "192.168.1.254";
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.hostName = "grouta";
|
||||||
|
|
||||||
|
# override hw-vm.nix default
|
||||||
|
networking.useDHCP = false;
|
||||||
|
}
|
||||||
@@ -1,16 +1,18 @@
|
|||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../../modules/router
|
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
./private.nix
|
./private.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
router = {
|
router = {
|
||||||
enableDesktop = false;
|
enableDesktop = false;
|
||||||
|
enableDhcpClient = true;
|
||||||
wanMAC = "bc:24:11:4f:c9:c4";
|
wanMAC = "bc:24:11:4f:c9:c4";
|
||||||
lanMAC = "bc:24:11:83:d8:de";
|
lanMAC = "bc:24:11:83:d8:de";
|
||||||
wanLL = "fe80::be24:11ff:fe4f:c9c4";
|
wanLL = "fe80::be24:11ff:fe4f:c9c4";
|
||||||
lanLL = "fe80::be24:11ff:fe83:d8de";
|
lanLL = "fe80::be24:11ff:fe83:d8de";
|
||||||
defaultToken = 1;
|
defaultToken = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
networking.hostName = "grouter";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ in
|
|||||||
boot.kernelPackages = pkgs.linuxKernel.packages.linux_6_12;
|
boot.kernelPackages = pkgs.linuxKernel.packages.linux_6_12;
|
||||||
boot.growPartition = true;
|
boot.growPartition = true;
|
||||||
|
|
||||||
networking.hostName = "grouter";
|
|
||||||
|
|
||||||
# Enable the X11 windowing system.
|
# Enable the X11 windowing system.
|
||||||
# You can disable this if you're only using the Wayland session.
|
# You can disable this if you're only using the Wayland session.
|
||||||
services.xserver.enable = false;
|
services.xserver.enable = false;
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ in
|
|||||||
"|etappi.${sysdomain}^$dnsrewrite=${ifs.lan.p4}.12"
|
"|etappi.${sysdomain}^$dnsrewrite=${ifs.lan.p4}.12"
|
||||||
"|etappi.${sysdomain}^$dnsrewrite=${ifs.lan.ulaPrefix}::12:1"
|
"|etappi.${sysdomain}^$dnsrewrite=${ifs.lan.ulaPrefix}::12:1"
|
||||||
|
|
||||||
|
"|hass.${domain}^$dnsrewrite=${ifs.lan.ulaAddr}"
|
||||||
|
|
||||||
# Lab DNS rewrites
|
# Lab DNS rewrites
|
||||||
"||lab.${domain}^$dnsrewrite=etappi.${sysdomain}"
|
"||lab.${domain}^$dnsrewrite=etappi.${sysdomain}"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
let
|
let
|
||||||
|
cfg = config.router;
|
||||||
vars = import ./vars.nix config;
|
vars = import ./vars.nix config;
|
||||||
links = vars.links;
|
links = vars.links;
|
||||||
ifs = vars.ifs;
|
ifs = vars.ifs;
|
||||||
@@ -57,7 +58,7 @@ in
|
|||||||
# https://github.com/systemd/systemd/issues/22571
|
# https://github.com/systemd/systemd/issues/22571
|
||||||
# https://github.com/systemd/systemd/issues/22571#issuecomment-2094905496
|
# https://github.com/systemd/systemd/issues/22571#issuecomment-2094905496
|
||||||
# https://gist.github.com/csamsel/0f8cca3b2e64d7e4cc47819ec5ba9396
|
# https://gist.github.com/csamsel/0f8cca3b2e64d7e4cc47819ec5ba9396
|
||||||
networking.dhcpcd.enable = true;
|
networking.dhcpcd.enable = cfg.enableDhcpClient;
|
||||||
networking.dhcpcd.allowInterfaces = [ ifs.wan.name ];
|
networking.dhcpcd.allowInterfaces = [ ifs.wan.name ];
|
||||||
networking.dhcpcd.extraConfig = ''
|
networking.dhcpcd.extraConfig = ''
|
||||||
debug
|
debug
|
||||||
|
|||||||
@@ -8,30 +8,36 @@ with lib;
|
|||||||
enableDesktop = mkOption {
|
enableDesktop = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "Enable desktop environment";
|
description = "Enable desktop environment for debugging";
|
||||||
|
};
|
||||||
|
|
||||||
|
enableDhcpClient = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Enable DHCP client (should only be set on the main router)";
|
||||||
};
|
};
|
||||||
|
|
||||||
wanMAC = mkOption {
|
wanMAC = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "bc:24:11:4f:c9:c4";
|
example = "bc:24:11:4f:c9:c4";
|
||||||
description = "WAN interface MAC address";
|
description = "WAN interface MAC address";
|
||||||
};
|
};
|
||||||
|
|
||||||
lanMAC = mkOption {
|
lanMAC = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "bc:24:11:83:d8:de";
|
example = "bc:24:11:83:d8:de";
|
||||||
description = "LAN interface MAC address";
|
description = "LAN interface MAC address";
|
||||||
};
|
};
|
||||||
|
|
||||||
wanLL = mkOption {
|
wanLL = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "fe80::be24:11ff:fe4f:c9c4";
|
example = "fe80::be24:11ff:fe4f:c9c4";
|
||||||
description = "WAN IPv6 link-local address";
|
description = "WAN IPv6 link-local address";
|
||||||
};
|
};
|
||||||
|
|
||||||
lanLL = mkOption {
|
lanLL = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "fe80::be24:11ff:fe83:d8de";
|
example = "fe80::be24:11ff:fe83:d8de";
|
||||||
description = "LAN IPv6 link-local address";
|
description = "LAN IPv6 link-local address";
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -43,17 +49,20 @@ with lib;
|
|||||||
|
|
||||||
wanAddr4 = mkOption {
|
wanAddr4 = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
|
example = "192.168.1.61";
|
||||||
description = "WAN IPv4 address";
|
description = "WAN IPv4 address";
|
||||||
};
|
};
|
||||||
|
|
||||||
wanGw4 = mkOption {
|
wanGw4 = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
|
example = "192.168.1.254";
|
||||||
description = "WAN IPv4 gateway";
|
description = "WAN IPv4 gateway";
|
||||||
};
|
};
|
||||||
|
|
||||||
pdFromWan = mkOption {
|
pdFromWan = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
description = "IPv6 prefix delegation from WAN";
|
example = "2001:db8:0:000";
|
||||||
|
description = "IPv6 prefix delegation from ISP (/60)";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -58,27 +58,36 @@ in
|
|||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.caddy.withPlugins {
|
package = pkgs.caddy.withPlugins {
|
||||||
plugins = [ "github.com/caddy-dns/cloudflare@v0.2.1" ];
|
plugins = [ "github.com/caddy-dns/cloudflare@v0.2.1" ];
|
||||||
hash = "sha256-Gsuo+ripJSgKSYOM9/yl6Kt/6BFCA6BuTDvPdteinAI=";
|
hash = "sha256-2D7dnG50CwtCho+U+iHmSj2w14zllQXPjmTHr6lJZ/A=";
|
||||||
};
|
};
|
||||||
virtualHosts."grouter.${domain}".extraConfig = ''
|
virtualHosts."*.${domain}".extraConfig = ''
|
||||||
encode
|
encode
|
||||||
tls {
|
tls {
|
||||||
dns cloudflare {env.CF_API_KEY}
|
dns cloudflare {env.CF_API_KEY}
|
||||||
resolvers 1.1.1.1
|
resolvers 1.1.1.1
|
||||||
}
|
}
|
||||||
@grafana path /grafana /grafana/*
|
|
||||||
handle @grafana {
|
@grouter host grouter.${domain}
|
||||||
reverse_proxy localhost:${toString config.services.grafana.settings.server.http_port}
|
handle @grouter {
|
||||||
}
|
@grafana path /grafana /grafana/*
|
||||||
redir /adghome /adghome/
|
handle @grafana {
|
||||||
handle_path /adghome/* {
|
reverse_proxy localhost:${toString config.services.grafana.settings.server.http_port}
|
||||||
reverse_proxy localhost:${toString config.services.adguardhome.port}
|
}
|
||||||
basic_auth {
|
redir /adghome /adghome/
|
||||||
Bob $2a$14$HsWmmzQTN68K3vwiRAfiUuqIjKoXEXaj9TOLUtG2mO1vFpdovmyBy
|
handle_path /adghome/* {
|
||||||
|
reverse_proxy localhost:${toString config.services.adguardhome.port}
|
||||||
|
basic_auth {
|
||||||
|
Bob $2a$14$HsWmmzQTN68K3vwiRAfiUuqIjKoXEXaj9TOLUtG2mO1vFpdovmyBy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handle /* {
|
||||||
|
reverse_proxy localhost:${toString config.services.glance.settings.server.port}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handle /* {
|
|
||||||
reverse_proxy localhost:${toString config.services.glance.settings.server.port}
|
@hass host hass.${domain}
|
||||||
|
handle @hass {
|
||||||
|
reverse_proxy homeassistant.4.lab.l.cazzzer.com:8123
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ rec {
|
|||||||
p4_ = "${p4}.20"; # .0/24
|
p4_ = "${p4}.20"; # .0/24
|
||||||
p6_ = "${pdFromWan}0"; # ::/64 managed by Att box
|
p6_ = "${pdFromWan}0"; # ::/64 managed by Att box
|
||||||
ulaPrefix_ = "${ulaPrefix}:0020"; # ::/64
|
ulaPrefix_ = "${ulaPrefix}:0020"; # ::/64
|
||||||
ip6Token_ = "::1:1"; # override ipv6 for lan20, since the Att box uses ::1 here
|
ip6Token_ = "::1:${toString cfg.defaultToken}"; # override ipv6 for lan20, since the Att box uses ::1 here
|
||||||
};
|
};
|
||||||
lan30 = mkIfConfig {
|
lan30 = mkIfConfig {
|
||||||
name_ = "${lan.name}.30";
|
name_ = "${lan.name}.30";
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
description = "Yura";
|
description = "Yura";
|
||||||
group = "cazzzer";
|
group = "cazzzer";
|
||||||
extraGroups = [ "wheel" ]
|
extraGroups = [ "wheel" "dialout" ]
|
||||||
++ lib.optionals config.networking.networkmanager.enable [ "networkmanager" ]
|
++ lib.optionals config.networking.networkmanager.enable [ "networkmanager" ]
|
||||||
++ lib.optionals config.virtualisation.docker.enable [ "docker" ]
|
++ lib.optionals config.virtualisation.docker.enable [ "docker" ]
|
||||||
++ lib.optionals config.programs.wireshark.enable [ "wireshark" ]
|
++ lib.optionals config.programs.wireshark.enable [ "wireshark" ]
|
||||||
|
|||||||
Reference in New Issue
Block a user