1 { config, lib, pkgs, ... }:
4 cfg = config.services.hockeypuck;
5 settingsFormat = pkgs.formats.toml { };
7 meta.maintainers = with lib.maintainers; [ etu ];
9 options.services.hockeypuck = {
10 enable = lib.mkEnableOption "Hockeypuck OpenPGP Key Server";
14 type = lib.types.port;
15 description = "HKP port to listen on.";
18 settings = lib.mkOption {
19 type = settingsFormat.type;
21 example = lib.literalExpression ''
25 logfile = "/var/log/hockeypuck/hockeypuck.log";
26 indexTemplate = "''${pkgs.hockeypuck-web}/share/templates/index.html.tmpl";
27 vindexTemplate = "''${pkgs.hockeypuck-web}/share/templates/index.html.tmpl";
28 statsTemplate = "''${pkgs.hockeypuck-web}/share/templates/stats.html.tmpl";
29 webroot = "''${pkgs.hockeypuck-web}/share/webroot";
31 hkp.bind = ":''${toString cfg.port}";
34 driver = "postgres-jsonb";
35 dsn = "database=hockeypuck host=/var/run/postgresql sslmode=disable";
41 Configuration file for hockeypuck, here you can override
42 certain settings (`loglevel` and
43 `openpgp.db.dsn`) by just setting those values.
45 For other settings you need to use lib.mkForce to override them.
47 This service doesn't provision or enable postgres on your
48 system, it rather assumes that you enable postgres and create
49 the database yourself.
53 services.postgresql = {
55 ensureDatabases = [ "hockeypuck" ];
58 ensureDBOwnership = true;
66 config = lib.mkIf cfg.enable {
67 services.hockeypuck.settings.hockeypuck = {
68 loglevel = lib.mkDefault "INFO";
69 logfile = "/var/log/hockeypuck/hockeypuck.log";
70 indexTemplate = "${pkgs.hockeypuck-web}/share/templates/index.html.tmpl";
71 vindexTemplate = "${pkgs.hockeypuck-web}/share/templates/index.html.tmpl";
72 statsTemplate = "${pkgs.hockeypuck-web}/share/templates/stats.html.tmpl";
73 webroot = "${pkgs.hockeypuck-web}/share/webroot";
75 hkp.bind = ":${toString cfg.port}";
78 driver = "postgres-jsonb";
79 dsn = lib.mkDefault "database=hockeypuck host=/var/run/postgresql sslmode=disable";
83 users.users.hockeypuck = {
86 description = "Hockeypuck user";
88 users.groups.hockeypuck = {};
90 systemd.services.hockeypuck = {
91 description = "Hockeypuck OpenPGP Key Server";
92 after = [ "network.target" "postgresql.target" ];
93 wantedBy = [ "multi-user.target" ];
95 WorkingDirectory = "/var/lib/hockeypuck";
97 ExecStart = "${pkgs.hockeypuck}/bin/hockeypuck -config ${settingsFormat.generate "config.toml" cfg.settings}";
100 LogsDirectory = "hockeypuck";
101 LogsDirectoryMode = "0755";
102 StateDirectory = "hockeypuck";