blob: 3bc9d107e474139caf6213df5ad0cab8d53b1697 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
self:
{ config, pkgs, lib, ... }:
with lib;
let
system = pkgs.system;
selfpkgs = self.packages.${system};
cfg = config.xeserv.services.todayinmarch2020;
in {
options.xeserv.services.todayinmarch2020 = {
enable = mkEnableOption "Lets you find out what day in 2020 today is";
useACME = mkEnableOption "Enables ACME for cert stuff";
domain = mkOption {
type = types.str;
default = "todayinmarch2020.xn--sz8hf6d.ws";
example = "todayinmarch2020.xn--sz8hf6d.ws";
description =
"The domain name that nginx should check against for HTTP hostnames";
};
sockPath = mkOption rec {
type = types.str;
default = "/srv/within/run/todayinmarch2020.sock";
example = default;
description = "The unix domain socket that printerfacts should listen on";
};
};
config = mkIf cfg.enable {
users.users.todayinmarch2020 = {
createHome = true;
description = "tulpa.dev/cadey/todayinmarch2020";
isSystemUser = true;
group = "within";
home = "/srv/within/todayinmarch2020";
};
systemd.services.todayinmarch2020 = {
wantedBy = [ "multi-user.target" ];
after = [ "within-homedir.service" ];
serviceConfig = {
User = "todayinmarch2020";
Group = "within";
Restart = "on-failure";
WorkingDirectory = "/srv/within/todayinmarch2020";
RestartSec = "30s";
UMask = "007";
};
script = ''
exec ${selfpkgs.todayinmarch2020}/bin/todayinmarch2020 -socket=${cfg.sockPath}
'';
};
services.nginx.virtualHosts."todayinmarch2020" = {
serverName = "${cfg.domain}";
locations."/".proxyPass = "http://unix:${cfg.sockPath}";
enableACME = true;
extraConfig = ''
access_log /var/log/nginx/todayinmarch2020.access.log;
'';
};
};
}
|