2024-06-23 04:41:53 +00:00
|
|
|
{
|
|
|
|
description = "Bagel cooking infrastructure";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
2024-08-12 22:38:51 +00:00
|
|
|
|
2024-07-02 09:08:19 +00:00
|
|
|
terranix.url = "github:terranix/terranix";
|
2024-08-12 22:38:51 +00:00
|
|
|
terranix.inputs.nixpkgs.follows = "nixpkgs";
|
2024-06-23 04:41:53 +00:00
|
|
|
|
2024-06-24 16:03:07 +00:00
|
|
|
agenix.url = "github:ryantm/agenix";
|
|
|
|
agenix.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
2024-06-23 04:41:53 +00:00
|
|
|
colmena.url = "github:zhaofengli/colmena";
|
|
|
|
colmena.inputs.nixpkgs.follows = "nixpkgs";
|
2024-06-24 14:45:59 +00:00
|
|
|
|
2024-08-12 23:10:52 +00:00
|
|
|
hydra.url = "git+https://git.lix.systems/lix-project/hydra.git";
|
2024-06-24 14:45:59 +00:00
|
|
|
hydra.inputs.nixpkgs.follows = "nixpkgs";
|
2024-06-24 18:59:37 +00:00
|
|
|
|
2024-07-08 20:30:08 +00:00
|
|
|
nix-gerrit.url = "git+https://git.lix.systems/the-distro/nix-gerrit.git";
|
|
|
|
nix-gerrit.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
2024-08-24 08:59:47 +00:00
|
|
|
gerrit-dashboard.url = "git+https://git.lix.systems/the-distro/gerrit-monitoring.git";
|
|
|
|
gerrit-dashboard.flake = false;
|
|
|
|
|
2024-10-18 11:47:33 +00:00
|
|
|
buildbot-nix.url = "git+https://git.lix.systems/lix-project/buildbot-nix.git?ref=refs/heads/bring-back-old-gerrit-reporting";
|
2024-07-17 12:47:38 +00:00
|
|
|
buildbot-nix.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
2024-08-01 22:33:42 +00:00
|
|
|
channel-scripts.url = "git+https://git.lix.systems/the-distro/channel-scripts.git";
|
|
|
|
channel-scripts.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
2024-09-26 22:09:12 +00:00
|
|
|
stateless-uptime-kuma.url = "git+https://git.dgnum.eu/DGNum/stateless-uptime-kuma.git";
|
|
|
|
stateless-uptime-kuma.flake = false;
|
|
|
|
|
2024-07-17 11:10:53 +00:00
|
|
|
lix.follows = "hydra/lix";
|
2024-08-15 14:22:22 +00:00
|
|
|
|
|
|
|
grapevine = {
|
|
|
|
type = "gitlab";
|
|
|
|
host = "gitlab.computer.surgery";
|
|
|
|
owner = "matrix";
|
|
|
|
repo = "grapevine-fork";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-06-23 04:41:53 +00:00
|
|
|
};
|
|
|
|
|
2024-07-09 08:49:29 +00:00
|
|
|
outputs = { self, nixpkgs, terranix, colmena, ... } @ inputs:
|
2024-07-02 09:08:19 +00:00
|
|
|
let
|
2024-07-21 15:03:29 +00:00
|
|
|
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
|
|
|
|
forEachSystem = f: builtins.listToAttrs (map (system: {
|
|
|
|
name = system;
|
|
|
|
value = f system;
|
|
|
|
}) supportedSystems);
|
|
|
|
systemBits = forEachSystem (system: rec {
|
2024-07-02 09:08:19 +00:00
|
|
|
inherit system;
|
2024-07-21 15:03:29 +00:00
|
|
|
pkgs = import nixpkgs {
|
|
|
|
localSystem = system;
|
|
|
|
overlays = [
|
|
|
|
inputs.hydra.overlays.default
|
|
|
|
inputs.lix.overlays.default
|
|
|
|
inputs.nix-gerrit.overlays.default
|
2024-08-01 22:33:42 +00:00
|
|
|
inputs.channel-scripts.overlays.default
|
2024-09-26 22:09:12 +00:00
|
|
|
(import "${inputs.stateless-uptime-kuma}/overlay.nix")
|
2024-07-21 15:03:29 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
terraform = pkgs.opentofu;
|
|
|
|
terraformCfg = terranix.lib.terranixConfiguration {
|
|
|
|
inherit system;
|
|
|
|
modules = [
|
|
|
|
./terraform
|
|
|
|
{
|
2024-09-23 17:24:30 +00:00
|
|
|
bagel.dnsimple.enable = true;
|
2024-07-21 15:03:29 +00:00
|
|
|
bagel.hydra.enable = true;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
});
|
|
|
|
forEachSystem' = f: forEachSystem (system: (f systemBits.${system}));
|
|
|
|
inherit (nixpkgs) lib;
|
2024-07-02 09:08:19 +00:00
|
|
|
in
|
|
|
|
{
|
2024-07-21 15:03:29 +00:00
|
|
|
apps = forEachSystem' ({ system, pkgs, terraformCfg, terraform, ... }: {
|
2024-07-07 17:17:11 +00:00
|
|
|
tf = {
|
2024-07-02 09:08:19 +00:00
|
|
|
type = "app";
|
2024-07-07 17:17:11 +00:00
|
|
|
program = toString (pkgs.writers.writeBash "tf" ''
|
2024-07-02 09:08:19 +00:00
|
|
|
set -eo pipefail
|
2024-07-07 17:17:11 +00:00
|
|
|
ln -snf ${terraformCfg} config.tf.json
|
|
|
|
exec ${lib.getExe terraform} "$@"
|
2024-07-02 09:08:19 +00:00
|
|
|
'');
|
2024-07-07 17:17:11 +00:00
|
|
|
};
|
2024-07-07 16:02:55 +00:00
|
|
|
|
2024-07-07 17:17:11 +00:00
|
|
|
default = self.apps.${system}.tf;
|
2024-07-21 15:03:29 +00:00
|
|
|
});
|
2024-07-05 09:43:53 +00:00
|
|
|
|
2024-07-21 15:03:29 +00:00
|
|
|
devShells = forEachSystem' ({ system, pkgs, ... }: {
|
|
|
|
default = pkgs.mkShell {
|
|
|
|
packages = [
|
|
|
|
inputs.agenix.packages.${system}.agenix
|
2024-07-04 11:54:50 +00:00
|
|
|
|
2024-07-21 15:03:29 +00:00
|
|
|
pkgs.opentofu
|
2024-07-23 22:21:00 +00:00
|
|
|
|
2024-07-21 15:03:29 +00:00
|
|
|
(pkgs.callPackage ./lib/colmena-wrapper.nix { })
|
|
|
|
];
|
|
|
|
};
|
|
|
|
});
|
2024-07-05 09:43:53 +00:00
|
|
|
|
2024-07-09 08:49:29 +00:00
|
|
|
nixosConfigurations = (colmena.lib.makeHive self.outputs.colmena).nodes;
|
|
|
|
|
2024-07-10 12:24:47 +00:00
|
|
|
colmena = let
|
|
|
|
commonModules = [
|
|
|
|
inputs.agenix.nixosModules.default
|
|
|
|
inputs.hydra.nixosModules.hydra
|
2024-07-17 12:47:38 +00:00
|
|
|
inputs.buildbot-nix.nixosModules.buildbot-coordinator
|
|
|
|
inputs.buildbot-nix.nixosModules.buildbot-worker
|
2024-07-10 12:24:47 +00:00
|
|
|
|
|
|
|
./services
|
|
|
|
./common
|
2024-10-05 16:04:51 +00:00
|
|
|
];
|
2024-10-05 14:29:14 +00:00
|
|
|
|
2024-10-05 16:04:51 +00:00
|
|
|
floralInfraModules = commonModules ++ [
|
2024-10-05 14:29:14 +00:00
|
|
|
({ config, lib, ... }: {
|
2024-08-01 21:41:05 +00:00
|
|
|
# This means that anyone with @floral-infra permissions
|
|
|
|
# can ssh on root of every machines handled here.
|
|
|
|
bagel.admins.allowedGroups = [
|
|
|
|
"floral-infra"
|
|
|
|
];
|
2024-10-05 14:29:14 +00:00
|
|
|
|
2024-10-05 16:04:51 +00:00
|
|
|
# Tag all machines which have local boot as local bootables.
|
2024-10-06 09:19:16 +00:00
|
|
|
deployment.tags = lib.mkMerge [
|
|
|
|
[ "floral" ]
|
|
|
|
(lib.mkIf (config.bagel.baremetal.builders.enable -> !config.bagel.baremetal.builders.netboot)
|
|
|
|
[ "localboot" ]
|
|
|
|
)
|
|
|
|
];
|
2024-10-05 16:04:51 +00:00
|
|
|
|
2024-10-06 09:03:53 +00:00
|
|
|
bagel.monitoring.grafana-agent.tenant = "floral";
|
2024-10-05 16:04:51 +00:00
|
|
|
bagel.secrets.tenant = "floral";
|
|
|
|
bagel.builders.extra-build-capacity.provider.tenant = "floral";
|
2024-10-05 16:14:39 +00:00
|
|
|
bagel.services.buildbot.tenant = "floral";
|
2024-10-05 14:29:14 +00:00
|
|
|
})
|
2024-07-10 12:24:47 +00:00
|
|
|
];
|
|
|
|
|
2024-10-05 16:04:51 +00:00
|
|
|
# These are Floral baremetal builders.
|
2024-10-05 14:29:14 +00:00
|
|
|
makeBuilder = i:
|
|
|
|
let
|
|
|
|
enableNetboot = i >= 6;
|
|
|
|
in
|
|
|
|
lib.nameValuePair "builder-${toString i}" {
|
2024-10-05 16:04:51 +00:00
|
|
|
imports = floralInfraModules;
|
2024-10-05 14:29:14 +00:00
|
|
|
bagel.baremetal.builders = { enable = true; num = i; netboot = enableNetboot; };
|
2024-07-10 12:24:47 +00:00
|
|
|
};
|
|
|
|
|
2024-10-05 16:04:51 +00:00
|
|
|
lixInfraModules = commonModules ++ [
|
|
|
|
{
|
|
|
|
# This means that anyone with @lix-infra permissions
|
|
|
|
# can ssh on root of every machines handled here.
|
|
|
|
bagel.admins.allowedGroups = [
|
|
|
|
"lix-infra"
|
|
|
|
];
|
|
|
|
|
|
|
|
# Tag all machines which have local boot as local bootables.
|
|
|
|
# Lix has no netbootable machine.
|
2024-10-06 09:19:16 +00:00
|
|
|
deployment.tags = [ "localboot" "lix" ];
|
2024-10-05 16:04:51 +00:00
|
|
|
|
2024-10-06 09:03:53 +00:00
|
|
|
bagel.monitoring.grafana-agent.tenant = "lix";
|
2024-10-05 16:04:51 +00:00
|
|
|
bagel.secrets.tenant = "lix";
|
2024-10-06 09:18:18 +00:00
|
|
|
bagel.builders.extra-build-capacity.provider = {
|
|
|
|
tenant = "lix";
|
|
|
|
buildfarmPublicKeys = [
|
|
|
|
# buildbot.lix.systems SSH key
|
|
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDu4cEqZzAI/1vZjSQkTJ4ijIg9nuloOuSKUrnkJIOFn"
|
|
|
|
];
|
|
|
|
};
|
2024-10-05 16:14:39 +00:00
|
|
|
bagel.services.buildbot.tenant = "lix";
|
2024-10-05 16:04:51 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2024-08-13 17:12:36 +00:00
|
|
|
builders = lib.listToAttrs (lib.genList makeBuilder 11);
|
2024-07-10 12:24:47 +00:00
|
|
|
in {
|
2024-07-21 15:03:29 +00:00
|
|
|
meta.nixpkgs = systemBits.x86_64-linux.pkgs;
|
2024-10-05 16:04:51 +00:00
|
|
|
# Add any non-x86_64 native systems here.
|
|
|
|
# Cross compilation is not supported yet.
|
|
|
|
meta.nodeNixpkgs =
|
|
|
|
let
|
|
|
|
aarch64-systems = systems: lib.genAttrs systems (system: systemBits.aarch64-linux.pkgs);
|
|
|
|
in
|
|
|
|
aarch64-systems [
|
2024-10-05 16:05:48 +00:00
|
|
|
"build01-aarch64-lix"
|
2024-10-05 16:04:51 +00:00
|
|
|
];
|
2024-06-24 14:45:59 +00:00
|
|
|
meta.specialArgs.inputs = inputs;
|
|
|
|
|
2024-10-05 16:04:51 +00:00
|
|
|
bagel-box.imports = floralInfraModules ++ [ ./hosts/bagel-box ];
|
|
|
|
meta01.imports = floralInfraModules ++ [ ./hosts/meta01 ];
|
|
|
|
gerrit01.imports = floralInfraModules ++ [ ./hosts/gerrit01 ];
|
|
|
|
fodwatch.imports = floralInfraModules ++ [ ./hosts/fodwatch ];
|
|
|
|
git.imports = floralInfraModules ++ [ ./hosts/git ];
|
|
|
|
wob-vpn-gw.imports = floralInfraModules ++ [ ./hosts/wob-vpn-gw ];
|
|
|
|
buildbot.imports = floralInfraModules ++ [ ./hosts/buildbot ];
|
|
|
|
public01.imports = floralInfraModules ++ [ ./hosts/public01 ];
|
|
|
|
build-coord.imports = floralInfraModules ++ [ ./hosts/build-coord ];
|
2024-10-05 16:05:48 +00:00
|
|
|
|
|
|
|
build01-aarch64-lix.imports = lixInfraModules ++ [ ./hosts/build01-aarch64-lix ];
|
2024-10-05 16:18:12 +00:00
|
|
|
buildbot-lix.imports = lixInfraModules ++ [ ./hosts/buildbot-lix ];
|
2024-07-10 12:24:47 +00:00
|
|
|
} // builders;
|
2024-07-10 16:40:59 +00:00
|
|
|
|
2024-08-01 20:47:25 +00:00
|
|
|
hydraJobs = builtins.mapAttrs (n: v: v.config.system.build.netbootDir or v.config.system.build.toplevel) self.nixosConfigurations;
|
2024-07-18 10:18:12 +00:00
|
|
|
buildbotJobs = builtins.mapAttrs (_: v: v.config.system.build.toplevel) self.nixosConfigurations;
|
2024-06-23 04:41:53 +00:00
|
|
|
};
|
|
|
|
}
|