depot/third_party/nixpkgs/nixos/modules/hardware/usb-storage.nix
Default email 555cd8a8f9 Project import generated by Copybara.
GitOrigin-RevId: 5633bcff0c6162b9e4b5f1264264611e950c8ec7
2024-10-09 18:51:18 +02:00

21 lines
770 B
Nix

{ config, lib, pkgs, ... }:
{
options.hardware.usbStorage.manageShutdown = lib.mkOption {
type = lib.types.bool;
default = false;
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.manageShutdown {
services.udev.extraRules = ''
ACTION=="add|change", SUBSYSTEM=="scsi_disk", DRIVERS=="usb-storage|uas", ATTR{manage_shutdown}="1"
'';
};
imports = [(lib.mkRenamedOptionModule [ "hardware" "usbStorage" "manageStartStop" ] [ "hardware" "usbStorage" "manageShutdown" ])];
}