just report

This commit is contained in:
Peder Bergebakken Sundt 2024-01-27 04:30:54 +01:00
parent 9704c36cb3
commit 6ddab8dd84
2 changed files with 26 additions and 0 deletions

View File

@ -191,6 +191,27 @@
}; };
modules = [ (mkModule domain system inputs stateVersion modules hostname) ]; modules = [ (mkModule domain system inputs stateVersion modules hostname) ];
}; };
mkReport = domain: system: inputs: stateVersion: modules: hostname: let
nixos = mkConfig domain system inputs stateVersion modules hostname;
cfg = nixos.config;
inherit (nixos.pkgs) lib;
in {
inherit system; # TODO: cross system
fqdn = cfg.networking.fqdn;
allowedTCPPorts = cfg.networking.firewall.allowedTCPPorts;
allowedUDPPorts = cfg.networking.firewall.allowedUDPPorts;
bootloader = if cfg.boot.loader.grub.enable then "grub"
else if cfg.boot.loader.systemd-boot.enable then "systemd-boot"
else null;
mounts = lib.pipe cfg.fileSystems [
(lib.filterAttrs (mount: fs: fs.fsType != "nfs"))
(lib.mapAttrs (mount: fs: "${fs.fsType}://${fs.device}"))
];
nginx-vhosts = lib.pipe cfg.services.nginx.virtualHosts [
#(lib.filterAttrs (domain: vhost: )
(lib.mapAttrs (domain: vhost: vhost.serverAliases or []))
];
};
mkHosts = mk: let mkHosts = mk: let
ls = imports: { inherit imports; }; ls = imports: { inherit imports; };
hw = nixos-hardware.nixosModules; hw = nixos-hardware.nixosModules;
@ -228,6 +249,7 @@
nixosModules = mkHosts mkModule; nixosModules = mkHosts mkModule;
nixosConfigurations = mkHosts mkConfig; nixosConfigurations = mkHosts mkConfig;
nixosReports = mkHosts mkReport;
packages = forAllSystems ({ inputs, pkgs, lib, flakes, ... }: { packages = forAllSystems ({ inputs, pkgs, lib, flakes, ... }: {
nixos-rebuild-nom = pkgs.writeScriptBin "nixos-rebuild" '' nixos-rebuild-nom = pkgs.writeScriptBin "nixos-rebuild" ''
@ -277,6 +299,7 @@
pkgs.age pkgs.age
pkgs.sops pkgs.sops
pkgs.ssh-to-age pkgs.ssh-to-age
pkgs.just
]; ];
in { in {
envrc-local = mkShell envrc-pkgs; envrc-local = mkShell envrc-pkgs;
@ -289,6 +312,7 @@
flakes.self.pkgs.nixos-rebuild-nom flakes.self.pkgs.nixos-rebuild-nom
pkgs.age pkgs.age
pkgs.ssh-to-age pkgs.ssh-to-age
pkgs.just
]; ];
}); });

2
justfile Normal file
View File

@ -0,0 +1,2 @@
report:
nix eval .#nixosReports --json | yq . --yaml-output