refactor(nfs): use more nix code for abstraction
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-01-24 21:57:24 -05:00
parent f885f7b316
commit 4371753913

View file

@ -1,14 +1,27 @@
# TODO: move this to NAS?
{...}: {
{lib, ...}: let
inherit (lib) concatMapStringsSep concatStringsSep;
in {
services.nfs.server = {
enable = true;
createMountPoints = true;
exports = ''
/export 10.0.0.244(rw,crossmnt,fsid=0,no_root_squash) 10.0.0.159(rw,crossmnt,fsid=0,no_root_squash) 100.64.0.8(rw,crossmnt,fsid=0,no_root_squash) 100.64.0.9(rw,crossmnt,fsid=0,no_root_squash)
/export/caddy 10.0.0.244(rw,nohide,no_root_squash) 10.0.0.159(rw,nohide,no_root_squash) 100.64.0.8(rw,nohide,no_root_squash) 100.64.0.9(rw,nohide,no_root_squash)
/export/headscale 10.0.0.244(rw,nohide,no_root_squash) 10.0.0.159(rw,nohide,no_root_squash) 100.64.0.8(rw,nohide,no_root_squash) 100.64.0.9(rw,nohide,no_root_squash)
exports = let
mkExport = dir: opts: ips: "/export${dir} ${
concatMapStringsSep " "
(ip: ip + "(${concatStringsSep "," opts})")
ips
}";
mkRootExport = opts: ips:
mkExport "" (opts ++ ["crossmnt" "fsid=0"]) ips;
allowedIps = ["10.0.0.244" "100.64.0.8" "10.0.0.159" "100.64.0.9"];
options = ["rw" "no_root_squash" "no_subtree_check"];
in ''
${mkRootExport options allowedIps}
${mkExport "/caddy" options allowedIps}
${mkExport "/headscale" options allowedIps}
'';
};
}