From e149da7b9bbc04bd0b1ca03fa0768e958cbcd40e Mon Sep 17 00:00:00 2001
From: John Ericson <John.Ericson@Obsidian.Systems>
Date: Fri, 3 May 2024 12:41:17 -0400
Subject: [PATCH] Try again to ensure hydra module is usable

Nixpkgs only contains a `hydra_unstable`, not `hydra`, package, so
adjust the default accordingly, and then override it to our package in
the separate module which does that.
---
 flake.nix                 | 2 +-
 nixos-modules/default.nix | 3 ++-
 nixos-modules/hydra.nix   | 4 ++--
 nixos-tests.nix           | 2 +-
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/flake.nix b/flake.nix
index 7e2f3f67..1f73e3b3 100644
--- a/flake.nix
+++ b/flake.nix
@@ -76,7 +76,7 @@
         modules =
           [
             self.nixosModules.hydra
-            self.nixosModules.overlayNixpkgsForThisHyydra
+            self.nixosModules.overlayNixpkgsForThisHydra
             self.nixosModules.hydraTest
             self.nixosModules.hydraProxy
             {
diff --git a/nixos-modules/default.nix b/nixos-modules/default.nix
index f44d7808..dac705c3 100644
--- a/nixos-modules/default.nix
+++ b/nixos-modules/default.nix
@@ -3,8 +3,9 @@
 {
   hydra = import ./hydra.nix;
 
-  overlayNixpkgsForThisHyydra = {
+  overlayNixpkgsForThisHydra = { pkgs, ... }: {
     nixpkgs = { inherit overlays; };
+    services.hydra.package = pkgs.hydra;
   };
 
   hydraTest = { pkgs, ... }: {
diff --git a/nixos-modules/hydra.nix b/nixos-modules/hydra.nix
index 1f0792d7..7a0486c1 100644
--- a/nixos-modules/hydra.nix
+++ b/nixos-modules/hydra.nix
@@ -68,7 +68,7 @@ in
 
       package = mkOption {
         type = types.path;
-        default = pkgs.hydra;
+        default = pkgs.hydra_unstable;
         defaultText = literalExpression "pkgs.hydra";
         description = "The Hydra package.";
       };
@@ -233,7 +233,7 @@ in
       gc-keep-outputs = true;
       gc-keep-derivations = true;
     };
-    
+
     services.hydra-dev.extraConfig =
       ''
         using_frontend_proxy = 1
diff --git a/nixos-tests.nix b/nixos-tests.nix
index 3c9dc6c8..19a9ba35 100644
--- a/nixos-tests.nix
+++ b/nixos-tests.nix
@@ -7,7 +7,7 @@ let
     {
       imports = [
         nixosModules.hydra
-        nixosModules.overlayNixpkgsForThisHyydra
+        nixosModules.overlayNixpkgsForThisHydra
         nixosModules.hydraTest
       ];