From fa6cf08b3a48685a5f5f9fde3fc156afe3937773 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy <dmitriy@pleshevski.ru> Date: Thu, 6 Mar 2025 12:50:05 +0300 Subject: [PATCH] host/home: add nfs server to share some dirs --- hosts/home/hardware-configuration/default.nix | 6 ++-- hosts/home/hardware-configuration/nfs.nix | 29 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 hosts/home/hardware-configuration/nfs.nix diff --git a/hosts/home/hardware-configuration/default.nix b/hosts/home/hardware-configuration/default.nix index 4177707..7bc9170 100644 --- a/hosts/home/hardware-configuration/default.nix +++ b/hosts/home/hardware-configuration/default.nix @@ -1,8 +1,10 @@ { config, ... }: { - # Include the results of the hardware scan. - imports = [ ./generated.nix ]; + imports = [ + ./generated.nix # Include the results of the hardware scan. + ./nfs.nix + ]; # Add support of usb boot.initrd.availableKernelModules = [ "usb_storage" ]; diff --git a/hosts/home/hardware-configuration/nfs.nix b/hosts/home/hardware-configuration/nfs.nix new file mode 100644 index 0000000..10dea2d --- /dev/null +++ b/hosts/home/hardware-configuration/nfs.nix @@ -0,0 +1,29 @@ +{ ... }: + +{ + fileSystems."/export/mynix" = { + device = "/home/jan/mynix"; + options = [ "bind" ]; + }; + + fileSystems."/export/projects" = { + device = "/home/jan/projects"; + options = [ "bind" ]; + }; + + services.nfs.server = { + enable = true; + lockdPort = 4001; + mountdPort = 4002; + statdPort = 4000; + exports = '' + /export 192.168.0.0/24(rw,fsid=0,no_subtree_check) + /export/mynix 192.168.0.0/24(rw,nohide,insecure,no_subtree_check) + /export/projects 192.168.0.0/24(rw,nohide,insecure,no_subtree_check) + ''; + }; + networking.firewall = { + allowedTCPPorts = [ 111 2049 4000 4001 4002 20048 ]; + allowedUDPPorts = [ 111 2049 4000 4001 4002 20048 ]; + }; +}