blob: eb88e21f9eb8e96d83b98946f94e1c1d9209b838 (
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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
{
lib,
my-lib,
...
}: let
inherit (lib) mkOption mkEnableOption types;
inherit (my-lib.netTypes {inherit lib;}) ipAddr;
# A helper function to generate the submodule
webserviceOptions = {
service_name,
default_port ? null,
reverse_proxy ? true,
}:
{
enable = mkEnableOption "${service_name} selfhosted service";
listenAddr = mkOption {
description = "The IP address on which ${service_name} will listen for incoming connections";
type = ipAddr;
default = "127.0.0.1";
};
privateUrl = mkOption {
description = "Internal .local name for the service. Don't put the protocol (https://) in the string";
type = lib.types.nullOr lib.types.str;
default = null;
};
publicUrl = mkOption {
description = "Public website on which the service will be hosted. Don't put the protocol (https://) in the string";
type = lib.types.nullOr lib.types.str;
default = null;
};
}
// (
if reverse_proxy
then {
reverseProxy = mkOption {
internal = true;
type = lib.types.bool;
default = true;
};
port = mkOption {
description = "The port on which ${service_name} will listen for incomming connections";
type = lib.types.port;
default = default_port;
};
}
else {
manualCaddyConfig = mkOption {
description = "Configuration to describe this service in caddy, since reverse_proxy = false.";
type = lib.types.str;
};
}
);
in {
options.collinux.services = {
sshd = {
enable = mkEnableOption "OpenSSH server";
portConfig = mkOption {
description = "List of ssh bind hosts. see submodule options for details";
type = lib.types.listOf (lib.types.submodule {
options = {
port = mkOption {
description = "Port to run on";
type = lib.types.port;
};
listenAddr = mkOption {
description = "Address to listen on";
type = lib.types.str;
default = "127.0.0.1";
};
otp = mkEnableOption "Whether to require TOTP (Google Authenticator) 2fa codes for this port";
rootLogin = mkEnableOption "Whether to allow root login for this port";
};
});
};
};
forgejo = webserviceOptions {
service_name = "forgejo";
default_port = 8010;
};
goaccess = webserviceOptions {
service_name = "goaccess";
reverse_proxy = false;
};
cgit = webserviceOptions {
service_name = "cgit";
reverse_proxy = false;
};
polaris = webserviceOptions {
service_name = "polaris";
default_port = 8079;
};
qbittorrent = webserviceOptions {
service_name = "qbittorrent";
default_port = 8076;
};
copyparty =
(webserviceOptions {
service_name = "copyparty";
default_port = 8099;
})
// {
users = mkOption {
type = lib.types.attrsOf (lib.types.submodule ({config, ...}: {
options = {
name = mkOption {
type = lib.types.str;
default = config._module.args.name;
internal = true;
};
isAdmin = mkEnableOption "whether this user is an admin";
passwordFile = mkOption {
description = "Absolute path to a file containing the password for this user";
type = lib.types.str;
example = "/run/secrets.d/copyparty-passwd";
};
hasPublicDir = mkEnableOption "give this user a world-readable directory at /public/<username>";
};
}));
};
};
caddy = {
enable = mkEnableOption "caddy https server";
envFile = mkOption {
type = types.str;
example = "/run/secrets.d/caddy-env";
};
};
};
}
|