hydra: add declarative controls via terranix

Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
raito 2024-07-04 13:54:50 +02:00 committed by Pierre Bourdon
parent e803c198c1
commit 8dc7ee9864
Signed by untrusted user: delroth
GPG key ID: 6FB80DCD84DA0F1C
4 changed files with 98 additions and 3 deletions

3
.gitignore vendored
View file

@ -1,4 +1,5 @@
result result
.gcroots .gcroots
config.tf.json config.tf.json
.direnv .direnv
.terraform

View file

@ -31,7 +31,12 @@
terraform = pkgs.opentofu; terraform = pkgs.opentofu;
terraformCfg = terranix.lib.terranixConfiguration { terraformCfg = terranix.lib.terranixConfiguration {
inherit system; inherit system;
modules = [ ]; modules = [
./terraform
{
bagel.hydra.enable = true;
}
];
}; };
in in
{ {
@ -46,6 +51,16 @@
${lib.getExe terraform} apply ${lib.getExe terraform} apply
''); '');
}; };
plan = {
type = "app";
program = toString (pkgs.writers.writeBash "plan" ''
set -eo pipefail
rm -f config.tf.json
cp ${terraformCfg} config.tf.json
${lib.getExe terraform} init
${lib.getExe terraform} plan
'');
};
# nix run ".#destroy" # nix run ".#destroy"
destroy = { destroy = {
type = "app"; type = "app";
@ -60,9 +75,11 @@
apps.${system}.default = self.apps.${system}.apply; apps.${system}.default = self.apps.${system}.apply;
devShells.${system}.default = pkgs.mkShell { devShells.${system}.default = pkgs.mkShell {
packages = [ packages = [
inputs.agenix.packages.${system}.agenix inputs.agenix.packages.${system}.agenix
inputs.colmena.packages.${system}.colmena inputs.colmena.packages.${system}.colmena
pkgs.opentofu
]; ];
}; };

5
terraform/default.nix Normal file
View file

@ -0,0 +1,5 @@
{
imports = [
./hydra.nix
];
}

72
terraform/hydra.nix Normal file
View file

@ -0,0 +1,72 @@
{ lib, config, ... }:
let
inherit (lib) mkEnableOption mkIf types mkOption;
cfg = config.bagel.hydra;
in
{
options.bagel.hydra = {
enable = mkEnableOption "the Hydra jobsets";
};
config = mkIf cfg.enable {
terraform.required_providers.hydra = {
version = "~> 0.1";
source = "DeterminateSystems/hydra";
};
provider.hydra = {
host = "https://hydra.bagel.delroth.net";
# username/password are provided via HYDRA_USERNAME/HYDRA_PASSWORD
};
resource.hydra_project.forkos = {
name = "forkos";
display_name = "ForkOS";
description = "ForkOS packages collection";
homepage = "https://cl.forkos.org";
owner = "raito";
enabled = true;
visible = true;
};
resource.hydra_jobset.raito-nixos-rolling-small = {
project = config.resource.hydra_project.forkos.name;
state = "enabled";
visible = true;
name = "raito-nixos-rolling-small";
type = "legacy";
description = "master branch for raito-nixos";
nix_expression = {
file = "pkgs/top-level/release.nix";
input = "nixpkgs";
};
check_interval = 0;
scheduling_shares = 3000;
keep_evaluations = 3;
email_notifications = false;
input = [
{
name = "nixpkgs";
type = "git";
value = "https://cl.forkos.org/nixpkgs";
notify_committers = false;
}
{
name = "officialRelease";
type = "boolean";
value = "false";
notify_committers = false;
}
{
name = "supportedSystems";
type = "nix";
value = ''[ "x86_64-linux" ]'';
}
];
};
};
}