diff --git a/nix/pkgs/default.nix b/nix/pkgs/default.nix index 951e75e..95af4be 100644 --- a/nix/pkgs/default.nix +++ b/nix/pkgs/default.nix @@ -92,9 +92,14 @@ let subnetplans = import ./subnetplans.nix { inherit self nixpkgs system; }; + + vlan-report = import ./vlan-report.nix { + inherit self nixpkgs system; + }; in rootfs-packages // vm-packages // device-templates // network-graphs // network-cypher-graphs // starlink // subnetplans // { inherit all-rootfs export-openwrt-models export-config dns-slaves encrypt-secrets decrypt-secrets switch-to-production + vlan-report ; } diff --git a/nix/pkgs/vlan-report.nix b/nix/pkgs/vlan-report.nix new file mode 100644 index 000000000..764719d --- /dev/null +++ b/nix/pkgs/vlan-report.nix @@ -0,0 +1,22 @@ +{ self, nixpkgs, system }: +with nixpkgs.legacyPackages.${system}; +let + config = self.lib.config; +in +writeText "vlan-report.txt" ( + lib.concatMapStrings (net: '' + ## ${net}${lib.optionalString (config.site.net.${net}.vlan != null) " (VLAN ${toString config.site.net.${net}.vlan})"} + ${lib.concatStringsSep "\n" ( + lib.concatMap (host: + map (target: "- ${host} -> ${target}") ( + builtins.attrNames ( + lib.filterAttrs (_: { nets, ... }: + lib.elem net nets + ) config.site.hosts.${host}.links + ) + ) + ) (lib.attrNames config.site.hosts) + )} + + '') (lib.attrNames config.site.net) +)