2024-03-18 14:44:16 +01:00
|
|
|
{
|
|
|
|
inputs,
|
|
|
|
outputs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: {
|
|
|
|
services.udev.extraRules = ''
|
2024-03-18 15:09:12 +01:00
|
|
|
KERNEL=="sd[a-z]|sd[a-z][0-9]", ACTION=="add", RUN+="${pkgs.systemd}/bin/systemctl start --no-block external-drive-mount@%k.service"
|
|
|
|
KERNEL=="sd[a-z]|sd[a-z][0-9]", ACTION=="remove", RUN+="${pkgs.systemd}/bin/systemctl stop --no-block external-drive-mount@%k.service"
|
2024-03-21 00:05:37 +01:00
|
|
|
KERNEL=="sd[a-z]|sd[a-z][0-9]", ACTION=="remove", RUN+="${pkgs.systemd}/bin/systemctl start --no-block external-drive-unmount@%k.service"
|
2024-03-18 15:09:12 +01:00
|
|
|
KERNEL=="mmcblk0|mmcblk0p[0-9]", ACTION=="add", RUN+="${pkgs.systemd}/bin/systemctl start --no-block external-drive-mount@%k.service"
|
|
|
|
KERNEL=="mmcblk0|mmcblk0p[0-9]", ACTION=="remove", RUN+="${pkgs.systemd}/bin/systemctl stop --no-block external-drive-mount@%k.service"
|
2024-03-21 00:05:37 +01:00
|
|
|
KERNEL=="mmcblk0|mmcblk0p[0-9]", ACTION=="remove", RUN+="${pkgs.systemd}/bin/systemctl start --no-block external-drive-unmount@%k.service"
|
2024-03-18 15:09:12 +01:00
|
|
|
KERNEL=="nvme0n1p9|nvme0n1p1[0-9]", ACTION=="add", RUN+="${pkgs.systemd}/bin/systemctl start --no-block external-drive-mount@%k.service"
|
|
|
|
KERNEL=="nvme0n1p9|nvme0n1p1[0-9]", ACTION=="remove", RUN+="${pkgs.systemd}/bin/systemctl stop --no-block external-drive-mount@%k.service"
|
2024-03-21 00:05:37 +01:00
|
|
|
KERNEL=="nvme0n1p9|nvme0n1p1[0-9]", ACTION=="remove", RUN+="${pkgs.systemd}/bin/systemctl start --no-block external-drive-unmount@%k.service"
|
2024-03-18 14:44:16 +01:00
|
|
|
'';
|
2024-03-21 00:27:10 +01:00
|
|
|
|
2024-03-18 15:19:43 +01:00
|
|
|
systemd.services."external-drive-mount@" = {
|
2024-03-21 13:43:22 +01:00
|
|
|
path = with pkgs; [jq coreutils udisks bash util-linux toybox auto-mount];
|
2024-03-18 14:44:16 +01:00
|
|
|
enable = true;
|
2024-03-21 00:56:04 +01:00
|
|
|
scriptArgs = "%i";
|
2024-03-18 14:44:16 +01:00
|
|
|
serviceConfig = {
|
2024-03-21 14:03:11 +01:00
|
|
|
execStart = "echo ${pkgs.auto-mount} add $@";
|
|
|
|
execStop = "echo ${pkgs.auto-mount} remove $@";
|
2024-03-18 14:44:16 +01:00
|
|
|
Type = "oneshot";
|
2024-03-18 15:19:43 +01:00
|
|
|
RemainAfterExit = true;
|
2024-03-18 14:44:16 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|