Add prototype raker module to the Nix flake
continuous-integration/drone the build was successful Details

rei/rakerstore_postgres_overhaul
Olivier 'reivilibre' 2022-04-26 20:55:41 +01:00
parent 588d5bdf54
commit 23733efd3f
2 changed files with 89 additions and 0 deletions

View File

@ -42,6 +42,7 @@
# NixOS Modules
nixosModules = {
quickpeepSearch = import ./modules/quickpeepSearch.nix self;
quickpeepRaker = import ./modules/quickpeepRaker.nix self;
};
# `nix run`

View File

@ -0,0 +1,88 @@
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}'';
};
};
};
}