2020-06-07 14:03:12 +00:00
|
|
|
# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2020-04-30 04:49:19 +00:00
|
|
|
{ depot, lib, pkgs, ... }@args:
|
|
|
|
let
|
|
|
|
inherit (builtins) foldl' mapAttrs;
|
2020-05-08 22:26:21 +00:00
|
|
|
baseModule = name: { ... }: {
|
|
|
|
_module.args = args // {
|
|
|
|
rebuilder = rebuilder name;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
systemFor = systemName: config:
|
|
|
|
(depot.third_party.nixeval {
|
|
|
|
system = builtins.currentSystem;
|
|
|
|
modules = [ (baseModule systemName) (args: { imports = [ lib/common.nix config ]; }) ];
|
2020-11-01 18:25:01 +00:00
|
|
|
});
|
2021-01-30 04:30:05 +00:00
|
|
|
systems = [
|
|
|
|
"porcorosso"
|
2021-04-29 12:16:49 +00:00
|
|
|
"howl"
|
2021-01-30 04:30:05 +00:00
|
|
|
"marukuru"
|
|
|
|
"clouvider-fra01"
|
|
|
|
"totoro"
|
|
|
|
"swann"
|
|
|
|
"clouvider-lon01"
|
|
|
|
"etheroute-lon01"
|
2021-02-07 20:21:32 +00:00
|
|
|
"blade-janeway"
|
2021-02-08 22:26:22 +00:00
|
|
|
"blade-tuvok"
|
|
|
|
"blade-paris"
|
|
|
|
"blade-torres"
|
|
|
|
"blade-chakotay"
|
|
|
|
"blade-kim"
|
2021-03-28 00:34:36 +00:00
|
|
|
"frantech-lux01"
|
|
|
|
"frantech-nyc01"
|
|
|
|
"frantech-las01"
|
|
|
|
"bvm-nixosmgmt"
|
2021-03-28 13:10:27 +00:00
|
|
|
"bvm-twitterchiver"
|
|
|
|
"bvm-prosody"
|
|
|
|
"bvm-ipfs"
|
2021-05-22 21:48:13 +00:00
|
|
|
"bvm-matrix"
|
2021-05-24 01:32:58 +00:00
|
|
|
"bvm-minecraft"
|
2021-08-15 22:46:57 +00:00
|
|
|
"bvm-netbox"
|
2021-09-24 22:50:30 +00:00
|
|
|
"bvm-radius"
|
2021-01-30 04:30:05 +00:00
|
|
|
];
|
2020-05-09 10:14:25 +00:00
|
|
|
rebuilder = system: (import ./lib/rebuilder.nix (args // { system = system; }));
|
2020-04-30 04:49:19 +00:00
|
|
|
systemCfgs = lib.genAttrs systems
|
2020-05-08 22:26:21 +00:00
|
|
|
(name: import (./. + "/${name}"));
|
2020-11-01 18:25:01 +00:00
|
|
|
evaledSystems = mapAttrs systemFor systemCfgs;
|
|
|
|
systemDrvs = mapAttrs (_: sys: sys.config.system.build.toplevel) evaledSystems;
|
|
|
|
systemTailscaleIPs = lib.mapAttrs' (n: v: lib.nameValuePair v [n]) (lib.filterAttrs (n: v: v != null) (mapAttrs (_: sys: sys.config.my.ip.tailscale) evaledSystems));
|
2020-11-06 04:52:54 +00:00
|
|
|
|
2020-11-18 02:02:23 +00:00
|
|
|
systemExporters = let
|
|
|
|
exportersForSystem = sysName: sys: let
|
|
|
|
mkExporter = exporterName: exporterPort: let jobName = "${sysName}/exporters/${exporterName}"; in lib.nameValuePair jobName {
|
|
|
|
job_name = jobName;
|
|
|
|
static_configs = [{
|
|
|
|
targets = ["${sysName}:${toString exporterPort}"];
|
|
|
|
labels = {
|
|
|
|
system = sysName;
|
|
|
|
exporter = exporterName;
|
|
|
|
};
|
|
|
|
}];
|
2020-11-06 04:52:54 +00:00
|
|
|
};
|
2021-03-14 01:13:37 +00:00
|
|
|
stockExporters = lib.mapAttrsToList (exporterName: exporter: mkExporter exporterName exporter.port) (lib.filterAttrs (exporterName: exporter: exporterName != "snmp" && exporter.enable) sys.config.services.prometheus.exporters);
|
2020-11-18 02:02:23 +00:00
|
|
|
customExporters = lib.mapAttrsToList mkExporter sys.config.my.prometheus.additionalExporterPorts;
|
|
|
|
in
|
|
|
|
stockExporters ++ customExporters;
|
|
|
|
in
|
|
|
|
builtins.listToAttrs (builtins.concatLists (lib.mapAttrsToList exportersForSystem evaledSystems));
|
2021-01-30 15:40:33 +00:00
|
|
|
|
|
|
|
netbootSystem = systemFor "netboot" (import ./netboot);
|
2021-03-18 23:51:38 +00:00
|
|
|
installcdSystem = systemFor "installcd" (import ./installcd);
|
2020-11-01 18:25:01 +00:00
|
|
|
in systemDrvs // {
|
2020-11-01 21:39:25 +00:00
|
|
|
systems = systemDrvs;
|
2021-03-28 15:27:46 +00:00
|
|
|
systemConfigs = evaledSystems;
|
2020-11-06 04:52:54 +00:00
|
|
|
systemExporters = systemExporters;
|
2020-11-01 18:25:01 +00:00
|
|
|
tailscaleIPs = systemTailscaleIPs;
|
2021-01-30 15:40:33 +00:00
|
|
|
|
|
|
|
netboot = netbootSystem.config.system.build.pixiecore;
|
2021-03-18 23:51:38 +00:00
|
|
|
installcd = installcdSystem.config.system.build.isoImage;
|
2021-03-13 16:57:28 +00:00
|
|
|
|
2021-03-13 17:05:49 +00:00
|
|
|
systemPathJSON = pkgs.writeText "systems.json" (builtins.toJSON systemDrvs);
|
2020-11-01 18:25:01 +00:00
|
|
|
}
|