flake.nix: reformat, prepare for hook

This commit is contained in:
Ilya K 2024-08-09 18:45:53 +03:00
parent 84efd0976d
commit d234b670d0

View file

@ -31,13 +31,27 @@
}; };
}; };
outputs = { self, nixpkgs, terranix, colmena, ... } @ inputs: outputs =
{
self,
nixpkgs,
terranix,
colmena,
...
}@inputs:
let let
supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; supportedSystems = [
forEachSystem = f: builtins.listToAttrs (map (system: { "x86_64-linux"
"aarch64-linux"
];
forEachSystem =
f:
builtins.listToAttrs (
map (system: {
name = system; name = system;
value = f system; value = f system;
}) supportedSystems); }) supportedSystems
);
systemBits = forEachSystem (system: rec { systemBits = forEachSystem (system: rec {
inherit system; inherit system;
pkgs = import nixpkgs { pkgs = import nixpkgs {
@ -64,20 +78,33 @@
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
in in
{ {
apps = forEachSystem' ({ system, pkgs, terraformCfg, terraform, ... }: { apps = forEachSystem' (
{
system,
pkgs,
terraformCfg,
terraform,
...
}:
{
tf = { tf = {
type = "app"; type = "app";
program = toString (pkgs.writers.writeBash "tf" '' program = toString (
pkgs.writers.writeBash "tf" ''
set -eo pipefail set -eo pipefail
ln -snf ${terraformCfg} config.tf.json ln -snf ${terraformCfg} config.tf.json
exec ${lib.getExe terraform} "$@" exec ${lib.getExe terraform} "$@"
''); ''
);
}; };
default = self.apps.${system}.tf; default = self.apps.${system}.tf;
}); }
);
devShells = forEachSystem' ({ system, pkgs, ... }: { devShells = forEachSystem' (
{ system, pkgs, ... }:
{
default = pkgs.mkShell { default = pkgs.mkShell {
packages = [ packages = [
inputs.agenix.packages.${system}.agenix inputs.agenix.packages.${system}.agenix
@ -87,11 +114,13 @@
(pkgs.callPackage ./lib/colmena-wrapper.nix { }) (pkgs.callPackage ./lib/colmena-wrapper.nix { })
]; ];
}; };
}); }
);
nixosConfigurations = (colmena.lib.makeHive self.outputs.colmena).nodes; nixosConfigurations = (colmena.lib.makeHive self.outputs.colmena).nodes;
colmena = let colmena =
let
commonModules = [ commonModules = [
inputs.agenix.nixosModules.default inputs.agenix.nixosModules.default
inputs.hydra.nixosModules.hydra inputs.hydra.nixosModules.hydra
@ -102,13 +131,20 @@
./common ./common
]; ];
makeBuilder = i: lib.nameValuePair "builder-${toString i}" { makeBuilder =
i:
lib.nameValuePair "builder-${toString i}" {
imports = commonModules; imports = commonModules;
bagel.baremetal.builders = { enable = true; num = i; netboot = i >= 6; }; bagel.baremetal.builders = {
enable = true;
num = i;
netboot = i >= 6;
};
}; };
builders = lib.listToAttrs (lib.genList makeBuilder 12); builders = lib.listToAttrs (lib.genList makeBuilder 12);
in { in
{
meta.nixpkgs = systemBits.x86_64-linux.pkgs; meta.nixpkgs = systemBits.x86_64-linux.pkgs;
meta.specialArgs.inputs = inputs; meta.specialArgs.inputs = inputs;
@ -120,9 +156,12 @@
wob-vpn-gw.imports = commonModules ++ [ ./hosts/wob-vpn-gw ]; wob-vpn-gw.imports = commonModules ++ [ ./hosts/wob-vpn-gw ];
buildbot.imports = commonModules ++ [ ./hosts/buildbot ]; buildbot.imports = commonModules ++ [ ./hosts/buildbot ];
public01.imports = commonModules ++ [ ./hosts/public01 ]; public01.imports = commonModules ++ [ ./hosts/public01 ];
} // builders; }
// builders;
hydraJobs = builtins.mapAttrs (n: v: v.config.system.build.netbootDir or v.config.system.build.toplevel) self.nixosConfigurations; hydraJobs = builtins.mapAttrs (
n: v: v.config.system.build.netbootDir or v.config.system.build.toplevel
) self.nixosConfigurations;
buildbotJobs = builtins.mapAttrs (_: v: v.config.system.build.toplevel) self.nixosConfigurations; buildbotJobs = builtins.mapAttrs (_: v: v.config.system.build.toplevel) self.nixosConfigurations;
}; };
} }