2022-08-07 19:51:04 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{
|
|
|
|
options.hardware.usbStorage.manageStartStop = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2022-08-07 19:51:04 +02:00
|
|
|
Enable this option to gracefully spin-down external storage during shutdown.
|
|
|
|
If you suspect improper head parking after poweroff, install `smartmontools` and check
|
|
|
|
for the `Power-Off_Retract_Count` field for an increment.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf config.hardware.usbStorage.manageStartStop {
|
|
|
|
services.udev.extraRules = ''
|
2023-11-02 15:29:30 +01:00
|
|
|
ACTION=="add|change", SUBSYSTEM=="scsi_disk", DRIVERS=="usb-storage", ATTR{manage_system_start_stop}="1"
|
2022-08-07 19:51:04 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|