about summary refs log tree commit diff
path: root/modules/services/drone/runner-docker
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-04-13 15:20:45 -0700
committerFranck Cuny <franck@fcuny.net>2022-04-13 15:20:45 -0700
commitd95497cf3a7728f4a0d43bf4f54eb4a796ba0870 (patch)
tree3df15db490f3da6f83d15e2e732196bb48cb2525 /modules/services/drone/runner-docker
parentnginx: configure correctly the dashboard (diff)
downloadworld-d95497cf3a7728f4a0d43bf4f54eb4a796ba0870.tar.gz
drone: initial attempt at configuring it
Diffstat (limited to 'modules/services/drone/runner-docker')
-rw-r--r--modules/services/drone/runner-docker/default.nix39
1 files changed, 39 insertions, 0 deletions
diff --git a/modules/services/drone/runner-docker/default.nix b/modules/services/drone/runner-docker/default.nix
new file mode 100644
index 0000000..d701c18
--- /dev/null
+++ b/modules/services/drone/runner-docker/default.nix
@@ -0,0 +1,39 @@
+{ config, lib, pkgs, ... }:
+let
+  cfg = config.my.services.drone;
+  hasRunner = (name: builtins.elem name cfg.runners);
+  dockerPkg = pkgs.drone-runner-docker;
+in {
+  config = lib.mkIf (cfg.enable && hasRunner "docker") {
+    systemd.services.drone-runner-docker = {
+      wantedBy = [ "multi-user.target" ];
+      after = [ "docker.socket" ]; # Needs the socket to be available
+      # might break deployment
+      restartIfChanged = false;
+      confinement.enable = true;
+      serviceConfig = {
+        Environment = [
+          "DRONE_SERVER_HOST=${cfg.vhostName}"
+          "DRONE_SERVER_PROTO=https"
+          "DRONE_RUNNER_CAPACITY=10"
+          "CLIENT_DRONE_RPC_HOST=127.0.0.1:${toString cfg.port}"
+        ];
+        BindPaths = [ "/var/run/docker.sock" ];
+        EnvironmentFile = [ cfg.sharedSecretFile ];
+        ExecStart = "${dockerPkg}/bin/drone-runner-docker";
+        User = "drone-runner-docker";
+        Group = "drone-runner-docker";
+      };
+    };
+
+    # Make sure it is activated in that case
+    virtualisation.docker.enable = true;
+
+    users.users.drone-runner-docker = {
+      isSystemUser = true;
+      group = "drone-runner-docker";
+      extraGroups = [ "docker" ]; # Give access to the daemon
+    };
+    users.groups.drone-runner-docker = { };
+  };
+}