pkgs/vlan-report: add

This commit is contained in:
Astro 2022-01-24 21:04:11 +01:00
parent 7b80560aed
commit 7acff4cf8e
2 changed files with 27 additions and 0 deletions

View File

@ -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
;
}

22
nix/pkgs/vlan-report.nix Normal file
View File

@ -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)
)