-
Notifications
You must be signed in to change notification settings - Fork 2
/
volume-mount-nfs.nix
90 lines (90 loc) · 2.87 KB
/
volume-mount-nfs.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
topLevel@{ inputs, flake-parts-lib, ... }: {
imports = [
./devcontainer.nix
./kubernetes.nix
inputs.flake-parts.flakeModules.flakeModules
];
flake.flakeModules.volumeMountNfs = {
imports = [
topLevel.config.flake.flakeModules.devcontainer
topLevel.config.flake.flakeModules.kubernetes
];
options.perSystem = flake-parts-lib.mkPerSystemOption (perSystem@{ lib, config, pkgs, ... }: {
ml-ops.common = {
options.volumeMounts.nfs = lib.mkOption {
default = { };
type = lib.types.attrsOf (lib.types.submoduleWith {
modules = [{
options.mountOptions = lib.mkOption {
default = [ "rw" "intr" "nolock" ];
type = lib.types.listOf lib.types.str;
};
options.path = lib.mkOption {
example = "/ml_data";
type = lib.types.str;
};
options.server = lib.mkOption {
example = "nfs.example.com";
type = lib.types.str;
};
}];
});
};
};
ml-ops.runtime = {
options.volumeMounts.nfs = lib.mkOption {
type = lib.types.attrsOf (lib.types.submoduleWith {
modules = [
({ config, ... }: {
options.kubernetesVolume = lib.mkOption {
defaultText = lib.literalMD "";
default = {
nfs = {
inherit (config) server path;
};
mountOptions = config.mountOptions;
};
};
})
];
});
};
};
ml-ops.devcontainer = {
options.volumeMounts.nfs = lib.mkOption {
type = lib.types.attrsOf (lib.types.submoduleWith {
modules = [
({ config, ... }: {
options.mountScript = lib.mkOption {
type = lib.types.lines;
default = ''
${
lib.strings.escapeShellArgs [
"mkdir"
"-p"
config._module.args.name
]
}
${
lib.strings.escapeShellArgs (
[
"mount.nfs"
] ++ lib.lists.optionals (config.mountOptions != []) [
"-o"
(lib.strings.concatStringsSep "," config.mountOptions)
] ++ [
"${config.server}:${config.path}"
config._module.args.name
]
)
}
'';
};
})
];
});
};
};
});
};
}