diff --git a/flake.nix b/flake.nix index d2431b8..9601dd4 100644 --- a/flake.nix +++ b/flake.nix @@ -93,7 +93,6 @@ modules = [ configurationPath sops-nix.nixosModules.sops - inputs.nix-topology.nixosModules.default ] ++ extraArgs.modules or []; pkgs = import nixpkgs { @@ -244,27 +243,50 @@ bluemap = pkgs.callPackage ./packages/bluemap.nix { }; out-of-your-element = pkgs.callPackage ./packages/out-of-your-element.nix { }; - } // + } + // + # Mediawiki extensions (lib.pipe null [ (_: pkgs.callPackage ./packages/mediawiki-extensions { }) (lib.flip builtins.removeAttrs ["override" "overrideDerivation"]) (lib.mapAttrs' (name: lib.nameValuePair "mediawiki-${name}")) ]) - // lib.genAttrs allMachines - (machine: self.nixosConfigurations.${machine}.config.system.build.toplevel); - }; + // + # Machines + lib.genAttrs allMachines + (machine: self.nixosConfigurations.${machine}.config.system.build.toplevel) + // + # Nix-topology + (let + topology' = import inputs.nix-topology { + pkgs = import nixpkgs { + system = "x86_64-linux"; + overlays = [ inputs.nix-topology.overlays.default ]; + }; - 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; } - ]; + modules = [ + ./topology + { + nixosConfigurations = lib.mapAttrs (_name: nixosCfg: nixosCfg.extendModules { + modules = [ + inputs.nix-topology.nixosModules.default + ./topology/service-extractors/greg-ng.nix + ]; + }) self.nixosConfigurations; + } + ]; + }; + in { + topology = topology'.config.output; + topology-png = pkgs.runCommand "pvv-config-topology-png" { + nativeBuildInputs = [ pkgs.writableTmpDirAsHomeHook ]; + } '' + mkdir -p "$out" + for file in '${topology'.config.output}'/*.svg; do + ${lib.getExe pkgs.imagemagick} -density 300 -background none "$file" "$out"/"$(basename "''${file%.svg}.png")" + done + ''; + }); }; }; } diff --git a/topology.nix b/topology/default.nix similarity index 67% rename from topology.nix rename to topology/default.nix index 8253ac5..eb1cd93 100644 --- a/topology.nix +++ b/topology/default.nix @@ -1,4 +1,4 @@ -{ config, ... }: +{ lib, config, ... }: let inherit (config.lib.topology) @@ -8,10 +8,9 @@ let mkDevice mkConnection mkConnectionRev; - values = import ./values.nix; + values = import ../values.nix; in { - -### Networks + ### Networks networks.pvv = { name = "PVV Network"; @@ -44,7 +43,7 @@ in { interfaces.eth1.network = "ntnu"; }; -### Brus + ### Brus nodes.ntnu-pvv-router = mkRouter "NTNU PVV Gateway" { interfaceGroups = [ ["wan1"] ["eth1"] ]; @@ -53,12 +52,19 @@ in { }; nodes.brus-switch = mkSwitch "Brus Switch" { - interfaceGroups = [ ["eth1" "eth2" "eth3" "eth4" "eth5" "eth6" "eth7"] ]; + interfaceGroups = [ (lib.genList (i: "eth${toString i}") 16) ]; + connections.eth2 = mkConnection "bekkalokk" "enp2s0"; - connections.eth3 = mkConnection "bicep" "enp6s0f0"; - # connections.eth4 = mkConnection "buskerud" "enp3s0f0"; + # connections.eth3 = mkConnection "bicep" "enp6s0f0"; + connections.eth4 = mkConnection "buskerud" "eth1"; connections.eth5 = mkConnection "knutsen" "eth1"; - connections.eth7 = mkConnection "joshua" "eth1"; + connections.eth6 = mkConnection "powerpuff-cluster" "eth1"; + + connections.eth8 = mkConnection "lupine-1" "enp0s31f6"; + connections.eth9 = mkConnection "lupine-2" "enp0s31f6"; + connections.eth11 = mkConnection "lupine-3" "enp0s31f6"; + connections.eth10 = mkConnection "lupine-4" "enp0s31f6"; + connections.eth12 = mkConnection "lupine-5" "enp0s31f6"; }; nodes.knutsen = mkRouter "knutsen" { @@ -69,17 +75,37 @@ in { interfaces.vpn1.virtual = true; }; - nodes.joshua = mkDevice "joshua" { + nodes.buskerud = mkDevice "buskerud" { interfaceGroups = [ ["eth1"] ]; }; nodes.shark = { guestType = "proxmox"; - parent = config.nodes.joshua.id; + parent = config.nodes.buskerud.id; }; + ### Powerpuff -### PVV + nodes.powerpuff-cluster = mkDevice "powerpuff-cluster" { + interfaceGroups = [ ["eth1"] ]; + }; + + nodes.kommode = { + guestType = "proxmox"; + parent = config.nodes.powerpuff-cluster.id; + }; + + nodes.bicep = { + guestType = "proxmox"; + parent = config.nodes.powerpuff-cluster.id; + }; + + nodes.ustetind = { + guestType = "proxmox"; + parent = config.nodes.powerpuff-cluster.id; + }; + + ### PVV nodes.ntnu-veggen = mkRouter "NTNU-Veggen" { interfaceGroups = [ ["wan1"] ["eth1"] ]; @@ -102,7 +128,7 @@ in { }; -### Openstack + ### Openstack nodes.stackit = mkDevice "stackit" { interfaceGroups = [ ["*"] ]; @@ -112,9 +138,12 @@ in { guestType = "openstack"; parent = config.nodes.stackit.id; }; - nodes.bob = { + nodes.wenche = { + guestType = "openstack"; + parent = config.nodes.stackit.id; + }; + nodes.bakke = { guestType = "openstack"; parent = config.nodes.stackit.id; }; - } diff --git a/topology/icons/greg-ng.png b/topology/icons/greg-ng.png new file mode 100644 index 0000000..89f18f9 Binary files /dev/null and b/topology/icons/greg-ng.png differ diff --git a/topology/service-extractors/greg-ng.nix b/topology/service-extractors/greg-ng.nix new file mode 100644 index 0000000..ce81279 --- /dev/null +++ b/topology/service-extractors/greg-ng.nix @@ -0,0 +1,11 @@ +{ config, lib, ... }: +let + cfg = config.services.greg-ng or { enable = false; }; +in +{ + config.topology.self.services.greg-ng = lib.mkIf cfg.enable { + name = "Greg-ng"; + icon = ../icons/greg-ng.png; + details.listen = { text = "${cfg.settings.host}:${toString cfg.settings.port}"; }; + }; +}