mirror of
https://codeberg.org/privacy1st/nix-git
synced 2024-12-25 02:56:05 +01:00
34 lines
854 B
Nix
34 lines
854 B
Nix
{ lib, config, options, pkgs, modulesPath, ... }:
|
|
with lib;
|
|
let
|
|
cfg = config.yoda.spin-down.hd-idle;
|
|
in
|
|
{
|
|
options = {
|
|
yoda.spin-down.hd-idle = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [ ];
|
|
example = ["ata-ST6000DM003-2CY186_ZR11WA9K"];
|
|
description = ''
|
|
List with IDs (/dev/disk/by-id/<ID>) of HDDs to spin down with hd-idle after 5 minutes.
|
|
|
|
Please try to use yoda.spin-down.hdparm first.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf (length cfg > 0) {
|
|
systemd.services."hd-idle" = {
|
|
description = "Spin down inactive HDDs";
|
|
wantedBy = [ "multi-user.target" ];
|
|
script =
|
|
let
|
|
args = strings.concatMapStrings (x: " -a disk/by-id/${x} -i 300") cfg;
|
|
in ''
|
|
set -eu -o pipefail
|
|
${pkgs.hd-idle}/bin/hd-idle ${args}
|
|
'';
|
|
};
|
|
};
|
|
}
|