···11-{
22- config,
33- lib,
44- pkgs,
55- ...
66-}: let
77- inherit (lib) mkOption types mdDoc;
88- cfg = config.services.iceshrimp;
99- iceshrimpSettingsFormat = pkgs.formats.yaml {};
1010- iceshrimpConfigFile = iceshrimpSettingsFormat.generate "default.yml" cfg.settings;
1111- stateDir = "/var/lib/iceshrimp";
1212-in {
1313- options.services.iceshrimp = {
1414- enable = lib.mkEnableOption "iceshrimp ActivityPub server";
1515- image = mkOption {
1616- type = types.nonEmptyStr;
1717- default = "iceshrimp.dev/iceshrimp/iceshrimp:latest";
1818- description = mdDoc ''
1919- The docker image to use for the iceshrimp server.
2020- '';
2121- };
2222- listenPort = mkOption {
2323- type = types.port;
2424- example = 3001;
2525- default = 3000;
2626- description = mdDoc ''
2727- The host port that iceshrimp will listen on. Defaults to 3000.
2828- '';
2929- };
3030- settings = mkOption {
3131- description = mdDoc ''
3232- The iceshrimp settings to use, defaults taken from example.yml in the Calckey repo.
3333- Note that you are only required to set the `url` setting, all other settings have defaults. This is to prevent starting an instance with no URL, which doesn't work.
3434- See [The example.yml](https://gitlab.prometheus.systems/iceshrimp/firefish/-/blob/develop/.config/example.yml) for all available keys.
3535- '';
3636- type = types.submodule {
3737- freeformType = iceshrimpSettingsFormat.type;
3838- options = {
3939- url = mkOption {
4040- type = types.nonEmptyStr;
4141- example = "https://example.com";
4242- description = mdDoc ''
4343- The publically accessible URL of the iceshrimp instance.
4444- CANNOT BE CHANGED AFTER INSTALLATION!!
4545- '';
4646- };
4747- accountDomain = mkOption {
4848- type = types.nullOr types.str;
4949- example = "example.social";
5050- default = null;
5151- description =
5252- mdDoc
5353- "OPTIONAL - Domain used for account handles, if you want the frontend at a subdomain but for account handles to be on a root domain, i.e. having the frontend at iceshrimp.example.social but the accounts being of the form @account@example.social.";
5454- };
5555- port = mkOption {
5656- type = types.port;
5757- example = 3001;
5858- default = 3000;
5959- description = mdDoc ''
6060- The listening port for the iceshrimp service INSIDE THE CONTAINER. This is not the external port, which is set in `config.firefish.listenPort`
6161- '';
6262- };
6363- cuid = {
6464- length = mkOption {
6565- type = types.ints.between 16 24;
6666- example = 18;
6767- default = 16;
6868- description = mdDoc ''
6969- The length of the cuid to generate. The default should be fine, but if you are running a large or distributed server, consider increasing it.
7070- '';
7171- };
7272- fingerprint = mkOption {
7373- type = types.nullOr types.nonEmptyStr;
7474- example = "my-fingerprint";
7575- default = null;
7676- description = mdDoc ''
7777- Set this to a unique string across workers(such as the machine's hostname)
7878- ONLY if your workers are running in multiple hosts.
7979- '';
8080- };
8181- };
8282- maxNoteLength = mkOption {
8383- type = types.ints.between 1 100000;
8484- example = 5000;
8585- default = 3000;
8686- description = mdDoc ''
8787- The maximum note length to allow users to send.
8888- '';
8989- };
9090- maxCaptionLength = mkOption {
9191- type = types.ints.between 1 8192;
9292- example = 2000;
9393- default = 1500;
9494- description = mdDoc ''
9595- The maximum caption length to allow users to add to an image.
9696- '';
9797- };
9898- reservedUsernames = mkOption {
9999- type = types.listOf types.nonEmptyStr;
100100- example = ["some" "example" "usernames"];
101101- default = ["root" "admin" "administrator" "me" "system"];
102102- description = mdDoc ''
103103- Usernames that only the administrator is allowed to register with.
104104- '';
105105- };
106106- disableHsts = mkOption {
107107- type = types.bool;
108108- example = false;
109109- default = true;
110110- description = mdDoc ''
111111- Whether to disable HSTS for the iceshrimp server.
112112- '';
113113- };
114114- clusterLimit = mkOption {
115115- type = types.int;
116116- example = 4;
117117- default = 1;
118118- description = mdDoc ''
119119- How many worker processes to run.
120120- '';
121121- };
122122- onlyQueueProcessor = mkOption {
123123- type = types.ints.between 0 1;
124124- example = 1;
125125- default = 0;
126126- description = mdDoc ''
127127- Whether to run in worker-only mode.
128128- '';
129129- };
130130- deliverJobConcurrency = mkOption {
131131- type = types.int;
132132- example = 64;
133133- default = 128;
134134- description = mdDoc ''
135135- The max deliver jobs to run on a worker.
136136- '';
137137- };
138138- inboxJobPerSec = mkOption {
139139- type = types.int;
140140- example = 32;
141141- default = 16;
142142- description = mdDoc ''
143143- The max inbox jobs to run on a worker.
144144- '';
145145- };
146146- deliverJobMaxAttempts = mkOption {
147147- type = types.int;
148148- example = 10;
149149- default = 12;
150150- description = mdDoc ''
151151- The maximum number of times to attempt sending a deliver job before aborting.
152152- '';
153153- };
154154- inboxJobMaxAttempts = mkOption {
155155- type = types.int;
156156- example = 6;
157157- default = 8;
158158- description = mdDoc ''
159159- The maximum number of times to attempt sending an inbox job before aborting.
160160- '';
161161- };
162162- outgoingAddressFamily = mkOption {
163163- type = types.enum ["ipv4" "ipv6" "dual"];
164164- example = "dual";
165165- default = "ipv4";
166166- description = mdDoc ''
167167- The IP address family to use for outgoing requests.
168168- '';
169169- };
170170- syslog = {
171171- host = mkOption {
172172- type = types.nullOr types.nonEmptyStr;
173173- example = "localhost";
174174- default = null;
175175- description = ''
176176- The host that should recieve syslog logs from iceshrimp.
177177- '';
178178- };
179179- port = mkOption {
180180- type = types.nullOr types.port;
181181- example = 514;
182182- default = null;
183183- description = mdDoc ''
184184- The port that the syslog server is listening on.
185185- '';
186186- };
187187- };
188188- proxy = mkOption {
189189- type = types.nullOr types.nonEmptyStr;
190190- example = "http://127.0.0.1:3128";
191191- default = null;
192192- description = mdDoc ''
193193- The HTTP/HTTPS proxy to use.
194194- '';
195195- };
196196- proxyBypassHosts = mkOption {
197197- type = types.listOf types.nonEmptyStr;
198198- example = ["web.kaiteki.app" "127.0.0.1"];
199199- default = [];
200200- description = mdDoc ''
201201- Hosts that should not be connected to with the proxy.
202202- '';
203203- };
204204- proxySmtp = mkOption {
205205- type = types.nullOr types.nonEmptyStr;
206206- example = "http://127.0.0.1:3128";
207207- default = null;
208208- description = mdDoc ''
209209- The proxy to use for SMTP. Can be an http, socks4, or socks5 proxy.
210210- '';
211211- };
212212- mediaProxy = mkOption {
213213- type = types.nullOr types.nonEmptyStr;
214214- example = "https://example.com/proxy";
215215- default = null;
216216- description = mdDoc ''
217217- The proxy to use to send media to the client.
218218- '';
219219- };
220220- proxyRemoteFiles = mkOption {
221221- type = types.bool;
222222- example = true;
223223- default = false;
224224- description = mdDoc "Whether to proxy remote files.";
225225- };
226226- mediaCleanup = {
227227- cron = mkOption {
228228- type = types.bool;
229229- example = true;
230230- default = false;
231231- };
232232- maxAgeDays = mkOption {
233233- type = types.int;
234234- example = 30;
235235- default = 0;
236236- description = mdDoc "The number of days to keep media for";
237237- };
238238- cleanAvatars = mkOption {
239239- type = types.bool;
240240- example = true;
241241- default = false;
242242- description =
243243- mdDoc "Whether to clean avatars on a timer with other media.";
244244- };
245245- cleanHeaders = mkOption {
246246- type = types.bool;
247247- example = true;
248248- default = false;
249249- description =
250250- mdDoc "Whether to clean headers on a timer with other media.";
251251- };
252252- };
253253- images = {
254254- info = mkOption {
255255- type = types.str;
256256- example = "/twemoji/1f440.svg";
257257- default = "/twemoji/1f440.svg";
258258- description = mdDoc "Path to the image to use for the info icon.";
259259- };
260260- notFound = mkOption {
261261- type = types.str;
262262- example = "/twemoji/2049.svg";
263263- default = "/twemoji/2049.svg";
264264- description =
265265- mdDoc "Path to the image to use for the notFound icon.";
266266- };
267267- error = mkOption {
268268- type = types.str;
269269- example = "/twemoji/1f480.svg";
270270- default = "/twemoji/1f480.svg";
271271- description =
272272- mdDoc "Path to the image to use for the error icon.";
273273- };
274274- };
275275- searchEngine = mkOption {
276276- type = types.str;
277277- example = "https://search.brave.com/search?q=";
278278- default = "https://duckduckgo.com/?q=";
279279- description =
280280- mdDoc
281281- "The search engine base string to use for the MFM search box.";
282282- };
283283- allowedPrivateNetworks = mkOption {
284284- type = types.listOf types.nonEmptyStr;
285285- example = ["127.0.0.1/32"];
286286- default = ["127.0.0.1/32"];
287287- description =
288288- mdDoc
289289- "The networks to classify as private when connecting to the server.";
290290- };
291291- twa = {
292292- nameSpace = mkOption {
293293- type = types.nullOr types.nonEmptyStr;
294294- example = "android_app";
295295- default = null;
296296- description = mdDoc "The TWA namespace to allow.";
297297- };
298298- packageName = mkOption {
299299- type = types.nullOr types.nonEmptyStr;
300300- example = "tld.domain.twa";
301301- default = null;
302302- description =
303303- mdDoc
304304- "The name of the android app package that can use this TWA.";
305305- };
306306- sha256CertFingerprints = mkOption {
307307- type = types.nullOr (types.listOf types.nonEmptyStr);
308308- example = ["AB:CD:EF"];
309309- default = null;
310310- description =
311311- mdDoc
312312- "The SHA256 certificate fingerprint(s) of the app package abouve";
313313- };
314314- };
315315- maxFileSize = mkOption {
316316- type = types.int;
317317- example = 100000;
318318- default = 262144000;
319319- description = mdDoc "The max upload file size. Defaults to 250 MB.";
320320- };
321321- };
322322- };
323323- };
324324-325325- envFile = mkOption {
326326- type = types.path;
327327- example = /path/to/secret.env;
328328- default = "";
329329- description = mdDoc ''
330330- The secret environment file to load into the database and iceshrimp server containers.
331331- The file should contain the variable `POSTGRES_PASSWORD`, set to the password of the Postgres database user.
332332- '';
333333- };
334334- };
335335- config = lib.mkIf cfg.enable {
336336- services.iceshrimp.settings = {
337337- db = {
338338- host = "iceshrimp-db";
339339- port = 5432;
340340- db = "iceshrimp";
341341- user = "iceshrimp";
342342- pass = "iceshrimpDBPassword123!";
343343- };
344344- redis = {
345345- host = "iceshrimp-redis";
346346- port = 6379;
347347- };
348348- };
349349- virtualisation.oci-containers.containers = {
350350- iceshrimp-server = {
351351- image = cfg.image;
352352- dependsOn = ["iceshrimp-db" "iceshrimp-redis" ];
353353- environment = {NODE_ENV = "production";};
354354- ports = [
355355- "${builtins.toString cfg.listenPort}:${
356356- builtins.toString cfg.settings.port
357357- }"
358358- ];
359359- volumes = [
360360- "${stateDir}/files:/iceshrimp/files"
361361- "${iceshrimpConfigFile}:/iceshrimp/.config/default.yml:ro"
362362- ];
363363- extraOptions = ["--network=iceshrimp"];
364364- };
365365- iceshrimp-redis = {
366366- image = "docker.io/redis:7.0-alpine";
367367- volumes = ["${stateDir}/redis:/data"];
368368- extraOptions = ["--network=iceshrimp"];
369369- };
370370- iceshrimp-db = {
371371- image = "docker.io/postgres:12.2-alpine";
372372- environment = {
373373- POSTGRES_PASSWORD = "iceshrimpDBPassword123!";
374374- POSTGRES_USER = "iceshrimp";
375375- POSTGRES_DB = "iceshrimp";
376376- };
377377- volumes = ["${stateDir}/db:/var/lib/postgresql/data"];
378378- extraOptions = ["--network=iceshrimp"];
379379- };
380380- };
381381- };
382382-}
-29
modules/pyrox.nix
···11-{
22- config,
33- lib,
44- pkgs,
55- myLib,
66- ...
77-}: let
88- inherit (lib) mkOption types;
99- inherit (myLib) myTypes;
1010- cfg = config.pyrox.services;
1111-in {
1212- # Import all config.pyrox modules
1313- imports = [
1414- ./forgejo-runner.nix
1515- ];
1616-1717- options.pyrox.metadata = {
1818- hosts = mkOption {
1919- description = "Each host that is in the PyroNet Network";
2020- type = types.attrsOf (myTypes.hostModule);
2121- };
2222- serviceHosts = mkOption {
2323- description = "The services and what hosts they run on.";
2424- type = types.submodule {
2525- freeformType = types.anything;
2626- };
2727- };
2828- };
2929-}