From 5ca085b6dac7dcca1e76f1de30c0758a8b86b3c6 Mon Sep 17 00:00:00 2001 From: Ahwx Date: Thu, 24 Apr 2025 11:30:09 +0200 Subject: [PATCH] feat: create and enable hd-idle module --- modules/services/dandelion.nix | 3 ++- modules/services/hd-idle.nix | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 modules/services/hd-idle.nix 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"'' + ]) + ]); +}