From 9a81d570bbcdf02b3a1e39a17b5d1882b3d75526 Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Thu, 18 Jul 2024 06:03:14 +0200 Subject: [PATCH] topology: init with placeholder values --- flake.lock | 419 ++++++++++++++++++++++++++++++++++++++------------- flake.nix | 17 +++ topology.nix | 120 +++++++++++++++ 3 files changed, 449 insertions(+), 107 deletions(-) create mode 100644 topology.nix diff --git a/flake.lock b/flake.lock index 126bb78..eda9185 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,27 @@ { "nodes": { + "devshell": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nix-topology", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1713532798, + "narHash": "sha256-wtBhsdMJA3Wa32Wtm1eeo84GejtI43pMrFrmwLXrsEc=", + "owner": "numtide", + "repo": "devshell", + "rev": "12e914740a25ea1891ec619bb53cf5e6ca922e40", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, "disko": { "inputs": { "nixpkgs": [ @@ -7,11 +29,11 @@ ] }, "locked": { - "lastModified": 1741786315, - "narHash": "sha256-VT65AE2syHVj6v/DGB496bqBnu1PXrrzwlw07/Zpllc=", + "lastModified": 1715445235, + "narHash": "sha256-SUu+oIWn+xqQIOlwfwNfS9Sek4i1HKsrLJchsDReXwA=", "owner": "nix-community", "repo": "disko", - "rev": "0d8c6ad4a43906d14abd5c60e0ffe7b587b213de", + "rev": "159d87ea5b95bbdea46f0288a33c5e1570272725", "type": "github" }, "original": { @@ -20,45 +42,138 @@ "type": "github" } }, - "gergle": { + "fix-python": { "inputs": { + "flake-utils": "flake-utils", "nixpkgs": [ + "grzegorz", "nixpkgs" ] }, "locked": { - "lastModified": 1736621371, - "narHash": "sha256-45UIQSQA7R5iU4YWvilo7mQbhY1Liql9bHBvYa3qRI0=", - "ref": "refs/heads/main", - "rev": "3729796c1213fe76e568ac28f1df8de4e596950b", - "revCount": 20, - "type": "git", - "url": "https://git.pvv.ntnu.no/Grzegorz/gergle.git" + "lastModified": 1713887124, + "narHash": "sha256-hGTSm0p9xXUYDgsAAr/ORZICo6T6u33vLfX3tILikaQ=", + "owner": "GuillaumeDesforges", + "repo": "fix-python", + "rev": "f7f4b33e22414071fc1f9cbf68072c413c3a7fdf", + "type": "github" }, "original": { - "type": "git", - "url": "https://git.pvv.ntnu.no/Grzegorz/gergle.git" + "owner": "GuillaumeDesforges", + "repo": "fix-python", + "type": "github" } }, - "greg-ng": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ], - "rust-overlay": "rust-overlay" - }, + "flake-compat": { + "flake": false, "locked": { - "lastModified": 1736545379, - "narHash": "sha256-PeTTmGumdOX3rd6OKI7QMCrZovCDkrckZbcHr+znxWA=", - "ref": "refs/heads/main", - "rev": "74f5316121776db2769385927ec0d0c2cc2b23e4", - "revCount": 42, - "type": "git", - "url": "https://git.pvv.ntnu.no/Grzegorz/greg-ng.git" + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" }, "original": { - "type": "git", - "url": "https://git.pvv.ntnu.no/Grzegorz/greg-ng.git" + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "id": "flake-utils", + "type": "indirect" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "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" + } + }, + "grzegorz": { + "inputs": { + "fix-python": "fix-python", + "nixpkgs": [ + "nixpkgs-unstable" + ] + }, + "locked": { + "lastModified": 1715364232, + "narHash": "sha256-ZJC3SkanEgbV7p+LFhP+85CviRWOXJNHzZwR/Stb7hE=", + "owner": "Programvareverkstedet", + "repo": "grzegorz", + "rev": "3841cda1cdcac470440b06838d56a2eb2256378c", + "type": "github" + }, + "original": { + "owner": "Programvareverkstedet", + "repo": "grzegorz", + "type": "github" } }, "grzegorz-clients": { @@ -68,17 +183,17 @@ ] }, "locked": { - "lastModified": 1736178795, - "narHash": "sha256-mPdi8cgvIDYcgG3FRG7A4BOIMu2Jef96TPMnV00uXlM=", - "ref": "refs/heads/master", - "rev": "fde738910de1fd8293535a6382c2f0c2749dd7c1", - "revCount": 79, - "type": "git", - "url": "https://git.pvv.ntnu.no/Grzegorz/grzegorz-clients.git" + "lastModified": 1715384651, + "narHash": "sha256-7RhckgUTjqeCjWkhiCc1iB+5CBx9fl80d/3O4Jh+5kM=", + "owner": "Programvareverkstedet", + "repo": "grzegorz-clients", + "rev": "738a4f3dd887f7c3612e4e772b83cbfa3cde5693", + "type": "github" }, "original": { - "type": "git", - "url": "https://git.pvv.ntnu.no/Grzegorz/grzegorz-clients.git" + "owner": "Programvareverkstedet", + "repo": "grzegorz-clients", + "type": "github" } }, "matrix-next": { @@ -88,35 +203,20 @@ ] }, "locked": { - "lastModified": 1735857245, - "narHash": "sha256-AKLLPrgXTxgzll3DqVUMa4QlPlRN3QceutgFBmEf8Nk=", + "lastModified": 1717234745, + "narHash": "sha256-MFyKRdw4WQD6V3vRGbP6MYbtJhZp712zwzjW6YiOBYM=", "owner": "dali99", "repo": "nixos-matrix-modules", - "rev": "da9dc0479ffe22362793c87dc089035facf6ec4d", + "rev": "d7dc42c9bbb155c5e4aa2f0985d0df75ce978456", "type": "github" }, "original": { "owner": "dali99", - "ref": "0.7.0", + "ref": "v0.6.0", "repo": "nixos-matrix-modules", "type": "github" } }, - "minecraft-data": { - "locked": { - "lastModified": 1725277886, - "narHash": "sha256-Fw4VbbE3EfypQWSgPDFfvVH47BHeg3ptsO715NlUM8Q=", - "ref": "refs/heads/master", - "rev": "1b4087bd3322a2e2ba84271c8fcc013e6b641a58", - "revCount": 2, - "type": "git", - "url": "https://git.pvv.ntnu.no/Projects/minecraft-kartverket.git" - }, - "original": { - "type": "git", - "url": "https://git.pvv.ntnu.no/Projects/minecraft-kartverket.git" - } - }, "nix-gitea-themes": { "inputs": { "nixpkgs": [ @@ -124,11 +224,11 @@ ] }, "locked": { - "lastModified": 1736531400, - "narHash": "sha256-+X/HVI1AwoPcud28wI35XRrc1kDgkYdDUGABJBAkxDI=", + "lastModified": 1714416973, + "narHash": "sha256-aZUcvXjdETUC6wVQpWDVjLUzwpDAEca8yR0ITDeK39o=", "ref": "refs/heads/main", - "rev": "e4dafd06b3d7e9e6e07617766e9c3743134571b7", - "revCount": 7, + "rev": "2b23c0ba8aae68d3cb6789f0f6e4891cef26cc6d", + "revCount": 6, "type": "git", "url": "https://git.pvv.ntnu.no/oysteikt/nix-gitea-themes.git" }, @@ -137,35 +237,116 @@ "url": "https://git.pvv.ntnu.no/oysteikt/nix-gitea-themes.git" } }, + "nix-topology": { + "inputs": { + "devshell": "devshell", + "flake-utils": "flake-utils_3", + "nixpkgs": [ + "nixpkgs" + ], + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1721160643, + "narHash": "sha256-ZkjJnwgDUkjzgySZv9GjKnDsDmNJVkU2u2pLD4a1QKA=", + "owner": "oddlama", + "repo": "nix-topology", + "rev": "fe9ace7f40a63e3eb9b39a20a1032834e090d806", + "type": "github" + }, + "original": { + "owner": "oddlama", + "repo": "nix-topology", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1741969460, - "narHash": "sha256-SCNxTTBfMJV7XuTcLUfdAd6cgCGsazzi+DoPrceQrZ0=", + "lastModified": 1719520878, + "narHash": "sha256-5BXzNOl2RVHcfS/oxaZDKOi7gVuTyWPibQG0DHd5sSc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "68612419aa6c9fd5b178b81e6fabbdf46d300ea4", + "rev": "a44bedbb48c367f0476e6a3a27bf28f6330faf23", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-24.05-small", + "type": "indirect" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1710695816, + "narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "614b4613980a522ba49f0d194531beddbb7220d3", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-24.11-small", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable_2": { + "locked": { + "lastModified": 1714858427, + "narHash": "sha256-tCxeDP4C1pWe2rYY3IIhdA40Ujz32Ufd4tcrHPSKx2M=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b980b91038fc4b09067ef97bbe5ad07eecca1e76", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-23.11", "repo": "nixpkgs", "type": "github" } }, "nixpkgs-unstable": { "locked": { - "lastModified": 1741960758, - "narHash": "sha256-pSGMbfkxF7TSeco54W+B1q+g22YCVp1qXHgtrdgtyR4=", + "lastModified": 1715435713, + "narHash": "sha256-lb2HqDQGfTdnCCpc1pgF6fkdgIOuBQ0nP8jjVSfLFqg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "845dc1e9cbc2e48640b8968af58b4a19db67aa8f", + "rev": "52b40f6c4be12742b1504ca2eb4527e597bf2526", "type": "github" }, "original": { - "owner": "NixOS", + "id": "nixpkgs", "ref": "nixos-unstable-small", - "repo": "nixpkgs", + "type": "indirect" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": [ + "nix-topology", + "flake-utils" + ], + "gitignore": "gitignore", + "nixpkgs": [ + "nix-topology", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1714478972, + "narHash": "sha256-q//cgb52vv81uOuwz1LaXElp3XAe1TqrABXODAEF6Sk=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "2849da033884f54822af194400f8dff435ada242", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", "type": "github" } }, @@ -176,11 +357,11 @@ ] }, "locked": { - "lastModified": 1723850344, - "narHash": "sha256-aT37O9l9eclWEnqxASVNBL1dKwDHZUOqdbA4VO9DJvw=", + "lastModified": 1693136143, + "narHash": "sha256-amHprjftc3y/bg8yf4hITCLa+ez5HIi0yGfR7TU6UIc=", "ref": "refs/heads/main", - "rev": "38b66677ab8c01aee10cd59e745af9ce3ea88092", - "revCount": 19, + "rev": "a32894b305f042d561500f5799226afd1faf5abb", + "revCount": 9, "type": "git", "url": "https://git.pvv.ntnu.no/Projects/calendar-bot.git" }, @@ -196,11 +377,11 @@ ] }, "locked": { - "lastModified": 1741738148, - "narHash": "sha256-cJo6nbcJEOjkazkZ194NDnlsZe0W0wpxeUh2/886uC8=", - "ref": "refs/heads/main", - "rev": "c1802e7cf27c7cf8b4890354c982a4eef5b11593", - "revCount": 486, + "lastModified": 1718404592, + "narHash": "sha256-Ud8pD0mxmbfvwBXKy2q3Yp8r1EofaTcodZtI3fbnfDY=", + "ref": "refs/heads/master", + "rev": "6e4a79ed3ddae8dfc80eb8af1789985d07bcf297", + "revCount": 463, "type": "git", "url": "https://git.pvv.ntnu.no/Projects/nettsiden.git" }, @@ -212,12 +393,11 @@ "root": { "inputs": { "disko": "disko", - "gergle": "gergle", - "greg-ng": "greg-ng", + "grzegorz": "grzegorz", "grzegorz-clients": "grzegorz-clients", "matrix-next": "matrix-next", - "minecraft-data": "minecraft-data", "nix-gitea-themes": "nix-gitea-themes", + "nix-topology": "nix-topology", "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable", "pvv-calendar-bot": "pvv-calendar-bot", @@ -225,39 +405,19 @@ "sops-nix": "sops-nix" } }, - "rust-overlay": { - "inputs": { - "nixpkgs": [ - "greg-ng", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1729391507, - "narHash": "sha256-as0I9xieJUHf7kiK2a9znDsVZQTFWhM1pLivII43Gi0=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "784981a9feeba406de38c1c9a3decf966d853cca", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, "sops-nix": { "inputs": { "nixpkgs": [ "nixpkgs" - ] + ], + "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1741861888, - "narHash": "sha256-ynOgXAyToeE1UdLNfrUn/hL7MN0OpIS2BtNdLjpjPf0=", + "lastModified": 1715244550, + "narHash": "sha256-ffOZL3eaZz5Y1nQ9muC36wBCWwS1hSRLhUzlA9hV2oI=", "owner": "Mic92", "repo": "sops-nix", - "rev": "d016ce0365b87d848a57c12ffcfdc71da7a2b55f", + "rev": "0dc50257c00ee3c65fef3a255f6564cfbfe6eb7f", "type": "github" }, "original": { @@ -265,6 +425,51 @@ "repo": "sops-nix", "type": "github" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index ed7eaa6..84cfd6f 100644 --- a/flake.nix +++ b/flake.nix @@ -11,6 +11,9 @@ disko.url = "github:nix-community/disko"; disko.inputs.nixpkgs.follows = "nixpkgs"; + nix-topology.url = "github:oddlama/nix-topology"; + nix-topology.inputs.nixpkgs.follows = "nixpkgs"; + pvv-nettsiden.url = "git+https://git.pvv.ntnu.no/Projects/nettsiden.git"; pvv-nettsiden.inputs.nixpkgs.follows = "nixpkgs"; @@ -67,6 +70,7 @@ modules = [ ./hosts/${name}/configuration.nix sops-nix.nixosModules.sops + inputs.nix-topology.nixosModules.default ] ++ config.modules or []; pkgs = import nixpkgs { @@ -178,5 +182,18 @@ // lib.genAttrs allMachines (machine: self.nixosConfigurations.${machine}.config.system.build.toplevel); }; + + topology.x86_64-linux = import inputs.nix-topology { + pkgs = import nixpkgs { + system = "x86_64-linux"; + overlays = [inputs.nix-topology.overlays.default]; + }; # Only this package set must include nix-topology.overlays.default + modules = [ + # Your own file to define global topology. Works in principle like a nixos module but uses different options. + ./topology.nix + # Inline module to inform topology of your existing NixOS hosts. + { nixosConfigurations = self.nixosConfigurations; } + ]; + }; }; } diff --git a/topology.nix b/topology.nix new file mode 100644 index 0000000..a2833e0 --- /dev/null +++ b/topology.nix @@ -0,0 +1,120 @@ +{ config, ... }: +let + inherit + (config.lib.topology) + mkInternet + mkRouter + mkSwitch + mkDevice + mkConnection + mkConnectionRev; + values = import ./values.nix; +in { + +### Networks + + networks.pvv = { + name = "PVV Network"; + cidrv4 = values.ipv4-space; + cidrv6 = values.ipv6-space; + }; + + networks.site-vpn = { + name = "OpenVPN Site to Site"; + style = { + primaryColor = "#9dd68d"; + secondaryColor = null; + pattern = "dashed"; + }; + }; + + networks.ntnu = { + name = "NTNU"; + }; + + nodes.internet = mkInternet { + connections = mkConnection "ntnu" "wan1"; + }; + + nodes.ntnu = mkRouter "NTNU" { + interfaceGroups = [ ["wan1"] ["eth1" "eth2" "eth3"] ]; + connections.eth1 = mkConnection "ntnu-pvv-router" "wan1"; + connections.eth2 = mkConnection "ntnu-veggen" "wan1"; + connections.eth3 = mkConnection "stackit" "*"; + interfaces.eth1.network = "ntnu"; + }; + +### Brus + + nodes.ntnu-pvv-router = mkRouter "NTNU PVV Gateway" { + interfaceGroups = [ ["wan1"] ["eth1"] ]; + connections.eth1 = mkConnection "brus-switch" "eth1"; + interfaces.eth1.network = "pvv"; + }; + + nodes.brus-switch = mkSwitch "Brus Switch" { + interfaceGroups = [ ["eth1" "eth2" "eth3" "eth4" "eth5" "eth6" "eth7"] ]; + connections.eth2 = mkConnection "bekkalokk" "enp2s0"; + connections.eth3 = mkConnection "bicep" "enp6s0f0"; + connections.eth4 = mkConnection "buskerud" "enp3s0f0"; + connections.eth5 = mkConnection "knutsen" "eth1"; + connections.eth7 = mkConnection "joshua" "eth1"; + }; + + nodes.knutsen = mkRouter "knutsen" { + interfaceGroups = [ ["eth1"] ["eth2"] ["vpn1"] ]; + connections.eth2 = mkConnectionRev "brus-switch" "eth6"; + # connections.vpn1 = mkConnection "ludvigsen" "vpn1"; + interfaces.vpn1.network = "site-vpn"; + interfaces.vpn1.virtual = true; + }; + + nodes.joshua = mkDevice "joshua" { + interfaceGroups = [ ["eth1"] ]; + }; + + nodes.shark = { + guestType = "proxmox"; + parent = config.nodes.joshua.id; + }; + + +### PVV + + nodes.ntnu-veggen = mkRouter "NTNU-Veggen" { + interfaceGroups = [ ["wan1"] ["eth1"] ]; + connections.eth1 = mkConnection "ludvigsen" "eth1"; + }; + + nodes.ludvigsen = mkRouter "ludvigsen" { + interfaceGroups = [ ["eth1"] ["eth2"] ["vpn1"] ]; + connections.eth2 = mkConnection "pvv-switch" "eth1"; + interfaces.vpn1.network = "site-vpn"; + interfaces.vpn1.virtual = true; + interfaces.eth1.network = "ntnu"; + interfaces.eth2.network = "pvv"; + }; + + nodes.pvv-switch = mkSwitch "PVV Switch (Terminalrommet)" { + interfaceGroups = [ ["eth1" "eth2" "eth3"] ]; + connections.eth2 = mkConnection "brzeczyszczykiewicz" "eno1"; + connections.eth3 = mkConnection "georg" "eno1"; + }; + + +### Openstack + + nodes.stackit = mkDevice "stackit" { + interfaceGroups = [ ["*"] ]; + }; + + nodes.ildkule = { + guestType = "openstack"; + parent = config.nodes.stackit.id; + }; + nodes.bob = { + guestType = "openstack"; + parent = config.nodes.stackit.id; + }; + +}