Fixed if statement. Added separate disk-spindown file.
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
### --> SnapRAID disks research
|
### --> SnapRAID disks research
|
||||||
contentDiskMounts = lib.attrsets.attrNames (
|
contentDiskMounts = lib.attrsets.attrNames (
|
||||||
lib.attrsets.filterAttrs (name: value: lib.strings.hasPrefix "/mnt/content-" name) config.fileSystems
|
lib.attrsets.filterAttrs (name: value: lib.strings.hasPrefix "/mnt/content-" name) config.fileSystems
|
||||||
@@ -14,15 +13,8 @@ let
|
|||||||
{ i = 0; }
|
{ i = 0; }
|
||||||
contentDiskMounts;
|
contentDiskMounts;
|
||||||
### SnapRAID disks research <--
|
### SnapRAID disks research <--
|
||||||
|
|
||||||
### --> Spindown disks
|
|
||||||
hardDrives = [ ${DISK_ID_LIST[@]} ];
|
|
||||||
### Spindown disks <--
|
|
||||||
in
|
in
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### --> MergerFS setup
|
### --> MergerFS setup
|
||||||
{
|
{
|
||||||
fileSystems."/mnt/data-storage" = {
|
fileSystems."/mnt/data-storage" = {
|
||||||
@@ -40,8 +32,6 @@ in
|
|||||||
};
|
};
|
||||||
### MergerFS setup <--
|
### MergerFS setup <--
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### --> SnapRAID setup
|
### --> SnapRAID setup
|
||||||
services.snapraid = {
|
services.snapraid = {
|
||||||
enable = true;
|
enable = true;
|
||||||
@@ -51,22 +41,4 @@ in
|
|||||||
};
|
};
|
||||||
### SnapRAID setup <--
|
### SnapRAID setup <--
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### --> Disk spindown
|
|
||||||
systemd.services.hd-idle = {
|
|
||||||
description = "External HD spin down daemon";
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "simple";
|
|
||||||
ExecStart =
|
|
||||||
let
|
|
||||||
idleTime = toString 1800;
|
|
||||||
hardDriveParameter = lib.strings.concatMapStringsSep " " (x: "-a ${x} -i ${idleTime}") hardDrives;
|
|
||||||
in
|
|
||||||
"${pkgs.hd-idle}/bin/hd-idle -i 0 ${hardDriveParameter}";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
### Disk spindown <--
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
|
### --> Disk spindown
|
||||||
|
systemd.services.hd-idle = {
|
||||||
|
description = "External HD spin down daemon";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "simple";
|
||||||
|
ExecStart =
|
||||||
|
let
|
||||||
|
idleTime = toString 1800;
|
||||||
|
hardDriveParameter = lib.strings.concatMapStringsSep " " (x: "-a ${x} -i ${idleTime}") hardDrives;
|
||||||
|
in
|
||||||
|
"${pkgs.hd-idle}/bin/hd-idle -i 0 ${hardDriveParameter}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
### Disk spindown <--
|
||||||
@@ -164,8 +164,10 @@ files_generation() {
|
|||||||
FRIGATE_DEVICES_BLOCK=""
|
FRIGATE_DEVICES_BLOCK=""
|
||||||
if [[ "$TARGET_GRAPHICS_RENDERER" == "true" ]]; then
|
if [[ "$TARGET_GRAPHICS_RENDERER" == "true" ]]; then
|
||||||
FRIGATE_DEVICES_BLOCK+=" - /dev/dri:/dev/dri\n"
|
FRIGATE_DEVICES_BLOCK+=" - /dev/dri:/dev/dri\n"
|
||||||
|
fi
|
||||||
if [[ "$TARGET_USB_CORAL" == "true" ]]; then
|
if [[ "$TARGET_USB_CORAL" == "true" ]]; then
|
||||||
FRIGATE_DEVICES_BLOCK+=" - /dev/bus/usb:/dev/bus/usb\n"
|
FRIGATE_DEVICES_BLOCK+=" - /dev/bus/usb:/dev/bus/usb\n"
|
||||||
|
fi
|
||||||
if [[ -n "$FRIGATE_DEVICES_BLOCK" ]]; then
|
if [[ -n "$FRIGATE_DEVICES_BLOCK" ]]; then
|
||||||
REPLACEMENT="devices:\n${FRIGATE_DEVICES_BLOCK%\\n}"
|
REPLACEMENT="devices:\n${FRIGATE_DEVICES_BLOCK%\\n}"
|
||||||
sed -i.bak "s|# --- frigate devices --- #|$REPLACEMENT|" ./config-files/docker/compose/frigate.nix
|
sed -i.bak "s|# --- frigate devices --- #|$REPLACEMENT|" ./config-files/docker/compose/frigate.nix
|
||||||
@@ -203,6 +205,7 @@ files_generation() {
|
|||||||
IMMICH_DEVICES_BLOCK=""
|
IMMICH_DEVICES_BLOCK=""
|
||||||
if [[ "$TARGET_GRAPHICS_RENDERER" == "true" ]]; then
|
if [[ "$TARGET_GRAPHICS_RENDERER" == "true" ]]; then
|
||||||
IMMICH_DEVICES_BLOCK+=" - /dev/dri:/dev/dri\n"
|
IMMICH_DEVICES_BLOCK+=" - /dev/dri:/dev/dri\n"
|
||||||
|
fi
|
||||||
if [[ -n "$IMMICH_DEVICES_BLOCK" ]]; then
|
if [[ -n "$IMMICH_DEVICES_BLOCK" ]]; then
|
||||||
REPLACEMENT="devices:\n${IMMICH_DEVICES_BLOCK%\\n}"
|
REPLACEMENT="devices:\n${IMMICH_DEVICES_BLOCK%\\n}"
|
||||||
sed -i.bak "s|# --- immich devices --- #|$REPLACEMENT|" ./config-files/docker/compose/immich.nix
|
sed -i.bak "s|# --- immich devices --- #|$REPLACEMENT|" ./config-files/docker/compose/immich.nix
|
||||||
@@ -521,6 +524,10 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
cp -avu ./config-files/disks/snapraid.nix ./nixos-config/disks/
|
cp -avu ./config-files/disks/snapraid.nix ./nixos-config/disks/
|
||||||
|
|
||||||
|
if [[ -n "${DISK_ID_LIST[@]}" ]]; then
|
||||||
|
sed -i "s|DISK_ID_LIST|${DISK_ID_LIST[@]}|" ./config-files/disks/spindown.nix
|
||||||
|
cp -avu ./config-files/disks/spindown.nix ./nixos-config/disks/spindown.nix
|
||||||
### Generate automatic unlock configuration <--
|
### Generate automatic unlock configuration <--
|
||||||
|
|
||||||
### --> Generate unlock keys
|
### --> Generate unlock keys
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{ config, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
# Enable networking and firewall
|
# Enable networking and firewall
|
||||||
|
|||||||
Reference in New Issue
Block a user