From af3f8c75646d75d3bbaaf2faa76684bd91c84db4 Mon Sep 17 00:00:00 2001 From: arunoruto Date: Mon, 14 Oct 2024 04:59:40 +0200 Subject: [PATCH] Add NFS option and enable it for kyuubi --- hosts/kyuubi/configuration.nix | 2 ++ modules/nixos/services/nas/default.nix | 6 +++--- modules/nixos/services/nas/nfs.nix | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 modules/nixos/services/nas/nfs.nix diff --git a/hosts/kyuubi/configuration.nix b/hosts/kyuubi/configuration.nix index 1e2b5c2..34b696e 100644 --- a/hosts/kyuubi/configuration.nix +++ b/hosts/kyuubi/configuration.nix @@ -14,6 +14,8 @@ in { # Define your hostname. networking.hostName = lib.mkForce "kyuubi"; + nfs.enable = true; + # environment.sessionVariables.FLAKE = "/home/${username}/Development/nix"; # Disable Autosuspend for USB Bluetooth dongles diff --git a/modules/nixos/services/nas/default.nix b/modules/nixos/services/nas/default.nix index a2a09f1..e8114d7 100644 --- a/modules/nixos/services/nas/default.nix +++ b/modules/nixos/services/nas/default.nix @@ -5,13 +5,13 @@ }: { imports = [ ./drives.nix + ./nfs.nix ]; - options = { - nas.enable = lib.mkEnableOption "NAS utilities and config"; - }; + options.nas.enable = lib.mkEnableOption "NAS utilities and config"; config = lib.mkIf config.nas.enable { drives.enable = lib.mkDefault true; + nfs.enable = lib.mkDefault false; }; } diff --git a/modules/nixos/services/nas/nfs.nix b/modules/nixos/services/nas/nfs.nix new file mode 100644 index 0000000..dbc9392 --- /dev/null +++ b/modules/nixos/services/nas/nfs.nix @@ -0,0 +1,24 @@ +{ + config, + lib, + ... +}: { + options.nfs.enable = lib.mkEnableOption "NFS Settings for Server and Client"; + + config = lib.mkIf config.nfs.enable { + services.nfs.server = { + enable = true; + # fixed rpc.statd port; for firewall + lockdPort = 4001; + mountdPort = 4002; + statdPort = 4000; + extraNfsdConfig = ''''; + }; + + networking.firewall = { + # for NFSv3; view with `rpcinfo -p` + allowedTCPPorts = [111 2049 4000 4001 4002 20048]; + allowedUDPPorts = [111 2049 4000 4001 4002 20048]; + }; + }; +}