diff --git a/modules/services/dandelion.nix b/modules/services/dandelion.nix index cb6d29c..979bbe9 100644 --- a/modules/services/dandelion.nix +++ b/modules/services/dandelion.nix @@ -5,5 +5,6 @@ ++ [ (import ./immich.nix) ] ++ [ (import ./nextcloud.nix) ] ++ [ (import ./home-assistant.nix) ] - ++ [ (import ./smart-monitoring.nix) ]; + ++ [ (import ./smart-monitoring.nix) ] + ++ [ (import ./hd-idle.nix) ]; } diff --git a/modules/services/hd-idle.nix b/modules/services/hd-idle.nix new file mode 100644 index 0000000..441452b --- /dev/null +++ b/modules/services/hd-idle.nix @@ -0,0 +1,21 @@ +{ pkgs, lib, ... }: +{ + environment.systemPackages = with pkgs; [ + hdparm + ]; + + services.udev.extraRules = + let + mkRule = as: lib.concatStringsSep ", " as; + mkRules = rs: lib.concatStringsSep "\n" rs; + in + mkRules ([ + (mkRule [ + ''ACTION=="add|change"'' + ''SUBSYSTEM=="block"'' + ''KERNEL=="sd[a-z]"'' + ''ATTR{queue/rotational}=="1"'' + ''RUN+="${pkgs.hdparm}/bin/hdparm -B 90 -S 41 /dev/%k"'' + ]) + ]); +}