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

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

32 lines
803 B
Nix
Raw Permalink Normal View History

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