about summary refs log tree commit diff
path: root/modules/services/drone/server
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-11-05 12:47:02 -0700
committerFranck Cuny <franck@fcuny.net>2022-11-05 12:47:02 -0700
commit5f40c7a5b0cb555f64231d18cf105bf0ec7eb0a2 (patch)
tree437fb6409e166cc64947d754458f2544502275dd /modules/services/drone/server
parentref(home/git): update mapping for the git-helper (diff)
downloadworld-5f40c7a5b0cb555f64231d18cf105bf0ec7eb0a2.tar.gz
Revert "ref(drone): remove all modules and configurations"
This reverts commit 614fc2fcce0e9ae0bcfdc6e08d3c4bac846d02a8.
Diffstat (limited to 'modules/services/drone/server')
-rw-r--r--modules/services/drone/server/default.nix53
1 files changed, 53 insertions, 0 deletions
diff --git a/modules/services/drone/server/default.nix b/modules/services/drone/server/default.nix
new file mode 100644
index 0000000..97e20a3
--- /dev/null
+++ b/modules/services/drone/server/default.nix
@@ -0,0 +1,53 @@
+{ config, lib, pkgs, ... }:
+let
+  cfg = config.my.services.drone;
+  secrets = config.age.secrets;
+in
+{
+  config = lib.mkIf cfg.enable {
+    systemd.services.drone-server = {
+      wantedBy = [ "multi-user.target" ];
+      serviceConfig = {
+        EnvironmentFile = [ cfg.sharedSecretFile ];
+        Environment = [
+          "DRONE_DATABASE_DRIVER=sqlite3"
+          "DRONE_DATABASE_DATASOURCE=/var/lib/drone-server/drone.sqlite"
+          "DRONE_SERVER_HOST=${cfg.vhostName}"
+          "DRONE_SERVER_PROTO=https"
+          "DRONE_SERVER_PORT=:${toString cfg.port}"
+          "DRONE_USER_CREATE=username:${cfg.admin},admin:true"
+          "DRONE_JSONNET_ENABLED=true"
+          "DRONE_STARLARK_ENABLED=true"
+        ];
+        StateDirectory = "drone-server";
+        ExecStart = "${pkgs.drone}/bin/drone-server";
+        User = "drone";
+        Group = "drone";
+      };
+    };
+
+    users.users.drone = {
+      isSystemUser = true;
+      createHome = true;
+      group = "drone";
+    };
+
+    users.groups.drone = { };
+
+    services.nginx.virtualHosts."${cfg.vhostName}" = {
+      forceSSL = true;
+      useACMEHost = cfg.vhostName;
+      locations."/" = {
+        proxyPass = "http://127.0.0.1:${toString cfg.port}";
+        proxyWebsockets = true;
+      };
+    };
+
+    security.acme.certs."${cfg.vhostName}" = {
+      dnsProvider = "gcloud";
+      credentialsFile = secrets."acme/credentials".path;
+    };
+
+    my.services.backup = { paths = [ "/var/lib/droner-server" ]; };
+  };
+}