summaryrefslogtreecommitdiffstats
path: root/krebs/3modules/htgen.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2017-04-12 09:24:46 +0200
committertv <tv@krebsco.de>2017-04-12 09:24:46 +0200
commit0248fce6be6705de4a6beab0f2a9336550df9d18 (patch)
tree6865e194d5df1f9f77a03da06192d5034f97cacf /krebs/3modules/htgen.nix
parent75f43655d379a7aeed58b9cb423759b8a3696a9a (diff)
parent9224e9c4c8432ce8d7788592b9d25cfc29440ee6 (diff)
Merge remote-tracking branch 'prism/makefu'
Diffstat (limited to 'krebs/3modules/htgen.nix')
-rw-r--r--krebs/3modules/htgen.nix68
1 files changed, 68 insertions, 0 deletions
diff --git a/krebs/3modules/htgen.nix b/krebs/3modules/htgen.nix
new file mode 100644
index 000000000..0dddca6c8
--- /dev/null
+++ b/krebs/3modules/htgen.nix
@@ -0,0 +1,68 @@
+{ config, lib, pkgs, ... }:
+
+with import <stockholm/lib>;
+let
+ cfg = config.krebs.htgen;
+
+ out = {
+ options.krebs.htgen = api;
+ config = imp;
+ };
+
+ api = mkOption {
+ default = {};
+ type = types.attrsOf (types.submodule ({ config, ... }: {
+ options = {
+ enable = mkEnableOption "krebs.htgen-${config.name}";
+
+ name = mkOption {
+ type = types.username;
+ default = config._module.args.name;
+ };
+
+ 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;
+ HTGEN_SCRIPT = htgen.script;
+ };
+ serviceConfig = {
+ SyslogIdentifier = "htgen";
+ User = htgen.user.name;
+ PrivateTmp = true;
+ Restart = "always";
+ ExecStart = "${pkgs.htgen}/bin/htgen --serve";
+ };
+ }
+ ) cfg;
+
+ users.users = mapAttrs' (name: htgen:
+ nameValuePair htgen.user.name {
+ inherit (htgen.user) home name uid;
+ createHome = true;
+ }
+ ) cfg;
+
+ };
+in out