nixpkgs/nixos/modules/hardware/usb-storage.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
640 B
Nix
Raw Normal View History

2022-08-07 20:51:04 +03:00
{ config, lib, pkgs, ... }:
{
options.hardware.usbStorage.manageStartStop = lib.mkOption {
type = lib.types.bool;
2022-08-07 20:51:04 +03:00
default = true;
description = ''
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 = lib.mkIf config.hardware.usbStorage.manageStartStop {
2022-08-07 20:51:04 +03:00
services.udev.extraRules = ''
2023-11-02 17:29:30 +03:00
ACTION=="add|change", SUBSYSTEM=="scsi_disk", DRIVERS=="usb-storage", ATTR{manage_system_start_stop}="1"
2022-08-07 20:51:04 +03:00
'';
};
}