liminix/modules/mount/service.nix

26 lines
624 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}";
options_string =
if options == [] then "" else "-o ${lib.concatStringsSep "," options}";
mount_service = oneshot {
name = "mount.${lib.escapeURL mountpoint}";
timeout-up = 3600;
up = "mount -t ${fstype} ${options_string} ${device} ${mountpoint}";
down = "umount ${mountpoint}";
};
2024-06-02 19:40:56 +00:00
in svc.uevent-rule.build {
service = mount_service;
symlink = device;
terms = {
partname = partlabel;
devtype = "partition";
};
2023-09-04 20:17:52 +00:00
}