Compare commits

..

7 commits

Author SHA1 Message Date
Ilya K d26dd9f2a6 Switch to push metrics with Grafana Agent 2024-07-07 16:32:57 +00:00
Ilya K 461e63b683 Prepare for remote push metrics 2024-07-07 16:32:57 +00:00
Ilya K 8d22df82bd Wire up Grafana to Alertmanager 2024-07-07 16:32:57 +00:00
Ilya K 22c87569b7 Enable Mimir Alertmanager, add example alert
Still TODO: actually connect it to Matrix
2024-07-07 16:32:57 +00:00
Pierre Bourdon 30859b2872
terraform: store state on S3 2024-07-07 18:22:41 +02:00
Pierre Bourdon 0c68a23275
flake: fix 'nix flake check' 2024-07-07 18:02:55 +02:00
raito 8dc7ee9864
hydra: add declarative controls via terranix
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2024-07-07 17:59:56 +02:00
5 changed files with 128 additions and 10 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@ result
.gcroots
config.tf.json
.direnv
.terraform

View file

@ -31,7 +31,12 @@
terraform = pkgs.opentofu;
terraformCfg = terranix.lib.terranixConfiguration {
inherit system;
modules = [ ];
modules = [
./terraform
{
bagel.hydra.enable = true;
}
];
};
in
{
@ -46,6 +51,16 @@
${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"
destroy = {
type = "app";
@ -56,13 +71,16 @@
${lib.getExe terraform} destroy
'');
};
default = self.apps.${system}.apply;
};
apps.${system}.default = self.apps.${system}.apply;
devShells.${system}.default = pkgs.mkShell {
packages = [
inputs.agenix.packages.${system}.agenix
inputs.colmena.packages.${system}.colmena
pkgs.opentofu
];
};

6
terraform/default.nix Normal file
View file

@ -0,0 +1,6 @@
{
imports = [
./hydra.nix
./state.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" ]'';
}
];
};
};
}

21
terraform/state.nix Normal file
View file

@ -0,0 +1,21 @@
{
# We use terraform.backend.s3 directly instead of the type-checked Terranix
# backend.s3 options. The latter does not support setting arbitrary s3
# endpoints.
#
# Note: currently requires the user to provide AWS_ACCESS_KEY_ID as well as
# AWS_SECRET_ACCESS_KEY in their environment variables.
terraform.backend.s3 = {
endpoints.s3 = "s3.delroth.net";
region = "garage";
bucket = "bagel-terraform-state";
key = "state";
# It's just a dump Garage server, don't try to be smart.
skip_credentials_validation = true;
skip_region_validation = true;
skip_requesting_account_id = true;
skip_metadata_api_check = true;
};
}