116 lines
2.7 KiB
Nix
116 lines
2.7 KiB
Nix
{ lib, config, ... }:
|
|
with lib;
|
|
let
|
|
cfg = config.cluster.mounts;
|
|
|
|
options =
|
|
[ "soft" "defaults" "vers=4.2" ] ++
|
|
(if cfg.automount.enable then [ "x-systemd.automount" ] else []);
|
|
|
|
users =
|
|
if cfg.users then {
|
|
"/users" = {
|
|
device = "/ceph/volumes/nfs/home";
|
|
options = [ "bind" ];
|
|
};
|
|
} else {};
|
|
|
|
opt =
|
|
if cfg.opt then {
|
|
"/opt/bin" = {
|
|
device = "/ceph/volumes/nfs/opt/bin";
|
|
options = [ "bind" ];
|
|
};
|
|
"/opt/sif" = {
|
|
device = "/ceph/volumes/nfs/opt/sif";
|
|
options = [ "bind" ];
|
|
};
|
|
} else {};
|
|
|
|
data =
|
|
if cfg.ceph then {
|
|
"/data" = {
|
|
device = "/ceph";
|
|
options = [ "bind" ];
|
|
};
|
|
} else {};
|
|
|
|
work =
|
|
if cfg.work then {
|
|
"/work" = {
|
|
device = if cfg.rdma.enable then "10.16.239.210:/work" else "172.16.239.210:/work";
|
|
fsType = "nfs4";
|
|
options = options ++ (if cfg.rdma.enable then [ "rdma" ] else []);
|
|
};
|
|
} else {};
|
|
|
|
ceph =
|
|
if cfg.ceph then {
|
|
"/ceph" = {
|
|
device = "oceanbox@.data=/";
|
|
fsType = "ceph";
|
|
options = [
|
|
"mon_addr=172.16.239.211/172.16.239.212/172.16.239.213:6789"
|
|
"_netdev"
|
|
"x-systemd.automount"
|
|
];
|
|
};
|
|
} else {};
|
|
|
|
fileSystems = users // opt // data // work // ceph;
|
|
|
|
automount = mountpoint:
|
|
if cfg.automount.enable && builtins.hasAttr mountpoint fileSystems then
|
|
[{
|
|
wantedBy = [ "multi-user.target" ];
|
|
automountConfig = {
|
|
TimeoutIdleSec = "600";
|
|
};
|
|
where = mountpoint;
|
|
}]
|
|
else [];
|
|
|
|
automounts =
|
|
[] ++
|
|
automount "/work" ++
|
|
automount "/opt" ++
|
|
automount "/backup" ++
|
|
automount "/data";
|
|
|
|
cephConf =
|
|
if cfg.ceph then {
|
|
"ceph/ceph.conf" = {
|
|
text = ''
|
|
[global]
|
|
mon_host = 172.16.239.211:6789,172.16.239.212:6789,172.16.239.213:6789
|
|
log file = /tmp/ceph-$pid.log
|
|
[client.oceanbox]
|
|
key = AQDb7sZokwnUAxAANjnzxX0p+W/FUtSYryuyqg==
|
|
[client.rbd]
|
|
key = replaceme
|
|
'';
|
|
mode = "0660";
|
|
group = "admin";
|
|
};
|
|
} else {};
|
|
|
|
in
|
|
{
|
|
options.cluster.mounts = {
|
|
rdma.enable = mkEnableOption "Enable NFS over RDMA";
|
|
automount.enable = mkEnableOption "Enable NFS automounting";
|
|
users = mkEnableOption "Enable /users";
|
|
opt = mkEnableOption "Enable /opt";
|
|
data = mkEnableOption "Enable /data";
|
|
work = mkEnableOption "Enable /work";
|
|
ceph = mkEnableOption "Enable /ceph";
|
|
};
|
|
|
|
config = {
|
|
fileSystems = fileSystems;
|
|
environment.etc = cephConf;
|
|
systemd.automounts = automounts;
|
|
boot.kernelModules = [ "rbd" ];
|
|
};
|
|
}
|