From 5f40c7a5b0cb555f64231d18cf105bf0ec7eb0a2 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sat, 5 Nov 2022 12:47:02 -0700 Subject: Revert "ref(drone): remove all modules and configurations" This reverts commit 614fc2fcce0e9ae0bcfdc6e08d3c4bac846d02a8. --- modules/services/drone/runner-docker/default.nix | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 modules/services/drone/runner-docker/default.nix (limited to 'modules/services/drone/runner-docker') diff --git a/modules/services/drone/runner-docker/default.nix b/modules/services/drone/runner-docker/default.nix new file mode 100644 index 0000000..428a8d6 --- /dev/null +++ b/modules/services/drone/runner-docker/default.nix @@ -0,0 +1,40 @@ +{ 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 = { }; + }; +} -- cgit 1.4.1