stuebinm
9dfac9818e
This is a first attempt to package octycs' keytracker [1] application. It's more a quick-and-dirty approach, so there are a couple things to note: - the config file is just generated by Nix as whatever the module got in its config option stuffed into a toml file. There are no default values, so all values must be set by hand – or rather, we just write the default values in the config. - I couldn't figure out how to actually make this thing work. It looks like it /should/ work, but gets hung up every time on loading key information via the web interface. Then again, it appears our current config on libocedrus also doesn't conform to what the readme says, so perhaps I just missed something that's as-yet undocumented. - The module just calls python instead of an actual server as backend. This is recommended just for development/testing, not actual deploys [2], but since the project is missing a setup.py which afaik are required to package these things more sensibly [3], that's it for now. - keys and corresponding tokens are currently baked into the nix store. This seems a bad idea, and I'll fix it as soon as I find the time. [1] https://gitlab.infra4future.de/octycs/keytracker [2] https://gitlab.infra4future.de/octycs/keytracker/-/blob/master/server/Readme.md [3] https://flask.palletsprojects.com/en/1.1.x/tutorial/deploy/
64 lines
1.4 KiB
Nix
64 lines
1.4 KiB
Nix
{pkgs, lib, config, ...}:
|
|
|
|
with lib;
|
|
let format = pkgs.formats.toml {};
|
|
in
|
|
{
|
|
options.services.keytracker = {
|
|
enable = mkOption {
|
|
default = false;
|
|
type = types.bool;
|
|
};
|
|
domain = mkOption {
|
|
default = "example.org";
|
|
type = types.str;
|
|
};
|
|
frontendPackage = mkOption {
|
|
default = pkgs.keytracker-frontend;
|
|
type = types.package;
|
|
};
|
|
serverPackage = mkOption {
|
|
default = pkgs.keytracker-server;
|
|
type = types.package;
|
|
};
|
|
stateDir = mkOption {
|
|
default = "/var/lib/keytracker";
|
|
type = types.str;
|
|
};
|
|
config = mkOption {
|
|
default = {};
|
|
type = format.type;
|
|
};
|
|
nginx = mkOption {
|
|
default = {};
|
|
type = types.attrs;
|
|
};
|
|
};
|
|
|
|
config =
|
|
let cfg = config.services.keytracker;
|
|
configfile = format.generate "config" cfg.config;
|
|
in {
|
|
services.nginx = mkIf cfg.enable {
|
|
enable = true;
|
|
virtualHosts.${cfg.domain} = {
|
|
root = cfg.frontendPackage.outPath;
|
|
} // cfg.nginx;
|
|
};
|
|
|
|
systemd.services = mkIf cfg.enable {
|
|
"keytracker" = {
|
|
enable = true;
|
|
description = "Keytracker backend server";
|
|
wantedBy = [ "multi-user.target" ];
|
|
serviceConfig.Type = "simple";
|
|
script = ''
|
|
mkdir -p ${cfg.stateDir}
|
|
cd ${cfg.stateDir}
|
|
ln -sf ${configfile} config
|
|
${cfg.serverPackage}/wrapped
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
}
|