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
|
2024-06-29 21:59:27 +00:00
|
|
|
inherit (liminix.services) oneshot;
|
2024-04-17 11:59:13 +00:00
|
|
|
device = "/dev/disk/by-partlabel/${partlabel}";
|
2024-06-09 21:37:45 +00:00
|
|
|
name = "mount.${lib.strings.sanitizeDerivationName (lib.escapeURL mountpoint)}";
|
2024-04-03 22:17:36 +00:00
|
|
|
options_string =
|
|
|
|
if options == [] then "" else "-o ${lib.concatStringsSep "," options}";
|
2024-06-09 21:37:45 +00:00
|
|
|
controller = svc.uevent-rule.build {
|
|
|
|
serviceName = name;
|
|
|
|
symlink = device;
|
|
|
|
terms = {
|
|
|
|
partname = partlabel;
|
|
|
|
devtype = "partition";
|
|
|
|
};
|
2024-06-02 19:40:56 +00:00
|
|
|
};
|
2024-06-09 21:37:45 +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
|
|
|
}
|