blob: 652dc8840252dda16c44f42b41615cafdb14f758 (
plain) (
blame)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
{ config, lib, pkgs, ... }:
let
inherit (lib) mkEnableOption mkIf mkOption mdDoc types literalExpression;
cfg = config.services.meme-bingo-web;
in {
options = {
services.meme-bingo-web = {
enable = mkEnableOption (mdDoc ''
a web app for the meme bingo, rendered entirely on the web server and made interactive with forms.
Note: The application's author suppose to run meme-bingo-web behind a reverse proxy for SSL and HTTP/3
'');
package = mkOption {
type = types.package;
default = pkgs.meme-bingo-web;
defaultText = literalExpression "pkgs.meme-bingo-web";
description = mdDoc "meme-bingo-web package to use.";
};
baseUrl = mkOption {
description = mdDoc ''
URL to be used for the HTML <base> element on all HTML routes.
'';
type = types.str;
default = "http://localhost:41678/";
example = "https://bingo.example.com/";
};
port = mkOption {
description = mdDoc ''
Port to be used for the web server.
'';
type = types.port;
default = 41678;
example = 21035;
};
};
};
config = mkIf cfg.enable {
systemd.services.meme-bingo-web = {
description = "A web app for playing meme bingos.";
wantedBy = [ "multi-user.target" ];
environment = {
MEME_BINGO_BASE = cfg.baseUrl;
MEME_BINGO_PORT = toString cfg.port;
};
path = [ cfg.package ];
serviceConfig = {
User = "meme-bingo-web";
Group = "meme-bingo-web";
DynamicUser = true;
ExecStart = "${cfg.package}/bin/meme-bingo-web";
Restart = "always";
RestartSec = 1;
# Hardening
CapabilityBoundingSet = [ "" ];
DeviceAllow = [ "/dev/random" ];
LockPersonality = true;
PrivateDevices = true;
PrivateUsers = true;
ProcSubset = "pid";
ProtectSystem = "strict";
ProtectClock = true;
ProtectControlGroups = true;
ProtectHome = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectProc = "invisible";
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
RestrictNamespaces = true;
RestrictRealtime = true;
SystemCallArchitectures = "native";
SystemCallFilter = [ "@system-service" "~@privileged" "~@resources" ];
UMask = "0077";
RestrictSUIDSGID = true;
RemoveIPC = true;
NoNewPrivileges = true;
MemoryDenyWriteExecute = true;
};
};
};
}
|