2021-04-08 02:19:54 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2021-03-28 22:08:19 +02:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.my.services.lohr;
|
|
|
|
my = config.my;
|
|
|
|
domain = config.networking.domain;
|
2021-04-08 02:19:54 +02:00
|
|
|
secrets = config.my.secrets;
|
|
|
|
lohrPkg =
|
|
|
|
let
|
|
|
|
flake = builtins.getFlake "github:alarsyo/lohr?rev=bc32f8a565faa2055c1bbfa8c2353ce4738208b2";
|
|
|
|
in
|
|
|
|
flake.defaultPackage."x86_64-linux"; # FIXME: use correct system
|
2021-03-28 22:08:19 +02:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.services.lohr = {
|
|
|
|
enable = lib.mkEnableOption "Lohr Mirroring Daemon";
|
|
|
|
|
|
|
|
home = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/lohr";
|
|
|
|
example = "/var/lib/lohr";
|
|
|
|
description = "Home for the lohr service, where data will be stored";
|
|
|
|
};
|
2021-04-08 02:19:54 +02:00
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 8080;
|
|
|
|
example = 8080;
|
|
|
|
description = "Internal port for Lohr daemon";
|
|
|
|
};
|
2021-03-28 22:08:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-04-08 02:19:54 +02:00
|
|
|
systemd.services.lohr = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Environment = [
|
|
|
|
"ROCKET_PORT=${toString cfg.port}"
|
|
|
|
"ROCKET_LOG_LEVEL=normal"
|
|
|
|
"LOHR_HOME=${cfg.home}"
|
|
|
|
"'LOHR_SECRET=${secrets.lohr-shared-secret}'"
|
|
|
|
];
|
|
|
|
ExecStart = "${lohrPkg}/bin/lohr";
|
|
|
|
StateDirectory = "lohr";
|
|
|
|
WorkingDirectory = "/var/lib/lohr";
|
|
|
|
User = "lohr";
|
|
|
|
Group = "lohr";
|
|
|
|
};
|
|
|
|
path = with pkgs; [
|
|
|
|
git
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
users.users.lohr = {
|
|
|
|
isSystemUser = true;
|
|
|
|
home = cfg.home;
|
|
|
|
createHome = true;
|
|
|
|
group = "lohr";
|
|
|
|
};
|
|
|
|
users.groups.lohr = { };
|
|
|
|
|
2021-03-28 22:08:19 +02:00
|
|
|
services.nginx.virtualHosts = {
|
|
|
|
"lohr.${domain}" = {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
|
|
|
|
locations."/" = {
|
2021-04-08 02:19:54 +02:00
|
|
|
proxyPass = "http://127.0.0.1:${toString cfg.port}";
|
2021-03-28 22:08:19 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|