111 lines
2.9 KiB
Nix
111 lines
2.9 KiB
Nix
flake: {config, pkgs, lib, ...}:
|
|
|
|
let
|
|
cfg = config.services.quickpeepSearch;
|
|
inherit (flake.packages.${pkgs.stdenv.hostPlatform.system}) quickpeep;
|
|
in
|
|
|
|
with lib;
|
|
|
|
{
|
|
options = {
|
|
services.quickpeepSearch = {
|
|
enable = mkOption {
|
|
default = false;
|
|
type = with types; bool;
|
|
description = ''
|
|
Start the QuickPeep Search web interface.
|
|
'';
|
|
};
|
|
|
|
user = mkOption {
|
|
default = "quickpeep";
|
|
type = with types; uniq str;
|
|
description = ''
|
|
Name of the user.
|
|
'';
|
|
};
|
|
|
|
bindHost = mkOption {
|
|
default = "127.0.0.1";
|
|
type = with types; str;
|
|
description = ''
|
|
Host upon which to bind the web interface.
|
|
'';
|
|
};
|
|
|
|
bindPort = mkOption {
|
|
default = 9733;
|
|
type = with types; int;
|
|
description = ''
|
|
Port upon which to bind the web interface.
|
|
'';
|
|
};
|
|
|
|
configPath = mkOption {
|
|
type = with types; path;
|
|
description = ''
|
|
Config path to use, in RON format.
|
|
'';
|
|
};
|
|
|
|
workingDir = mkOption {
|
|
type = with types; path;
|
|
description = ''
|
|
Path to a working directory to run the web interface and indexer from.
|
|
This is the base from which paths in the config file are looked up from.
|
|
'';
|
|
};
|
|
|
|
autoIndexUrl = mkOption {
|
|
default = null;
|
|
type = with types; nullOr str;
|
|
description = ''
|
|
HTTP(S) URL to an index (list) of rakepacks.
|
|
If specified, the indexer will periodically fetch new packs from that list and then add the pages within to the search index.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
users.users."${cfg.user}" = {
|
|
description = "QuickPeep User";
|
|
isSystemUser = true;
|
|
group = "${cfg.user}";
|
|
};
|
|
users.groups."${cfg.user}" = {};
|
|
|
|
systemd.services.quickpeepSearch = {
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network.target" ];
|
|
description = "Start the QuickPeep Search web interface.";
|
|
|
|
environment = {
|
|
QUICKPEEP_CONFIG = cfg.configPath;
|
|
};
|
|
serviceConfig = {
|
|
Type = "simple";
|
|
User = "${cfg.user}";
|
|
ExecStart = ''${quickpeep}/bin/quickpeep ${cfg.bindHost}:${builtins.toString cfg.bindPort}'';
|
|
WorkingDirectory = cfg.workingDir;
|
|
};
|
|
};
|
|
|
|
systemd.services.quickpeepIndex = mkIf (cfg.autoIndexUrl != null) {
|
|
after = [ "network.target" ];
|
|
description = "Fetches rakepacks from a feed and adds pages to the search index.";
|
|
serviceConfig = {
|
|
Type = "simple";
|
|
User = "${cfg.user}";
|
|
ExecStart = ''${quickpeep}/bin/qp-indexer --config ${lib.strings.escapeShellArg cfg.configPath} --feed ${lib.strings.escapeShellArg cfg.autoIndexUrl}'';
|
|
WorkingDirectory = cfg.workingDir;
|
|
};
|
|
};
|
|
|
|
# TODO systemd.timers.quickpeepIndex = mkIf (cfg.autoIndexUrl != null) {
|
|
#
|
|
# };
|
|
};
|
|
}
|