services: scribe: setup scribe service

This commit is contained in:
Antoine Martin 2023-01-29 01:35:51 +01:00
parent 98394281bf
commit cab7845ee7
3 changed files with 77 additions and 0 deletions

View file

@ -113,6 +113,11 @@ in {
paths = ["/home/alarsyo"];
};
scribe = {
enable = true;
port = 8087;
};
tailscale = {
enable = true;
exitNode = true;

View file

@ -20,6 +20,7 @@
./postgresql-backup.nix
./postgresql.nix
./restic-backup.nix
./scribe.nix
./tailscale.nix
./transmission.nix
];

71
services/scribe.nix Normal file
View file

@ -0,0 +1,71 @@
{
config,
lib,
pkgs,
...
}: let
inherit
(lib)
mkEnableOption
mkIf
mkOption
;
cfg = config.my.services.scribe;
my = config.my;
domain = config.networking.domain;
hostname = config.networking.hostName;
fqdn = "${hostname}.${domain}";
in {
options.my.services.scribe = let
inherit (lib) types;
in {
enable = mkEnableOption "Scribe config";
home = mkOption {
type = types.str;
default = "/var/lib/scribe";
example = "/var/lib/scribe";
description = "Home for the scribe service, where data will be stored";
};
port = mkOption {
type = types.port;
default = 2343;
example = 8080;
description = "Internal port for Scribe service";
};
};
config = mkIf cfg.enable {
users.users.scribe = {
isSystemUser = true;
home = cfg.home;
createHome = true;
group = "scribe";
};
users.groups.scribe = {};
services.nginx.virtualHosts = {
"scribe.${domain}" = {
forceSSL = true;
useACMEHost = fqdn;
locations."/" = {
proxyPass = "http://127.0.0.1:${toString cfg.port}";
proxyWebsockets = true;
};
extraConfig = ''
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
client_max_body_size 200m;
'';
};
};
security.acme.certs.${fqdn}.extraDomainNames = ["scribe.${domain}"];
};
}