liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

service.nix (696B)


      1 {
      2   liminix,
      3   lib,
      4   svc,
      5 }:
      6 {
      7   partlabel,
      8   mountpoint,
      9   options,
     10   fstype,
     11 }:
     12 let
     13   inherit (liminix.services) oneshot;
     14   device = "/dev/disk/by-partlabel/${partlabel}";
     15   name = "mount.${lib.strings.sanitizeDerivationName (lib.escapeURL mountpoint)}";
     16   options_string = if options == [ ] then "" else "-o ${lib.concatStringsSep "," options}";
     17   controller = svc.uevent-rule.build {
     18     serviceName = name;
     19     symlink = device;
     20     terms = {
     21       partname = partlabel;
     22       devtype = "partition";
     23     };
     24   };
     25 in
     26 oneshot {
     27   inherit name;
     28   timeout-up = 3600;
     29   up = "mount -t ${fstype} ${options_string} ${device} ${mountpoint}";
     30   down = "umount ${mountpoint}";
     31   inherit controller;
     32 }