modules(drone-server): init
This commit is contained in:
parent
48597e362c
commit
9c2ecdf461
|
@ -1,3 +1,4 @@
|
|||
{
|
||||
acme-dns = ./servers/acme-dns.nix;
|
||||
drone-server = ./servers/drone.nix;
|
||||
}
|
||||
|
|
71
modules/servers/drone.nix
Normal file
71
modules/servers/drone.nix
Normal file
|
@ -0,0 +1,71 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
with lib;
|
||||
with types;
|
||||
let
|
||||
cfg = config.services.drone-server;
|
||||
in
|
||||
{
|
||||
options.services.drone-server = {
|
||||
enable = mkEnableOption "Enable a Drone CI/CD web server";
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = pkgs.drone;
|
||||
defaultText = "pkgs.drone";
|
||||
};
|
||||
env = mkOption {
|
||||
type = listOf str;
|
||||
description = "Environment strings (e.g. DRONE_USER_CREATE, etc.)";
|
||||
};
|
||||
envFile = mkOption {
|
||||
type = str;
|
||||
description = "Path to the environment file (may contains secrets)";
|
||||
};
|
||||
user = mkOption {
|
||||
type = str;
|
||||
default = "droneserver";
|
||||
};
|
||||
group = mkOption {
|
||||
type = str;
|
||||
default = "droneserver";
|
||||
};
|
||||
port = mkOption {
|
||||
type = port;
|
||||
default = 3030;
|
||||
};
|
||||
};
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.drone-server = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
EnvironmentFile = [
|
||||
cfg.envFile
|
||||
];
|
||||
Environment = [
|
||||
"DRONE_DATABASE_DATASOURCE=postgres:///${cfg.database.name}?host=/run/postgresql"
|
||||
"DRONE_DATABASE_DRIVER=postgres"
|
||||
"DRONE_SERVER_PORT=:${toString cfg.port}"
|
||||
] ++ cfg.env;
|
||||
|
||||
ExecStart = "${cfg.package}/bin/drone-server";
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
};
|
||||
};
|
||||
|
||||
services.postgresql = {
|
||||
ensureDatabases = [ cfg.database.name ];
|
||||
ensureUsers = [{
|
||||
name = cfg.user;
|
||||
ensurePermissions."DATABASE ${cfg.database.name}" = "ALL PRIVILEGES";
|
||||
}];
|
||||
};
|
||||
|
||||
users.users.${cfg.user} = {
|
||||
isSystemUser = true;
|
||||
createHome = true;
|
||||
group = cfg.group;
|
||||
};
|
||||
users.groups.${cfg.group} = {};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue