2023-12-30 20:13:48 +00:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
let
|
2024-01-01 12:16:11 +00:00
|
|
|
cfg = config.lab.data-sharing;
|
2024-02-12 21:30:29 +00:00
|
|
|
|
2023-12-30 20:13:48 +00:00
|
|
|
nfsShares = [
|
2024-01-01 12:16:11 +00:00
|
|
|
"/nextcloud/data"
|
|
|
|
"/radicale"
|
|
|
|
"/freshrss/data"
|
|
|
|
"/freshrss/extensions"
|
|
|
|
"/pihole/data"
|
|
|
|
"/pihole/dnsmasq"
|
|
|
|
"/hedgedoc/uploads"
|
|
|
|
"/traefik/acme"
|
2024-04-20 11:00:41 +00:00
|
|
|
"/forgejo/data"
|
|
|
|
"/forgejo/runner/data"
|
|
|
|
"/forgejo/runner/certs"
|
2024-01-01 12:16:11 +00:00
|
|
|
"/kitchenowl/data"
|
|
|
|
"/syncthing/config"
|
2024-01-15 20:34:25 +00:00
|
|
|
"/paperless-ngx/data"
|
|
|
|
"/paperless-ngx/redisdata"
|
2024-02-12 21:30:29 +00:00
|
|
|
"/media"
|
2024-02-12 23:11:26 +00:00
|
|
|
"/media/books"
|
|
|
|
"/media/movies"
|
|
|
|
"/media/music"
|
|
|
|
"/media/shows"
|
2024-02-12 21:30:29 +00:00
|
|
|
"/jellyfin/config"
|
2024-02-12 23:11:26 +00:00
|
|
|
"/transmission/config"
|
2024-02-15 08:27:08 +00:00
|
|
|
"/jellyseerr/config"
|
2024-02-18 10:14:07 +00:00
|
|
|
"/radarr/config"
|
|
|
|
"/prowlarr/config"
|
2024-02-18 17:19:39 +00:00
|
|
|
"/sonarr/config"
|
2024-02-24 20:45:29 +00:00
|
|
|
"/bazarr/config"
|
2024-04-13 20:21:26 +00:00
|
|
|
"/minecraft"
|
2024-04-27 18:53:32 +00:00
|
|
|
"/atticd"
|
2024-05-20 15:47:49 +00:00
|
|
|
"/longhorn-backup"
|
2023-12-30 20:13:48 +00:00
|
|
|
];
|
2024-02-12 21:30:29 +00:00
|
|
|
|
2023-12-30 20:13:48 +00:00
|
|
|
nfsExports = lib.strings.concatLines (
|
|
|
|
builtins.map
|
|
|
|
(share:
|
2024-03-22 21:19:44 +00:00
|
|
|
"${cfg.nfsRoot}${share} 192.168.30.0/16(rw,sync,no_subtree_check,no_root_squash)"
|
2023-12-30 20:13:48 +00:00
|
|
|
)
|
|
|
|
nfsShares
|
|
|
|
);
|
|
|
|
in
|
|
|
|
{
|
2024-01-01 12:16:11 +00:00
|
|
|
options.lab.data-sharing = {
|
2023-12-30 20:13:48 +00:00
|
|
|
enable = lib.mkOption {
|
|
|
|
default = false;
|
|
|
|
type = lib.types.bool;
|
|
|
|
description = ''
|
2024-01-01 12:16:11 +00:00
|
|
|
Configure this server to serve our data using NFS and PostgreSQL.
|
2023-12-30 20:13:48 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
nfsRoot = lib.mkOption {
|
2024-01-01 12:16:11 +00:00
|
|
|
default = "/mnt/data/nfs";
|
2023-12-30 20:13:48 +00:00
|
|
|
type = lib.types.str;
|
|
|
|
description = ''
|
|
|
|
Root directory of NFS data.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
postgresDir = lib.mkOption {
|
|
|
|
default = "/mnt/data/postgresql/${config.services.postgresql.package.psqlSchema}";
|
|
|
|
type = lib.types.str;
|
|
|
|
description = ''
|
|
|
|
Postgresql data directory.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
2024-03-22 21:19:44 +00:00
|
|
|
networking.firewall.allowedTCPPorts = [
|
2024-01-01 12:16:11 +00:00
|
|
|
2049 # NFS
|
|
|
|
5432 # PostgeSQL
|
|
|
|
111 # NFS
|
|
|
|
20048 # NFS
|
|
|
|
];
|
2023-12-30 20:13:48 +00:00
|
|
|
|
|
|
|
services = {
|
|
|
|
nfs.server = {
|
|
|
|
enable = true;
|
|
|
|
exports = nfsExports;
|
|
|
|
};
|
|
|
|
|
|
|
|
postgresql = {
|
|
|
|
enable = true;
|
|
|
|
package = pkgs.postgresql_15;
|
|
|
|
enableTCPIP = true;
|
|
|
|
|
|
|
|
dataDir = cfg.postgresDir;
|
|
|
|
|
|
|
|
authentication = ''
|
2024-01-06 19:17:45 +00:00
|
|
|
host nextcloud nextcloud all md5
|
|
|
|
host hedgedoc hedgedoc all md5
|
2024-01-15 20:34:25 +00:00
|
|
|
host paperless paperless all md5
|
2024-04-27 18:53:32 +00:00
|
|
|
host attic attic all md5
|
2023-12-30 20:13:48 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|