2023-09-12 08:44:05 -06:00
|
|
|
{ config
|
|
|
|
, lib
|
|
|
|
, pkgs
|
|
|
|
, ...
|
2023-07-11 09:12:50 -06:00
|
|
|
}:
|
|
|
|
with pkgs; let
|
2022-10-11 09:28:16 -06:00
|
|
|
cfg = config.services.yarr;
|
2023-09-12 08:44:05 -06:00
|
|
|
yarr = callPackage ../pkgs/yarr.nix { };
|
|
|
|
in
|
|
|
|
{
|
2022-10-11 09:28:16 -06:00
|
|
|
options = with lib; {
|
|
|
|
services.yarr = {
|
|
|
|
enable = mkEnableOption "Enable yarr";
|
|
|
|
|
|
|
|
directory = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/yarr";
|
|
|
|
description = "Persistent directory to house database.";
|
|
|
|
};
|
|
|
|
|
|
|
|
basePath = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = "Base path of the service URL.";
|
|
|
|
};
|
|
|
|
|
|
|
|
authFilePath = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/run/secrets/yarr_auth";
|
|
|
|
description = "Path to file containing authentication information.";
|
|
|
|
};
|
|
|
|
|
|
|
|
address = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "127.0.0.1";
|
|
|
|
description = ''
|
|
|
|
Address to run yarr on.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 7070;
|
|
|
|
description = "Port to listen on";
|
|
|
|
};
|
|
|
|
|
|
|
|
dbPath = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "${cfg.directory}/storage.db";
|
|
|
|
description = "Full path to the database file.";
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
2023-09-12 08:44:05 -06:00
|
|
|
type = with types; oneOf [ str int ];
|
2022-10-11 09:28:16 -06:00
|
|
|
default = "yarr";
|
|
|
|
description = ''
|
|
|
|
The user the service will use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
2023-09-12 08:44:05 -06:00
|
|
|
type = with types; oneOf [ str int ];
|
2022-10-11 09:28:16 -06:00
|
|
|
default = "yarr";
|
|
|
|
description = ''
|
|
|
|
The user the service will use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = yarr;
|
|
|
|
defaultText = literalExpression "pkgs.yarr";
|
|
|
|
description = "The package to use for yarr";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
2023-09-12 08:44:05 -06:00
|
|
|
users.groups.yarr = { };
|
2022-10-11 09:28:16 -06:00
|
|
|
users.users.yarr = {
|
|
|
|
description = "Yarr service user";
|
|
|
|
isSystemUser = true;
|
|
|
|
home = "${cfg.directory}";
|
|
|
|
createHome = true;
|
|
|
|
group = "yarr";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.yarr = {
|
|
|
|
enable = true;
|
|
|
|
description = "Yet Another Rss Reader server";
|
2023-09-12 08:44:05 -06:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "networking.service" ];
|
2022-10-11 09:28:16 -06:00
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
|
|
|
|
2022-10-12 20:34:56 -06:00
|
|
|
ExecStart = "${cfg.package}/bin/yarr -addr ${cfg.address}:${
|
2023-07-11 09:12:50 -06:00
|
|
|
toString cfg.port
|
|
|
|
} -db ${cfg.dbPath} -auth-file ${cfg.authFilePath}";
|
2022-10-11 09:28:16 -06:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|