diff --git a/nix/nixosProfiles/common.nix b/nix/nixosProfiles/common.nix index 5026b86..7fc7af0 100644 --- a/nix/nixosProfiles/common.nix +++ b/nix/nixosProfiles/common.nix @@ -10,6 +10,7 @@ }: let cfg = config.x-banananetwork.allCommon; + inherit (lib.modules) mkIf; in { @@ -146,6 +147,14 @@ in # so smartd reports them by their /dev/disk/by-id name (https://www.smartmontools.org/ticket/1390#comment:2) defaults.autodetected = "-d by-id"; }; + + # TODO upstream with better option for rules + # required because smartd only detects drives when launching + # so the udev rule makes smartd useable with removeable drives + # "restart-or-reload" is required because smartd fails to start if no SMART drive was found + udev.extraRules = mkIf config.services.smartd.enable '' + ACTION=="add|change|move|remove", SUBSYSTEM=="scsi_disk", RUN+="${config.systemd.package}/bin/systemctl --no-block try-reload-or-restart smartd.service" + ''; }; # TODO upstream