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

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

22 lines
770 B
Nix
Raw Normal View History

2022-08-07 17:51:04 +00:00
{ config, lib, pkgs, ... }:
2024-01-27 09:25:21 +00:00
2022-08-07 17:51:04 +00:00
{
2024-01-27 09:25:21 +00:00
options.hardware.usbStorage.manageShutdown = lib.mkOption {
type = lib.types.bool;
2024-01-27 09:25:21 +00:00
default = false;
2022-08-07 17:51:04 +00:00
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.
'';
};
2024-01-27 09:25:21 +00:00
config = lib.mkIf config.hardware.usbStorage.manageShutdown {
2022-08-07 17:51:04 +00:00
services.udev.extraRules = ''
2024-01-27 09:25:21 +00:00
ACTION=="add|change", SUBSYSTEM=="scsi_disk", DRIVERS=="usb-storage|uas", ATTR{manage_shutdown}="1"
2022-08-07 17:51:04 +00:00
'';
};
2024-01-27 09:25:21 +00:00
imports = [(lib.mkRenamedOptionModule [ "hardware" "usbStorage" "manageStartStop" ] [ "hardware" "usbStorage" "manageShutdown" ])];
2022-08-07 17:51:04 +00:00
}