aboutsummaryrefslogtreecommitdiff
path: root/nixos/serverModules/nfs.nix
diff options
context:
space:
mode:
authorspl3g <notspl3g@duck.com>2026-03-18 18:01:41 +0300
committerspl3g <notspl3g@duck.com>2026-03-18 18:01:59 +0300
commit03648b3d9f177227df40129bed22558f6924b91c (patch)
tree8a22eda142beeafd9002a8d5901ba9428a77ad52 /nixos/serverModules/nfs.nix
parentdc19a2b583b3ab50d8e36ff0a90ca633495f675f (diff)
so.. v2 i guess
Diffstat (limited to 'nixos/serverModules/nfs.nix')
-rw-r--r--nixos/serverModules/nfs.nix112
1 files changed, 0 insertions, 112 deletions
diff --git a/nixos/serverModules/nfs.nix b/nixos/serverModules/nfs.nix
deleted file mode 100644
index f8186b6..0000000
--- a/nixos/serverModules/nfs.nix
+++ /dev/null
@@ -1,112 +0,0 @@
-{ config, lib, ... }:
-with lib;
-let
- cfg = config.nfs;
-in
-{
- options = {
- nfs.server = mkOption {
- description = ''
- NFS server configuration.
- '';
- default = { enable = false; };
- type = types.submodule {
- options = {
- enable = mkEnableOption "Enable nfs server";
- exportsPath = mkOption {
- type = types.str;
- default = "/export";
- description = ''
- A path to the dir, where exports will be binded.
- '';
- };
-
- defaultExportIps = mkOption {
- type = types.listOf (types.str);
- description = ''
- A list of ip addresses, that will be used as default in exportDirs
- '';
- };
-
- defaultExportParams = mkOption {
- type = types.str;
- default = "rw,nohide,insecure,no_subtree_check";
- description = ''
- Params, that will be used as default in exportDirs
- '';
- };
-
- exportDirs = mkOption {
- description = ''
- A list of directories to export.
- '';
- type = types.listOf (types.submodule {
- options = {
- path = mkOption {
- type = types.str;
- description = ''
- A path to the directory to export.
- '';
- };
- exportPath = mkOption {
- type = types.str;
- default = "";
- description = ''
- A path that will be binded to the export directory in the exportsPath.
- '';
- };
- ips = mkOption {
- type = types.listOf (types.str);
- default = cfg.server.defaultExportIps;
- description = ''
- A list of ip addresses to export the dir to.
- '';
- };
- params = mkOption {
- type = types.str;
- default = cfg.server.defaultExportParams;
- description = ''
- Params for the ip addresses.
- '';
- };
- };
- });
- };
- };
- };
- };
- };
-
- config = mkIf cfg.server.enable {
- services.nfs.server = {
- enable = true;
- exports = "${cfg.server.exportsPath} ${concatMapStrings (ip: "${ip}(rw,fsid=0,no_subtree_check) ") cfg.server.defaultExportIps}\n"
- + concatMapStrings
- (dir:
- let
- ips = concatMapStrings (ip: "${ip}(${dir.params}) ") dir.ips;
- exportPath = if dir.exportPath != "" then dir.exportPath else
- baseNameOf dir.path;
- in "${cfg.server.exportsPath}/${exportPath} ${ips}\n")
- cfg.server.exportDirs;
- };
-
- systemd.tmpfiles.rules = [
- "d ${cfg.server.exportsPath} 0744 nobody nogroup"
- ];
-
- fileSystems = listToAttrs (map (exportDir:
- let
- exportPath = if exportDir.exportPath != "" then exportDir.exportPath else
- baseNameOf exportDir.path;
- fullExportPath = "${cfg.server.exportsPath}/${exportPath}";
- in
- {
- name = fullExportPath;
- value = {
- device = exportDir.path;
- options = ["bind"];
- };
- }) cfg.server.exportDirs);
- };
-}