Files
platform/ekman/mounts.nix
2025-09-12 13:12:36 +02:00

141 lines
3.3 KiB
Nix

{ lib, config, ... }:
with lib;
let
cfg = config.cluster.mounts;
options =
[ "soft" "defaults" "vers=4.2" ] ++
(if cfg.automount.enable then [ "noauto" "x-systemd.automount" ] else []);
users =
if cfg.users then {
<<<<<<<< HEAD:rossby/mounts.nix
"/users" = {
device = "172.16.239.222:/home";
========
"/frontend" = {
device = "10.255.241.100:/home";
>>>>>>>> ekman:ekman/mounts.nix
fsType = "nfs4";
options = [
"soft"
"defaults"
"noauto"
"x-systemd.automount"
];
};
} else {};
opt =
let
server = "172.16.239.222";
in
if cfg.opt then {
"/opt/bin" = {
device = "${server}:/opt/bin";
fsType = "nfs4";
inherit options;
};
"/opt/sif" = {
device = "${server}:/opt/sif";
fsType = "nfs4";
inherit options;
};
"/opt/singularity" = {
device = "${server}:/opt/singularity";
fsType = "nfs4";
inherit options;
};
} else {};
data =
if cfg.ceph then {
"/data" = {
device = "/ceph";
options = [ "bind" ];
};
} else {};
work =
if cfg.work then {
"/work" = {
device = "172.16.240.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"
];
};
} else {};
<<<<<<<< HEAD:rossby/mounts.nix
fileSystems = users // opt // data // work // ceph;
========
fileSystems = users // opt // data // work // backup // ceph;
>>>>>>>> ekman:ekman/mounts.nix
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 = replaceme
[client.rbd]
key = replaceme
'';
mode = "0660";
group = "admin";
};
} else {};
in
{
options.cluster.mounts = {
rdma.enable = mkEnableOption "Enable NFS over RDMA";
gbe100.enable = mkEnableOption "Enable NFS over 100 GbE";
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" ];
};
}