1
0
nixfiles/lib/flake-helper.nix

45 lines
1.4 KiB
Nix
Raw Normal View History

2023-03-23 16:45:30 +01:00
{ self, nixpkgs, nixos-exporter, solid-xmpp-alarm, ... }@inputs:
rec {
2023-03-23 17:09:54 +01:00
generateNixosSystem = name: let
localNixpkgs = nixpkgs.lib.attrByPath [ "nixpkgs-${name}" ] nixpkgs inputs;
in localNixpkgs.lib.nixosSystem {
2023-03-23 16:45:30 +01:00
system = "x86_64-linux";
modules = [
({ ... }: {
/*
Make the contents of the flake availiable to modules.
Useful for having the monitoring server scraping the
target config from all other servers automatically.
*/
_module.args._nixfiles = self;
})
../configuration/common
({ ... }: {
nixpkgs.overlays = [
(_: _: {
inherit (nixos-exporter.packages."x86_64-linux")
nixos-exporter;
})
];
})
solid-xmpp-alarm.nixosModules.solid-xmpp-alarm
(../hosts + "/${name}/configuration.nix")
];
};
generateColmenaHost = name: hostSystem: {
deployment = {
targetHost = "${name}.net.clerie.de";
targetUser = null;
};
nixpkgs.system = hostSystem.config.nixpkgs.system;
imports = hostSystem._module.args.modules;
deployment.allowLocalDeployment = builtins.any (n: n == name) [ "schule" "osmium" ];
};
mapToColmenaHosts = hosts: builtins.mapAttrs (generateColmenaHost) hosts;
buildHosts = hosts: builtins.mapAttrs (name: host: host.config.system.build.toplevel) (nixpkgs.lib.filterAttrs (name: host: (builtins.substring 0 1 name) != "_") hosts);
2023-03-23 16:45:30 +01:00
}