lol

nixos/hddtemp: allow use of command substitutions in drives option

+10 -5
+10 -5
nixos/modules/hardware/sensor/hddtemp.nix
··· 9 9 10 10 cfg = config.hardware.sensor.hddtemp; 11 11 12 - wrapper = pkgs.writeShellScript "hddtemp-wrapper" '' 12 + script = '' 13 13 set -eEuo pipefail 14 14 15 15 file=/var/lib/hddtemp/hddtemp.db 16 16 17 - drives=(${toString (map (e: ''$(realpath ${lib.escapeShellArg e}) '') cfg.drives)}) 17 + raw_drives="" 18 + ${lib.concatStringsSep "\n" (map (drives: "raw_drives+=\"${drives} \"") cfg.drives)} 19 + drives="" 20 + for i in $raw_drives; do 21 + drives+=" $(realpath $i)" 22 + done 18 23 19 24 cp ${pkgs.hddtemp}/share/hddtemp/hddtemp.db $file 20 25 ${lib.concatMapStringsSep "\n" (e: "echo ${lib.escapeShellArg e} >> $file") cfg.dbEntries} 21 26 22 - exec ${pkgs.hddtemp}/bin/hddtemp ${lib.escapeShellArgs cfg.extraArgs} \ 27 + ${pkgs.hddtemp}/bin/hddtemp ${lib.escapeShellArgs cfg.extraArgs} \ 23 28 --daemon \ 24 29 --unit=${cfg.unit} \ 25 30 --file=$file \ 26 - ''${drives[@]} 31 + $drives 27 32 ''; 28 33 29 34 in ··· 77 82 description = "HDD/SSD temperature"; 78 83 documentation = [ "man:hddtemp(8)" ]; 79 84 wantedBy = [ "multi-user.target" ]; 85 + inherit script; 80 86 serviceConfig = { 81 87 Type = "forking"; 82 - ExecStart = wrapper; 83 88 StateDirectory = "hddtemp"; 84 89 PrivateTmp = true; 85 90 ProtectHome = "tmpfs";