1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00

htgen: update

This commit is contained in:
2025-12-19 12:44:58 +01:00
parent 2f5ad473c6
commit 9ab93d0e82
3 changed files with 111 additions and 53 deletions

View File

@@ -3,45 +3,108 @@
lib,
pkgs,
...
}: let
}:
let
optionalAttr = name: value: if name != null then { ${name} = value; } else { };
cfg = config.services.htgen;
out = {
options.services.htgen = api;
config = imp;
};
htgen = pkgs.callPackage ../packages/htgen.nix { };
in {
options.services.htgen = lib.mkOption {
api =
with lib;
mkOption {
default = { };
type = lib.types.attrsOf (lib.types.submodule ({config, ...}: {
type = types.attrsOf (
types.submodule (
{ config, ... }:
{
options = {
enable = lib.mkEnableOption "htgen-${config._module.args.name}";
port = lib.mkOption {
type = lib.types.int;
enable = mkEnableOption "services.htgen-${config._module.args.name}";
name = mkOption {
type = types.str;
default = config._module.args.name;
};
script = lib.mkOption {
type = lib.types.str;
package = mkOption {
default = htgen;
type = types.package;
};
port = mkOption {
type = types.port;
};
script = mkOption {
type = types.nullOr types.str;
default = null;
};
scriptFile = mkOption {
type = types.nullOr (types.either types.package types.pathname);
default = null;
};
user = mkOption {
default = {
name = "htgen-${config.name}";
home = "/var/lib/htgen-${config.name}";
};
defaultText = {
name = "htgen-name";
home = "/var/lib/htgen-name";
};
};
}));
};
config = {
systemd.services =
lib.mapAttrs' (
name: cfg:
}
)
);
};
imp = {
systemd.services = lib.mapAttrs' (
name: htgen:
lib.nameValuePair "htgen-${name}" {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
environment = {
HOME = "/var/lib/htgen-${name}";
HTGEN_PORT = toString cfg.port;
HTGEN_SCRIPT = cfg.script;
};
HTGEN_PORT = toString htgen.port;
}
// optionalAttr "HTGEN_SCRIPT" htgen.script
// optionalAttr "HTGEN_SCRIPT_FILE" htgen.scriptFile;
serviceConfig = {
SyslogIdentifier = "htgen-${name}";
DynamicUser = true;
StateDirectory = "htgen-${name}";
SyslogIdentifier = "htgen";
User = htgen.user.name;
PrivateTmp = true;
Restart = "always";
ExecStart = "${htgen}/bin/htgen --serve";
ExecStart = "${htgen.package}/bin/htgen --serve";
};
}
)
config.services.htgen;
};
) cfg;
users.users = lib.mapAttrs' (
name: htgen:
lib.nameValuePair htgen.user.name {
inherit (htgen.user) home name;
group = htgen.user.name;
createHome = true;
isSystemUser = true;
}
) cfg;
users.groups = lib.mapAttrs' (
name: htgen:
lib.nameValuePair htgen.user.name {
name = htgen.user.name;
}
) cfg;
};
in
out

View File

@@ -1,17 +1,12 @@
{
fetchgit,
lib,
pkgs,
stdenv,
}:
{ fetchgit, lib, pkgs, stdenv }:
stdenv.mkDerivation rec {
pname = "htgen";
version = "1.3.1";
version = "1.4.0";
src = fetchgit {
url = "http://cgit.krebsco.de/htgen";
url = "https://cgit.krebsco.de/htgen";
rev = "refs/tags/${version}";
sha256 = "0ml8kp89bwkrwy6iqclzyhxgv2qn9dcpwaafbmsr4mgcl70zx22r";
sha256 = "1k6xdr4g1p2wjiyizwh33ihw3azbar7kmhyxywcq0whpip9inpmj";
};
installPhase = ''

View File

@@ -17,7 +17,7 @@
in {
services.htgen.tarot = {
port = tarotPort;
script = ''. ${pkgs.writers.writeDash "tarot" ''
script = pkgs.writers.writeDash "tarot" ''
case "$Method $Request_URI" in
"GET /")
if item=$(${pkgs.findutils}/bin/find ${toString tarotFiles} -type f | ${pkgs.coreutils}/bin/shuf -n1); then
@@ -40,7 +40,7 @@ in {
fi
;;
esac
''}'';
'';
};
niveum.passport.services = [