89 lines
2.2 KiB
Nix
89 lines
2.2 KiB
Nix
flake: {config, pkgs, lib, ...}:
|
|
|
|
let
|
|
cfg = config.services.quickpeepRaker;
|
|
inherit (flake.packages.${pkgs.stdenv.hostPlatform.system}) quickpeep;
|
|
in
|
|
|
|
with lib;
|
|
|
|
{
|
|
options = {
|
|
services.quickpeepRaker = {
|
|
enable = mkOption {
|
|
default = false;
|
|
type = with types; bool;
|
|
description = ''
|
|
Start the QuickPeep Raker.
|
|
'';
|
|
};
|
|
|
|
user = mkOption {
|
|
default = "quickpeep";
|
|
type = with types; uniq str;
|
|
description = ''
|
|
Name of the user.
|
|
'';
|
|
};
|
|
|
|
# metricsBind = mkOption {
|
|
# default = null;
|
|
# example = "127.0.0.1:1234";
|
|
# type = with types; nullOr str;
|
|
# description = ''
|
|
# Host and port upon which to bind the Prometheus/OpenMetrics interface.
|
|
# '';
|
|
# };
|
|
|
|
configPath = mkOption {
|
|
type = with types; path;
|
|
description = ''
|
|
Config path to use, in RON format.
|
|
'';
|
|
};
|
|
|
|
concurrency = mkOption {
|
|
type = types.int;
|
|
default = 8;
|
|
description = ''
|
|
Number of concurrent fetches to allow.
|
|
'';
|
|
};
|
|
|
|
sleepers = mkOption {
|
|
type = types.int;
|
|
default = 56;
|
|
description = ''
|
|
An additional number of tasks to permit in the sleeping state.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
users.users."${cfg.user}" = {
|
|
description = "QuickPeep User";
|
|
isSystemUser = true;
|
|
group = "${cfg.user}";
|
|
};
|
|
users.groups."${cfg.user}" = {};
|
|
|
|
systemd.services.quickpeepRaker = {
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network.target" ];
|
|
description = "Rakes websites and converts them to an indexable format.";
|
|
|
|
environment = {
|
|
QUICKPEEP_CONFIG = cfg.configPath;
|
|
};
|
|
serviceConfig = {
|
|
# TODO disable automatic restart?
|
|
# TODO start it on a timer to ensure it picks up updates to stuff..?
|
|
Type = "simple";
|
|
User = "${cfg.user}";
|
|
ExecStart = ''${quickpeep}/bin/qp-raker --config ${cfg.configPath} --concurrency ${builtins.toString cfg.concurrency} --sleepers ${builtins.toString cfg.sleepers}'';
|
|
};
|
|
};
|
|
};
|
|
}
|