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
|
|
|
});
|
2020-11-04 15:51:55 +00:00
|
|
|
systems = [ "porcorosso" "ixvm-fra01" "marukuru" "clouvider-fra01" "totoro" "kusakabe" "swann" "clouvider-lon01" ];
|
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
|
|
|
|
|
|
|
systemExporters = builtins.listToAttrs (builtins.concatLists (lib.mapAttrsToList (sysName: sys: lib.mapAttrsToList (exporterName: exporter: let jobName = "${sysName}/exporters/${exporterName}"; in lib.nameValuePair jobName {
|
|
|
|
job_name = jobName;
|
|
|
|
static_configs = [{
|
|
|
|
targets = ["${sysName}:${toString exporter.port}"];
|
|
|
|
labels = {
|
|
|
|
system = sysName;
|
|
|
|
exporter = exporterName;
|
|
|
|
};
|
|
|
|
}];
|
|
|
|
}) (lib.filterAttrs (_: exporter: exporter.enable) sys.config.services.prometheus.exporters)) evaledSystems));
|
2020-11-01 18:25:01 +00:00
|
|
|
in systemDrvs // {
|
2020-11-01 21:39:25 +00:00
|
|
|
systems = systemDrvs;
|
2020-11-06 04:52:54 +00:00
|
|
|
systemExporters = systemExporters;
|
2020-11-01 18:25:01 +00:00
|
|
|
tailscaleIPs = systemTailscaleIPs;
|
|
|
|
}
|