liminix/modules/mount/service.nix

28 lines
695 B
Nix
Raw Normal View History

2023-09-04 20:17:52 +00:00
{
liminix
, lib
2024-06-02 19:40:56 +00:00
, svc
2023-09-04 20:17:52 +00:00
}:
2024-04-17 11:59:13 +00:00
{ partlabel, mountpoint, options, fstype }:
2023-09-04 20:17:52 +00:00
let
inherit (liminix.services) longrun oneshot;
2024-04-17 11:59:13 +00:00
device = "/dev/disk/by-partlabel/${partlabel}";
name = "mount.${lib.strings.sanitizeDerivationName (lib.escapeURL mountpoint)}";
options_string =
if options == [] then "" else "-o ${lib.concatStringsSep "," options}";
controller = svc.uevent-rule.build {
serviceName = name;
symlink = device;
terms = {
partname = partlabel;
devtype = "partition";
};
2024-06-02 19:40:56 +00:00
};
in oneshot {
inherit name;
timeout-up = 3600;
up = "mount -t ${fstype} ${options_string} ${device} ${mountpoint}";
down = "umount ${mountpoint}";
inherit controller;
2023-09-04 20:17:52 +00:00
}