Skip to content

Commit 5f58e38

Browse files
committed
add NFS export on trenderhoof
1 parent 049031c commit 5f58e38

2 files changed

Lines changed: 96 additions & 0 deletions

File tree

hosts/servers/trenderhoof.nix

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{ ... }:
2+
3+
{
4+
imports = [ ../../hardware/virtualized.nix ];
5+
6+
networking.hostName = "trenderhoof";
7+
8+
ocf.nfs = {
9+
enable = true;
10+
# https://github.com/ocf/puppet/blob/a081b2210691bd46d585accc8548c985188486a0/modules/ocf_filehost/manifests/init.pp#L10-L16
11+
exports = [
12+
{
13+
directory = "/opt/homes";
14+
hosts = [
15+
"admin"
16+
"www"
17+
"ssh"
18+
"apphost"
19+
"adenine"
20+
"guanine"
21+
"cytosine"
22+
"thymine"
23+
"fluttershy"
24+
"rainbowdash"
25+
];
26+
options = [
27+
"rw"
28+
"fsid=0"
29+
"no_subtree_check"
30+
"no_root_squash"
31+
];
32+
}
33+
];
34+
};
35+
36+
system.stateVersion = "25.11";
37+
}

modules/ocf/nfs.nix

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{ config, lib, ... }:
2+
3+
let
4+
inherit (lib)
5+
concatMapStrings
6+
concatMapStringsSep
7+
concatStringsSep
8+
mkEnableOption
9+
mkIf
10+
mkOption
11+
types
12+
;
13+
cfg = config.ocf.nfs;
14+
in
15+
{
16+
options.ocf.nfs = {
17+
enable = mkEnableOption "NFS exports";
18+
exports = mkOption {
19+
type = types.listOf (
20+
types.submodule {
21+
options = {
22+
directory = mkOption {
23+
type = types.path;
24+
};
25+
hosts = mkOption {
26+
description = "Hosts with which the export is shared";
27+
example = [
28+
"192.168.0.0/28"
29+
"*.ocf.io"
30+
];
31+
type = with types; nonEmptyListOf str;
32+
};
33+
options = mkOption {
34+
default = [ ];
35+
description = "NFS options applied to all hosts";
36+
example = [ "rw" ];
37+
type = with types; listOf str;
38+
};
39+
};
40+
}
41+
);
42+
};
43+
};
44+
45+
config = mkIf cfg.enable {
46+
services.nfs.server = {
47+
enable = true;
48+
# https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/5/html/deployment_guide/s1-nfs-server-config-exports
49+
exports = lib.traceValSeq (
50+
concatMapStrings (export: ''
51+
${export.directory} \
52+
${concatMapStringsSep " \\\n " (
53+
host: "${host}(${concatStringsSep " " export.options})"
54+
) export.hosts}
55+
'') cfg.exports
56+
);
57+
};
58+
};
59+
}

0 commit comments

Comments
 (0)