This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / modules / htgen.nix
3.4 kB 127 lines
1# Copied from stockholm krebs/3modules/htgen.nix (cc283503); htgen now comes 2# from stockholm's packages output instead of its overlay. Users and groups 3# get their ids from NixOS instead of stockholm's genid. 4{ 5 config, 6 lib, 7 pkgs, 8 self, 9 ... 10}: 11 12with lib; 13let 14 optionalAttr = name: value: if name != null then { ${name} = value; } else { }; 15 16 cfg = config.krebs.htgen; 17 18 out = { 19 options.krebs.htgen = api; 20 config = imp; 21 }; 22 23 api = mkOption { 24 default = { }; 25 type = types.attrsOf ( 26 types.submodule ( 27 { config, ... }: { 28 options = { 29 enable = mkEnableOption "krebs.htgen-${config._module.args.name}"; 30 31 name = mkOption { 32 # POSIX portable filename, like stockholm's types.username 33 type = types.strMatching "[0-9A-Za-z._][0-9A-Za-z._-]*"; 34 default = config._module.args.name; 35 }; 36 37 package = mkOption { 38 default = self.inputs.stockholm.packages.${pkgs.stdenv.hostPlatform.system}.htgen; 39 type = types.package; 40 }; 41 42 port = mkOption { 43 type = types.port; 44 }; 45 46 script = mkOption { 47 type = types.nullOr types.str; 48 default = null; 49 }; 50 51 scriptFile = mkOption { 52 type = types.nullOr (types.either types.package types.path); 53 default = null; 54 }; 55 56 user = mkOption { 57 type = types.submodule ( 58 { config, ... }: 59 { 60 options = { 61 name = mkOption { 62 type = types.strMatching "[0-9A-Za-z._][0-9A-Za-z._-]*"; 63 }; 64 home = mkOption { 65 type = types.path; 66 # as stockholm's types.user 67 default = "/home/${config.name}"; 68 }; 69 }; 70 } 71 ); 72 default = { 73 name = "htgen-${config.name}"; 74 home = "/var/lib/htgen-${config.name}"; 75 }; 76 defaultText = { 77 name = "htgen-‹name›"; 78 home = "/var/lib/htgen-‹name›"; 79 }; 80 }; 81 }; 82 } 83 ) 84 ); 85 }; 86 imp = { 87 88 systemd.services = mapAttrs' ( 89 name: htgen: 90 nameValuePair "htgen-${name}" { 91 wantedBy = [ "multi-user.target" ]; 92 after = [ "network.target" ]; 93 environment = { 94 HTGEN_PORT = toString htgen.port; 95 } 96 // optionalAttr "HTGEN_SCRIPT" htgen.script 97 // optionalAttr "HTGEN_SCRIPT_FILE" htgen.scriptFile; 98 serviceConfig = { 99 SyslogIdentifier = "htgen"; 100 User = htgen.user.name; 101 PrivateTmp = true; 102 Restart = "always"; 103 ExecStart = "${htgen.package}/bin/htgen --serve"; 104 }; 105 } 106 ) cfg; 107 108 users.users = mapAttrs' ( 109 name: htgen: 110 nameValuePair htgen.user.name { 111 inherit (htgen.user) home name; 112 group = htgen.user.name; 113 createHome = true; 114 isSystemUser = true; 115 } 116 ) cfg; 117 118 users.groups = mapAttrs' ( 119 _name: htgen: 120 nameValuePair htgen.user.name { 121 name = htgen.user.name; 122 } 123 ) cfg; 124 125 }; 126in 127out