2017-03-16 19:56:28 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with import <stockholm/lib>;
|
|
|
|
let
|
|
|
|
cfg = config.krebs.htgen;
|
|
|
|
|
|
|
|
out = {
|
|
|
|
options.krebs.htgen = api;
|
|
|
|
config = imp;
|
|
|
|
};
|
|
|
|
|
|
|
|
api = mkOption {
|
2017-03-16 21:12:11 +00:00
|
|
|
default = {};
|
2017-03-16 19:56:28 +00:00
|
|
|
type = types.attrsOf (types.submodule ({ config, ... }: {
|
|
|
|
options = {
|
|
|
|
enable = mkEnableOption "krebs.htgen-${config.name}";
|
|
|
|
|
|
|
|
name = mkOption {
|
|
|
|
type = types.username;
|
|
|
|
default = config._module.args.name;
|
|
|
|
};
|
|
|
|
|
2021-02-02 21:28:25 +00:00
|
|
|
package = mkOption {
|
|
|
|
default = pkgs.htgen;
|
|
|
|
type = types.package;
|
|
|
|
};
|
|
|
|
|
2017-03-16 19:56:28 +00:00
|
|
|
port = mkOption {
|
|
|
|
type = types.uint;
|
|
|
|
};
|
|
|
|
|
|
|
|
script = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
user = mkOption {
|
|
|
|
type = types.user;
|
|
|
|
default = {
|
|
|
|
name = "htgen-${config.name}";
|
|
|
|
home = "/var/lib/htgen-${config.name}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
imp = {
|
|
|
|
|
|
|
|
systemd.services = mapAttrs' (name: htgen:
|
|
|
|
nameValuePair "htgen-${name}" {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
environment = {
|
|
|
|
HTGEN_PORT = toString htgen.port;
|
2017-03-16 20:53:34 +00:00
|
|
|
HTGEN_SCRIPT = htgen.script;
|
2017-03-16 19:56:28 +00:00
|
|
|
};
|
|
|
|
serviceConfig = {
|
|
|
|
SyslogIdentifier = "htgen";
|
|
|
|
User = htgen.user.name;
|
|
|
|
PrivateTmp = true;
|
|
|
|
Restart = "always";
|
2021-02-02 21:28:25 +00:00
|
|
|
ExecStart = "${htgen.package}/bin/htgen --serve";
|
2017-03-16 19:56:28 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
) cfg;
|
|
|
|
|
|
|
|
users.users = mapAttrs' (name: htgen:
|
|
|
|
nameValuePair htgen.user.name {
|
|
|
|
inherit (htgen.user) home name uid;
|
|
|
|
createHome = true;
|
2021-06-01 22:11:38 +00:00
|
|
|
isSystemUser = true;
|
2017-03-16 19:56:28 +00:00
|
|
|
}
|
|
|
|
) cfg;
|
|
|
|
|
|
|
|
};
|
|
|
|
in out
|