2024-10-28 13:12:06 +00:00
|
|
|
{
|
|
|
|
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-05-26 12:34:19 +00:00
|
|
|
"/mnt/longhorn/persistent/media"
|
|
|
|
"/mnt/longhorn/persistent/media/books"
|
|
|
|
"/mnt/longhorn/persistent/media/movies"
|
|
|
|
"/mnt/longhorn/persistent/media/music"
|
|
|
|
"/mnt/longhorn/persistent/media/shows"
|
|
|
|
"/mnt/longhorn/persistent/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
|
2024-10-28 13:12:06 +00:00
|
|
|
(
|
|
|
|
share: "${share} 192.168.30.0/16(rw,sync,no_subtree_check,no_root_squash) 127.0.0.1/8(rw,sync,no_subtree_check,no_root_squash) 10.0.0.0/8(rw,sync,no_subtree_check,no_root_squash)"
|
|
|
|
)
|
|
|
|
nfsShares
|
2023-12-30 20:13:48 +00:00
|
|
|
);
|
2024-10-28 13:12:06 +00:00
|
|
|
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
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
111 # NFS
|
|
|
|
20048 # NFS
|
|
|
|
];
|
2023-12-30 20:13:48 +00:00
|
|
|
|
2024-05-25 16:05:44 +00:00
|
|
|
services.nfs.server = {
|
|
|
|
enable = true;
|
|
|
|
exports = nfsExports;
|
2023-12-30 20:13:48 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|