summary refs log tree commit diff
path: root/nixos/modules/services/continuous-integration/hydra/default.nix
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2019-09-14 12:58:42 +0200
committerMaximilian Bosch <maximilian@mbosch.me>2019-09-14 12:58:42 +0200
commitce37a040c262aed26e9c6fd63ba527ba1bc028cc (patch)
tree9234242d215508aea1b0c2f5ef491d913ca54086 /nixos/modules/services/continuous-integration/hydra/default.nix
parent7f136b5a5607059c3dca1967ffaca126e3d1fe29 (diff)
downloadnixpkgs-ce37a040c262aed26e9c6fd63ba527ba1bc028cc.tar
nixpkgs-ce37a040c262aed26e9c6fd63ba527ba1bc028cc.tar.gz
nixpkgs-ce37a040c262aed26e9c6fd63ba527ba1bc028cc.tar.bz2
nixpkgs-ce37a040c262aed26e9c6fd63ba527ba1bc028cc.tar.lz
nixpkgs-ce37a040c262aed26e9c6fd63ba527ba1bc028cc.tar.xz
nixpkgs-ce37a040c262aed26e9c6fd63ba527ba1bc028cc.tar.zst
nixpkgs-ce37a040c262aed26e9c6fd63ba527ba1bc028cc.zip
nixos/hydra: incorporate upstream changes and update test
During the last update, `hydra-notify` was rewritten as a daemon which
listens to postgresql notifications for each build[1]. The module
uses the `hydra-notify.service` unit from upstream's Hydra module and
the VM test ensures that email notifications are sent properly.

Also updated `hydra-init.service` to install `pg_trgm` on a local
database if needed[2].

[1] https://github.com/NixOS/hydra/commit/c7861b85c4c3cc974b27147bbf3cc258b9fe9cc3
[2] https://github.com/NixOS/hydra/commit/8a0a5ec3a3200d4f4d4d38f87d0afdb49f092b39
Diffstat (limited to 'nixos/modules/services/continuous-integration/hydra/default.nix')
-rw-r--r--nixos/modules/services/continuous-integration/hydra/default.nix20
1 files changed, 20 insertions, 0 deletions
diff --git a/nixos/modules/services/continuous-integration/hydra/default.nix b/nixos/modules/services/continuous-integration/hydra/default.nix
index 500acb48562..2da10a9a5e2 100644
--- a/nixos/modules/services/continuous-integration/hydra/default.nix
+++ b/nixos/modules/services/continuous-integration/hydra/default.nix
@@ -275,6 +275,7 @@ in
               ${pkgs.sudo}/bin/sudo -u ${config.services.postgresql.superUser} ${config.services.postgresql.package}/bin/createdb -O hydra hydra
               touch ${baseDir}/.db-created
             fi
+            echo "create extension if not exists pg_trgm" | ${pkgs.sudo}/bin/sudo -u ${config.services.postgresql.superUser} -- ${config.services.postgresql.package}/bin/psql hydra
           ''}
 
           if [ ! -e ${cfg.gcRootsDir} ]; then
@@ -379,6 +380,23 @@ in
           };
       };
 
+    systemd.services.hydra-notify =
+      { wantedBy = [ "multi-user.target" ];
+        requires = [ "hydra-init.service" ];
+        after = [ "hydra-init.service" ];
+        restartTriggers = [ hydraConf ];
+        environment = env // {
+          PGPASSFILE = "${baseDir}/pgpass-queue-runner";
+        };
+        serviceConfig =
+          { ExecStart = "@${cfg.package}/bin/hydra-notify hydra-notify";
+            # FIXME: run this under a less privileged user?
+            User = "hydra-queue-runner";
+            Restart = "always";
+            RestartSec = 5;
+          };
+      };
+
     # If there is less than a certain amount of free disk space, stop
     # the queue/evaluator to prevent builds from failing or aborting.
     systemd.services.hydra-check-space =
@@ -416,6 +434,8 @@ in
         hydra-users hydra-queue-runner hydra
         hydra-users hydra-www hydra
         hydra-users root hydra
+        # The postgres user is used to create the pg_trgm extension for the hydra database
+        hydra-users postgres postgres
       '';
 
     services.postgresql.authentication = optionalString haveLocalDB