Skip to content

Commit e98d2e0

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

2 files changed

Lines changed: 101 additions & 0 deletions

File tree

hosts/servers/trenderhoof.nix

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

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)