2021-04-02 14:18:50 +02:00
|
|
|
{ depot, config, lib, pkgs, ... }:
|
2020-07-22 01:40:49 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.depot.panettone;
|
2022-01-30 17:06:58 +01:00
|
|
|
in
|
|
|
|
{
|
2020-07-22 01:40:49 +02:00
|
|
|
options.services.depot.panettone = with lib; {
|
|
|
|
enable = mkEnableOption "Panettone issue tracker";
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
description = "Port on which Panettone should listen";
|
|
|
|
type = types.int;
|
|
|
|
default = 7268;
|
|
|
|
};
|
2020-07-26 21:41:15 +02:00
|
|
|
|
|
|
|
dbHost = mkOption {
|
|
|
|
description = "Postgresql host to connect to for Panettone";
|
2020-07-28 03:30:47 +02:00
|
|
|
type = types.str;
|
2020-07-26 21:41:15 +02:00
|
|
|
default = "localhost";
|
|
|
|
};
|
|
|
|
|
|
|
|
dbName = mkOption {
|
|
|
|
description = "Name of the database for Panettone";
|
2020-07-28 03:30:47 +02:00
|
|
|
type = types.str;
|
2020-07-26 21:41:15 +02:00
|
|
|
default = "panettone";
|
|
|
|
};
|
|
|
|
|
|
|
|
dbUser = mkOption {
|
|
|
|
description = "Name of the database user for Panettone";
|
2020-07-28 03:30:47 +02:00
|
|
|
type = types.str;
|
2020-07-26 21:41:15 +02:00
|
|
|
default = "panettone";
|
|
|
|
};
|
2020-07-28 03:30:47 +02:00
|
|
|
|
|
|
|
secretsFile = mkOption {
|
|
|
|
description = ''
|
|
|
|
Path to a file containing secrets, in the format accepted
|
|
|
|
by systemd's EnvironmentFile
|
|
|
|
'';
|
|
|
|
type = types.str;
|
2021-12-10 21:19:56 +01:00
|
|
|
default = "/run/agenix/panettone";
|
2020-07-28 03:30:47 +02:00
|
|
|
};
|
2020-11-17 22:56:28 +01:00
|
|
|
|
|
|
|
irccatHost = mkOption {
|
|
|
|
description = "Hostname for the irccat instance";
|
|
|
|
type = types.str;
|
|
|
|
default = "localhost";
|
|
|
|
};
|
|
|
|
|
|
|
|
irccatPort = mkOption {
|
|
|
|
description = "Port for the irccat instance";
|
|
|
|
type = types.int;
|
|
|
|
default = 4722;
|
|
|
|
};
|
|
|
|
|
|
|
|
irccatChannel = mkOption {
|
|
|
|
description = "IRC channels to post to via irccat";
|
|
|
|
type = types.str;
|
|
|
|
};
|
2020-07-22 01:40:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
2020-07-26 21:41:15 +02:00
|
|
|
assertions = [{
|
|
|
|
assertion =
|
|
|
|
cfg.dbHost != "localhost" || config.services.postgresql.enable;
|
|
|
|
message = "Panettone requires a postgresql database";
|
2022-01-30 17:06:58 +01:00
|
|
|
}
|
|
|
|
{
|
|
|
|
assertion =
|
|
|
|
cfg.dbHost != "localhost" || config.services.postgresql.enableTCPIP;
|
|
|
|
message = "Panettone can only connect to the postgresql database over TCP";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
assertion =
|
|
|
|
cfg.dbHost != "localhost" || (lib.any
|
|
|
|
(user: user.name == cfg.dbUser)
|
|
|
|
config.services.postgresql.ensureUsers);
|
|
|
|
message = "Panettone requires a database user";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
assertion =
|
|
|
|
cfg.dbHost != "localhost" || (lib.any
|
|
|
|
(db: db == cfg.dbName)
|
|
|
|
config.services.postgresql.ensureDatabases);
|
|
|
|
message = "Panettone requires a database";
|
|
|
|
}];
|
2020-07-26 21:41:15 +02:00
|
|
|
|
2020-07-22 01:40:49 +02:00
|
|
|
systemd.services.panettone = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
script = "${depot.web.panettone}/bin/panettone";
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
DynamicUser = true;
|
|
|
|
Restart = "always";
|
2020-07-28 03:30:47 +02:00
|
|
|
EnvironmentFile = cfg.secretsFile;
|
2020-07-22 01:40:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
environment = {
|
|
|
|
PANETTONE_PORT = toString cfg.port;
|
2020-07-26 21:41:15 +02:00
|
|
|
PGHOST = "localhost";
|
|
|
|
PGUSER = cfg.dbUser;
|
|
|
|
PGDATABASE = cfg.dbName;
|
2020-11-17 22:56:28 +01:00
|
|
|
IRCCATHOST = cfg.irccatHost;
|
|
|
|
IRCCATPORT = toString cfg.irccatPort;
|
|
|
|
ISSUECHANNEL = cfg.irccatChannel;
|
2020-07-22 01:40:49 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|