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
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
forEachSystem = f: builtins.listToAttrs (map (system: {
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
];
forEachSystem =
f:
builtins.listToAttrs (
map (system: {
name = system;
value = f system;
}) supportedSystems);
}) supportedSystems
);
systemBits = forEachSystem (system: rec {
inherit system;
pkgs = import nixpkgs {
@ -64,20 +78,33 @@
inherit (nixpkgs) lib;
in
{
apps = forEachSystem' ({ system, pkgs, terraformCfg, terraform, ... }: {
apps = forEachSystem' (
{
system,
pkgs,
terraformCfg,
terraform,
...
}:
{
tf = {
type = "app";
program = toString (pkgs.writers.writeBash "tf" ''
program = toString (
pkgs.writers.writeBash "tf" ''
set -eo pipefail
ln -snf ${terraformCfg} config.tf.json
exec ${lib.getExe terraform} "$@"
'');
''
);
};
default = self.apps.${system}.tf;
});
}
);
devShells = forEachSystem' ({ system, pkgs, ... }: {
devShells = forEachSystem' (
{ system, pkgs, ... }:
{
default = pkgs.mkShell {
packages = [
inputs.agenix.packages.${system}.agenix
@ -87,11 +114,13 @@
(pkgs.callPackage ./lib/colmena-wrapper.nix { })
];
};
});
}
);
nixosConfigurations = (colmena.lib.makeHive self.outputs.colmena).nodes;
colmena = let
colmena =
let
commonModules = [
inputs.agenix.nixosModules.default
inputs.hydra.nixosModules.hydra
@ -102,13 +131,20 @@
./common
];
makeBuilder = i: lib.nameValuePair "builder-${toString i}" {
makeBuilder =
i:
lib.nameValuePair "builder-${toString i}" {
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);
in {
in
{
meta.nixpkgs = systemBits.x86_64-linux.pkgs;
meta.specialArgs.inputs = inputs;
@ -120,9 +156,12 @@
wob-vpn-gw.imports = commonModules ++ [ ./hosts/wob-vpn-gw ];
buildbot.imports = commonModules ++ [ ./hosts/buildbot ];
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;
};
}