2024-03-18 14:44:16 +01:00
|
|
|
{
|
|
|
|
inputs,
|
|
|
|
outputs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: {
|
2024-03-18 14:46:37 +01:00
|
|
|
environment.systemPackages = with pkgs; [auto-mount];
|
|
|
|
|
2024-03-18 14:44:16 +01:00
|
|
|
services.udev.extraRules = ''
|
2024-03-18 14:49:13 +01:00
|
|
|
KERNEL=="sd[a-z]|sd[a-z][0-9]", ACTION=="add", RUN+="/run/current-system/sw/bin/systemctl start --no-block external-drive-mount@%k.service"
|
|
|
|
KERNEL=="sd[a-z]|sd[a-z][0-9]", ACTION=="remove", RUN+="/run/current-system/sw/bin/systemctl stop --no-block external-drive-mount@%k.service"
|
|
|
|
KERNEL=="mmcblk0|mmcblk0p[0-9]", ACTION=="add", RUN+="/run/current-system/sw/bin/systemctl start --no-block external-drive-mount@%k.service"
|
|
|
|
KERNEL=="mmcblk0|mmcblk0p[0-9]", ACTION=="remove", RUN+="/run/current-system/sw/bin/systemctl stop --no-block external-drive-mount@%k.service"
|
|
|
|
KERNEL=="nvme0n1p9|nvme0n1p1[0-9]", ACTION=="add", RUN+="/run/current-system/sw/bin/systemctl start --no-block external-drive-mount@%k.service"
|
|
|
|
KERNEL=="nvme0n1p9|nvme0n1p1[0-9]", ACTION=="remove", RUN+="/run/current-system/sw/bin/systemctl stop --no-block external-drive-mount@%k.service"
|
2024-03-18 14:44:16 +01:00
|
|
|
'';
|
|
|
|
systemd.services.auto-mount = {
|
|
|
|
enable = true;
|
|
|
|
description = "Mount External Drive on %i";
|
|
|
|
unitConfig = {
|
|
|
|
};
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
ExecStart = "/run/current-system/sw/bin/automount add %i";
|
|
|
|
ExecStop = "/run/current-system/sw/bin/automount remove %i";
|
|
|
|
RemainAfterExit = true;
|
|
|
|
};
|
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
};
|
|
|
|
}
|