From 0c8eb5ed6a0f18be91df69db90dbd3eaaccac705 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io>
Date: Thu, 12 May 2022 00:07:07 +0200
Subject: [PATCH] add hydra declarative projects

---
 secrets/hydra-password     | Bin 0 -> 48 bytes
 shell.nix                  |   2 ++
 terraform/hydra-jobsets.tf |  28 ++++++++++++++++++++++++++++
 terraform/main.tf          |   8 ++++++++
 4 files changed, 38 insertions(+)
 create mode 100644 secrets/hydra-password
 create mode 100644 terraform/hydra-jobsets.tf

diff --git a/secrets/hydra-password b/secrets/hydra-password
new file mode 100644
index 0000000000000000000000000000000000000000..affd737ff22cfff9e11c8a5fba96fe43cc39cad6
GIT binary patch
literal 48
zcmV-00MGvbM@dveQdv+`0NG*B^K%+9Y5SA(m#<YP7im;#Rl84RlZeu#Zr(AEODI><
G=&3314i(k_

literal 0
HcmV?d00001

diff --git a/shell.nix b/shell.nix
index c1ef7de..9fb2ee2 100644
--- a/shell.nix
+++ b/shell.nix
@@ -16,6 +16,7 @@ mkShell {
         p.cloudflare
         p.null
         p.external
+        p.hydra
       ]
     ))
     sops
@@ -31,5 +32,6 @@ mkShell {
 
   shellHook = ''
     export CLOUDFLARE_API_TOKEN=$(< ./secrets/cloudflare-api-token)
+    export HYDRA_PASSWORD=$(< ./secrets/hydra-password)
   '';
 }
diff --git a/terraform/hydra-jobsets.tf b/terraform/hydra-jobsets.tf
new file mode 100644
index 0000000..d38e293
--- /dev/null
+++ b/terraform/hydra-jobsets.tf
@@ -0,0 +1,28 @@
+resource "hydra_project" "kittybox" {
+  name         = "kittybox"
+  display_name = "Kittybox"
+  description  = "The IndieWeb blogging solution"
+  homepage     = "https://gitlab.com/kittybox/kittybox"
+  owner        = "admin"
+  enabled      = true
+  visible      = true
+}
+
+
+resource "hydra_jobset" "kittybox" {
+  project     = hydra_project.kittybox.name
+  state       = "enabled"
+  visible     = true
+  name        = "main"
+  type        = "flake"
+  description = "main branch"
+
+  flake_uri = "gitlab:kittybox/kittybox"
+
+  check_interval    = 300
+  scheduling_shares = 3000
+  keep_evaluations  = 3
+
+  email_notifications = false
+  #email_override      = ""
+}
diff --git a/terraform/main.tf b/terraform/main.tf
index 0c160d8..9f23b52 100644
--- a/terraform/main.tf
+++ b/terraform/main.tf
@@ -8,9 +8,17 @@ terraform {
     cloudflare = {
       source  = "cloudflare/cloudflare"
     }
+    hydra = {
+      source  = "DeterminateSystems/hydra"
+    }
   }
 }
 
 provider "cloudflare" {
   account_id = "e4a2db52c495db230973c839a0699ae1"
 }
+
+provider "hydra" {
+  host = "https://hydra.nix-community.org"
+  username = "admin"
+}