2021-03-19 01:41:12 +01:00
|
|
|
{ self, nixpkgs, system }:
|
|
|
|
with nixpkgs.lib;
|
2021-02-25 01:06:32 +01:00
|
|
|
let
|
2021-03-19 01:41:12 +01:00
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
2021-03-19 01:52:49 +01:00
|
|
|
config = self.lib.config;
|
2021-03-19 01:41:12 +01:00
|
|
|
|
|
|
|
device-scripts =
|
2021-11-03 01:07:44 +01:00
|
|
|
builtins.mapAttrs (hostName: hostConfig@{ role, model, ... }:
|
|
|
|
pkgs.writeScript "${hostName}.sh" (
|
|
|
|
let
|
|
|
|
args = {
|
2021-11-07 02:22:24 +01:00
|
|
|
inherit self hostName config hostConfig pkgs;
|
2021-11-03 01:07:44 +01:00
|
|
|
};
|
|
|
|
in {
|
|
|
|
ap = import ./ap.nix args;
|
2021-11-07 02:22:24 +01:00
|
|
|
switch = import (./switches + "/${model}.nix")
|
|
|
|
(args //
|
|
|
|
import ./switches/shared.nix args
|
|
|
|
);
|
2021-11-03 01:07:44 +01:00
|
|
|
}.${role}
|
2021-04-29 01:39:21 +02:00
|
|
|
)
|
|
|
|
) (
|
|
|
|
filterAttrs (_: { role, ... }:
|
|
|
|
role == "ap" || role == "switch"
|
|
|
|
) config.site.hosts
|
|
|
|
);
|
2021-02-25 01:06:32 +01:00
|
|
|
|
2021-03-19 01:41:12 +01:00
|
|
|
all-device-scripts =
|
2021-02-25 01:06:32 +01:00
|
|
|
pkgs.runCommandLocal "all-device-scripts" {} (
|
|
|
|
''
|
|
|
|
mkdir -p $out/bin
|
2021-04-25 23:53:38 +02:00
|
|
|
|
|
|
|
substitute ${./ap_install_collectd.sh} $out/bin/ap_install_collectd.sh \
|
|
|
|
--replace "{{STATS}}" "${config.site.net.serv.hosts6.dn42.stats}"
|
2021-04-29 01:39:21 +02:00
|
|
|
chmod a+x $out/bin/ap_install_collectd.sh
|
2021-02-25 01:06:32 +01:00
|
|
|
'' +
|
|
|
|
builtins.concatStringsSep "\n" (
|
2021-11-03 01:07:44 +01:00
|
|
|
map (hostName:
|
|
|
|
"ln -s ${device-scripts.${hostName}} $out/bin/${hostName}.sh"
|
2021-03-19 18:44:04 +01:00
|
|
|
) (builtins.attrNames device-scripts)
|
2021-02-25 01:06:32 +01:00
|
|
|
)
|
|
|
|
);
|
2021-03-19 01:41:12 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
inherit all-device-scripts;
|
|
|
|
} // device-scripts
|