nixos/modules/services/nfs.nix
2024-09-26 13:27:16 +08:00

30 lines
907 B
Nix

inputs:
{
options.nixos.services.nfs = let inherit (inputs.lib) mkOption types; in mkOption
{
type = types.nullOr (types.submodule { options =
{
root = mkOption { type = types.nonEmptyStr; };
exports = mkOption { type = types.listOf types.nonEmptyStr; };
accessLimit = mkOption { type = types.nonEmptyStr; };
};});
default = null;
};
config = let inherit (inputs.config.nixos.services) nfs; in inputs.lib.mkIf (nfs != null)
{
services =
{
rpcbind.enable = true;
nfs.server =
{
enable = true;
exports = "${nfs.root} ${nfs.accessLimit}(rw,no_root_squash,fsid=0,sync,crossmnt)\n"
+ builtins.concatStringsSep "\n" (builtins.map
(export: "${export} ${nfs.accessLimit}(rw,no_root_squash,sync,crossmnt)")
nfs.exports);
};
};
networking.firewall.allowedTCPPorts = [ 2049 ];
};
}