created nfs exports
This commit is contained in:
parent
5eea6cdb04
commit
835945c925
6 changed files with 176 additions and 3 deletions
50
modules/nixos-modules/server/network_storage/nfs.nix
Normal file
50
modules/nixos-modules/server/network_storage/nfs.nix
Normal file
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
options = {
|
||||
host.network_storage.nfs = {
|
||||
enable = lib.mkEnableOption "is this server going to export network storage as nfs shares";
|
||||
directories = lib.mkOption {
|
||||
type = lib.types.listOf (
|
||||
lib.types.enum (
|
||||
builtins.map (
|
||||
directory: directory.folder
|
||||
)
|
||||
config.host.network_storage.directories
|
||||
)
|
||||
);
|
||||
description = "list of exported directories to be exported via nfs";
|
||||
};
|
||||
};
|
||||
};
|
||||
config = lib.mkMerge [
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = !(config.host.network_storage.nfs.enable && !config.host.network_storage.enable);
|
||||
message = "nfs cant be enabled with network storage disabled";
|
||||
}
|
||||
];
|
||||
}
|
||||
(
|
||||
lib.mkIf (config.host.network_storage.nfs.enable && config.host.network_storage.enable) {
|
||||
services.nfs.server = {
|
||||
enable = true;
|
||||
exports = lib.strings.concatLines (
|
||||
builtins.map (
|
||||
directory: "${directory._directory} 192.168.1.0/22(rw,sync,no_subtree_check,crossmnt)"
|
||||
)
|
||||
(
|
||||
builtins.filter (
|
||||
directory: lib.lists.any (target: target == directory.folder) config.host.network_storage.nfs.directories
|
||||
)
|
||||
config.host.network_storage.directories
|
||||
)
|
||||
);
|
||||
};
|
||||
}
|
||||
)
|
||||
];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue