diff --git a/flake.lock b/flake.lock index f74a156..e7021b0 100644 --- a/flake.lock +++ b/flake.lock @@ -105,6 +105,27 @@ "url": "https://git.clan.lol/clan/data-mesher/archive/main.tar.gz" } }, + "devshell": { + "inputs": { + "nixpkgs": [ + "nix-topology", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1728330715, + "narHash": "sha256-xRJ2nPOXb//u1jaBnDP56M7v5ldavjbtR6lfGqSvcKg=", + "owner": "numtide", + "repo": "devshell", + "rev": "dd6b80932022cea34a019e2bb32f6fa9e494dfef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, "disko": { "inputs": { "nixpkgs": [ @@ -146,6 +167,22 @@ "type": "github" } }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -188,6 +225,46 @@ "type": "github" } }, + "flake-utils_2": { + "inputs": { + "systems": "systems_4" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "nix-topology", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "gvc": { "flake": false, "locked": { @@ -317,6 +394,29 @@ "url": "https://git.clan.lol/clan/nix-select/archive/main.tar.gz" } }, + "nix-topology": { + "inputs": { + "devshell": "devshell", + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ], + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1744142264, + "narHash": "sha256-h5KyodobZm8dx/HSNN+basgdmjxrQxudjrss4gAQpZk=", + "owner": "oddlama", + "repo": "nix-topology", + "rev": "f49121cbbf4a86c560638ade406d99ee58deb7aa", + "type": "github" + }, + "original": { + "owner": "oddlama", + "repo": "nix-topology", + "type": "github" + } + }, "nixlib": { "locked": { "lastModified": 1736643958, @@ -414,6 +514,33 @@ "type": "github" } }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nix-topology", + "nixpkgs" + ], + "nixpkgs-stable": [ + "nix-topology", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1730797577, + "narHash": "sha256-SrID5yVpyUfknUTGWgYkTyvdr9J1LxUym4om3SVGPkg=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "1864030ed24a2b8b4e4d386a5eeaf0c5369e50a9", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { "agenix": "agenix", @@ -422,6 +549,7 @@ "home-manager": "home-manager_2", "ignis": "ignis", "impermanence": "impermanence", + "nix-topology": "nix-topology", "nixos-generators": "nixos-generators", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs_2" @@ -493,6 +621,21 @@ "type": "github" } }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": [ diff --git a/flake.nix b/flake.nix index 9b4ff19..aec3202 100644 --- a/flake.nix +++ b/flake.nix @@ -92,6 +92,29 @@ }; } ); + + topology = + nixpkgs.lib.genAttrs + [ + "x86_64-linux" + "aarch64-linux" + ] + ( + system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ inputs.nix-topology.overlays.default ]; + }; + in + import inputs.nix-topology { + inherit pkgs; + modules = [ + { inherit (self) nixosConfigurations; } + ./topology.nix + ]; + } + ); }; inputs = { @@ -127,6 +150,10 @@ url = "github:linkfrg/ignis"; inputs.nixpkgs.follows = "nixpkgs"; }; + nix-topology = { + url = "github:oddlama/nix-topology"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; nixConfig = { diff --git a/machines/crocus/configuration.nix b/machines/crocus/configuration.nix index 39e52d0..49f1674 100644 --- a/machines/crocus/configuration.nix +++ b/machines/crocus/configuration.nix @@ -12,6 +12,7 @@ inputs.clan-core.clanModules.state-version ../../modules/remote-builder.nix ../../modules/borgbackup.nix + ./topology.nix ]; nixpkgs.hostPlatform = "x86_64-linux"; diff --git a/machines/crocus/topology.nix b/machines/crocus/topology.nix new file mode 100644 index 0000000..d658870 --- /dev/null +++ b/machines/crocus/topology.nix @@ -0,0 +1,11 @@ +{ + topology.self = { + hardware.info = "x86_64 VPS"; + interfaces = { + tailscale0 = { + type = "wireguard"; + network = "tailscale"; + }; + }; + }; +} diff --git a/machines/genepi/configuration.nix b/machines/genepi/configuration.nix index d373c90..5831449 100644 --- a/machines/genepi/configuration.nix +++ b/machines/genepi/configuration.nix @@ -19,6 +19,7 @@ ./nginx.nix ./syncthing.nix ./taskchampion.nix + ./topology.nix ../../system ../../modules/borgbackup.nix diff --git a/machines/genepi/topology.nix b/machines/genepi/topology.nix new file mode 100644 index 0000000..184608a --- /dev/null +++ b/machines/genepi/topology.nix @@ -0,0 +1,24 @@ +{ config, ... }: +let + inherit (config.lib.topology) + mkConnection + ; +in +{ + topology.self = { + hardware.info = "Raspberry Pi 4B"; + interfaces = { + tailscale0 = { + type = "wireguard"; + network = "tailscale"; + }; + enp1s0 = { + type = "ethernet"; + network = "home"; + physicalConnections = [ + (mkConnection "cassoulet" "eth1") + ]; + }; + }; + }; +} diff --git a/machines/haze/configuration.nix b/machines/haze/configuration.nix index d0b43f8..64ed0a1 100644 --- a/machines/haze/configuration.nix +++ b/machines/haze/configuration.nix @@ -18,6 +18,7 @@ ./thunderbird.nix ./network.nix ./syncthing.nix + ./topology.nix ./video.nix ../../system diff --git a/machines/haze/topology.nix b/machines/haze/topology.nix new file mode 100644 index 0000000..8a2990a --- /dev/null +++ b/machines/haze/topology.nix @@ -0,0 +1,12 @@ +{ + topology.self = { + hardware.info = "VivoBook Laptop"; + interfaces = { + tailscale0 = { + type = "wireguard"; + network = "tailscale"; + virtual = true; + }; + }; + }; +} diff --git a/system/network/default.nix b/system/network/default.nix index 1f59251..3f791d2 100644 --- a/system/network/default.nix +++ b/system/network/default.nix @@ -1,5 +1,7 @@ +{ inputs, ... }: { imports = [ + inputs.nix-topology.nixosModules.default ./tailscale.nix ]; } diff --git a/topology.nix b/topology.nix new file mode 100644 index 0000000..bd2d18b --- /dev/null +++ b/topology.nix @@ -0,0 +1,40 @@ +{ config, ... }: +let + inherit (config.lib.topology) + mkConnection + mkInternet + mkRouter + ; +in +{ + nodes.internet = mkInternet { + connections = [ + (mkConnection "cassoulet" "wan1") + (mkConnection "crocus" "enp1s0") + ]; + }; + + nodes.cassoulet = mkRouter "Cassoulet" { + info = "BBox Fibre"; + interfaceGroups = [ + [ "wan1" ] + [ + "eth1" + "eth2" + "eth3" + "eth4" + ] + ]; + }; + + networks.home = { + name = "Home Network"; + cidrv4 = "192.168.1.1/24"; + }; + + networks.tailscale = { + name = "Tailscale"; + cidrv4 = "100.100.181.10/32"; + cidrv6 = "fd7a:115c:a1e0::2401:b50a/128"; + }; +}