convert mount service to trigger
Good: this means it's not hanging holding the s6 dataase lock. Bad: it's the ugliest implementation and doesn't deserve to be preserved (tbf the ugliness is not new)
This commit is contained in:
parent
4795dd05b7
commit
5df5c822ea
5 changed files with 154 additions and 6 deletions
|
@ -4,15 +4,28 @@
|
|||
}:
|
||||
{ device, mountpoint, options, fstype }:
|
||||
let
|
||||
inherit (liminix.services) oneshot;
|
||||
in oneshot {
|
||||
name = "mount.${lib.escapeURL mountpoint}";
|
||||
up = ''
|
||||
inherit (liminix.services) longrun oneshot;
|
||||
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}";
|
||||
};
|
||||
in longrun {
|
||||
name = "watch-mount.${lib.strings.sanitizeDerivationName mountpoint}";
|
||||
isTrigger = true;
|
||||
buildInputs = [ mount_service ];
|
||||
|
||||
# This accommodates bringing the service up when the device appears.
|
||||
# It doesn't bring it down on unplug because unmount will probably
|
||||
# fail anyway (so don't do that)
|
||||
run = ''
|
||||
while ! findfs ${device}; do
|
||||
echo waiting for device ${device}
|
||||
sleep 1
|
||||
done
|
||||
mount -t ${fstype} -o ${lib.concatStringsSep "," options} ${device} ${mountpoint}
|
||||
s6-rc -b -u change ${mount_service.name}
|
||||
'';
|
||||
down = "umount ${mountpoint}";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue