Helios64 NAS
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
# This is used to change the default configuration of Realtek USB ethernet adapters
|
||||
|
||||
ACTION!="add", GOTO="usb_realtek_net_end"
|
||||
SUBSYSTEM!="usb", GOTO="usb_realtek_net_end"
|
||||
ENV{DEVTYPE}!="usb_device", GOTO="usb_realtek_net_end"
|
||||
|
||||
# Modify this to change the default value
|
||||
ENV{REALTEK_NIC_MODE}="1"
|
||||
|
||||
# Realtek
|
||||
ATTR{idVendor}=="0bda", ATTR{idProduct}=="8156", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="0bda", ATTR{idProduct}=="8153", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="0bda", ATTR{idProduct}=="8152", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
|
||||
# Samsung
|
||||
ATTR{idVendor}=="04e8", ATTR{idProduct}=="a101", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
|
||||
# Lenovo
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="304f", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="3052", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="3054", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="3057", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="3082", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="7205", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="720a", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="720b", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="720c", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="721e", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="a359", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="a387", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
|
||||
# TP-LINK
|
||||
ATTR{idVendor}=="2357", ATTR{idProduct}=="0601", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
|
||||
# Nvidia
|
||||
ATTR{idVendor}=="0955", ATTR{idProduct}=="09ff", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
|
||||
LABEL="usb_realtek_net_end"
|
||||
@@ -0,0 +1 @@
|
||||
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="r8152", KERNEL=="eth1", NAME="eth1"
|
||||
23
machines/storage/s0/helios64/modules/bsp/90-helios64-hwmon.rules
Executable file
23
machines/storage/s0/helios64/modules/bsp/90-helios64-hwmon.rules
Executable file
@@ -0,0 +1,23 @@
|
||||
# Helios64 persistent hwmon
|
||||
|
||||
ACTION=="remove", GOTO="helios64_hwmon_end"
|
||||
|
||||
#
|
||||
KERNELS=="p6-fan", SUBSYSTEMS=="platform", ENV{_HELIOS64_FAN_}="p6", ENV{_IS_HELIOS64_FAN_}="1", ENV{IS_HELIOS64_HWMON}="1"
|
||||
KERNELS=="p7-fan", SUBSYSTEMS=="platform", ENV{_HELIOS64_FAN_}="p7", ENV{_IS_HELIOS64_FAN_}="1", ENV{IS_HELIOS64_HWMON}="1"
|
||||
KERNELS=="2-004c", SUBSYSTEMS=="i2c", DRIVERS=="lm75", ENV{IS_HELIOS64_HWMON}="1"
|
||||
|
||||
SUBSYSTEM!="hwmon", GOTO="helios64_hwmon_end"
|
||||
|
||||
ENV{HWMON_PATH}="/sys%p"
|
||||
#
|
||||
ATTR{name}=="cpu", ENV{IS_HELIOS64_HWMON}="1", ENV{HELIOS64_SYMLINK}="/dev/thermal-cpu"
|
||||
#
|
||||
ENV{IS_HELIOS64_HWMON}=="1", ATTR{name}=="lm75", ENV{HELIOS64_SYMLINK}="/dev/thermal-board"
|
||||
ENV{_IS_HELIOS64_FAN_}=="1", ENV{HELIOS64_SYMLINK}="/dev/fan-$env{_HELIOS64_FAN_}"
|
||||
|
||||
#
|
||||
ENV{IS_HELIOS64_HWMON}=="1", RUN+="/bin/ln -sf $env{HWMON_PATH} $env{HELIOS64_SYMLINK}"
|
||||
|
||||
LABEL="helios64_hwmon_end"
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
ACTION=="add", GOTO="helios64_ups_end"
|
||||
ACTION=="remove", GOTO="helios64_ups_end"
|
||||
|
||||
# Power loss event
|
||||
ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTRS{online}=="0", RUN+="/usr/bin/systemctl start helios64-ups.timer"
|
||||
|
||||
# Power restore event
|
||||
ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTRS{online}=="1", RUN+="/usr/bin/systemctl stop helios64-ups.timer"
|
||||
|
||||
LABEL="helios64_ups_end"
|
||||
|
||||
41
machines/storage/s0/helios64/modules/fancontrol.nix
Normal file
41
machines/storage/s0/helios64/modules/fancontrol.nix
Normal file
@@ -0,0 +1,41 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
hardware.fancontrol.enable = true;
|
||||
hardware.fancontrol.config = ''
|
||||
# Helios64 PWM Fan Control Configuration
|
||||
# Temp source : /dev/thermal-cpu
|
||||
INTERVAL=10
|
||||
FCTEMPS=/dev/fan-p6/pwm1=/dev/thermal-cpu/temp1_input /dev/fan-p7/pwm1=/dev/thermal-cpu/temp1_input
|
||||
MINTEMP=/dev/fan-p6/pwm1=40 /dev/fan-p7/pwm1=40
|
||||
MAXTEMP=/dev/fan-p6/pwm1=80 /dev/fan-p7/pwm1=80
|
||||
MINSTART=/dev/fan-p6/pwm1=60 /dev/fan-p7/pwm1=60
|
||||
MINSTOP=/dev/fan-p6/pwm1=29 /dev/fan-p7/pwm1=29
|
||||
MINPWM=20
|
||||
'';
|
||||
|
||||
services.udev.packages = [
|
||||
# Fan control
|
||||
(pkgs.callPackage (
|
||||
{ stdenv, lib, coreutils }:
|
||||
stdenv.mkDerivation {
|
||||
name = "helios64-udev-fancontrol";
|
||||
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p "$out/etc/udev/rules.d/";
|
||||
install -Dm644 "${./bsp/90-helios64-hwmon.rules}" \
|
||||
"$out/etc/udev/rules.d/90-helios64-hwmon.rules"
|
||||
substituteInPlace "$out/etc/udev/rules.d/90-helios64-hwmon.rules" \
|
||||
--replace '/bin/ln' '${lib.getBin coreutils}/bin/ln'
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Udev rules for fancontrol for the Helios64";
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
) {})
|
||||
];
|
||||
}
|
||||
20
machines/storage/s0/helios64/modules/heartbeat.nix
Normal file
20
machines/storage/s0/helios64/modules/heartbeat.nix
Normal file
@@ -0,0 +1,20 @@
|
||||
{ pkgs, lib, ... }:
|
||||
{
|
||||
systemd.services.heartbeat = {
|
||||
enable = true;
|
||||
description = "Enable heartbeat & network activity led on Helios64";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = ''
|
||||
${lib.getBin pkgs.bash}/bin/bash -c 'echo heartbeat | ${lib.getBin pkgs.coreutils}/bin/tee /sys/class/leds/helios64\\:\\:status/trigger'
|
||||
${lib.getBin pkgs.bash}/bin/bash -c 'echo netdev | ${lib.getBin pkgs.coreutils}/bin/tee /sys/class/leds/helios64\\:blue\\:net/trigger'
|
||||
${lib.getBin pkgs.bash}/bin/bash -c 'echo eth0 | ${lib.getBin pkgs.coreutils}/bin/tee /sys/class/leds/helios64\\:blue\\:net/device_name'
|
||||
${lib.getBin pkgs.bash}/bin/bash -c 'echo 1 | ${lib.getBin pkgs.coreutils}/bin/tee /sys/class/leds/helios64\\:blue\\:net/link'
|
||||
${lib.getBin pkgs.bash}/bin/bash -c 'echo 1 | ${lib.getBin pkgs.coreutils}/bin/tee /sys/class/leds/helios64\\:blue\\:net/rx'
|
||||
${lib.getBin pkgs.bash}/bin/bash -c 'echo 1 | ${lib.getBin pkgs.coreutils}/bin/tee /sys/class/leds/helios64\\:blue\\:net/tx'
|
||||
'';
|
||||
};
|
||||
after = [ "getty.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
}
|
||||
51
machines/storage/s0/helios64/modules/ups.nix
Normal file
51
machines/storage/s0/helios64/modules/ups.nix
Normal file
@@ -0,0 +1,51 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
systemd.services.helios64-ups = {
|
||||
enable = true;
|
||||
description = "Helios64 UPS Action";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${pkgs.systemd}/bin/poweroff";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.timers.helios64-ups = {
|
||||
enable = true;
|
||||
description = "Helios64 UPS Shutdown timer on power loss";
|
||||
# disabling the timer by default. Even though armbian enaled
|
||||
# the timer by default through this, we don't, as we can't
|
||||
# rely on the udev rules to disable it after a system switch.
|
||||
# wantedBy = [ "multi-user.target" ];
|
||||
timerConfig = {
|
||||
OnActiveSec = "10m";
|
||||
AccuracySec = "1s";
|
||||
Unit = "helios64-ups.service";
|
||||
};
|
||||
};
|
||||
# The udev rule that will trigger the above service.
|
||||
services.udev.packages = [
|
||||
(pkgs.callPackage (
|
||||
{ stdenv, lib, coreutils, systemd }:
|
||||
stdenv.mkDerivation {
|
||||
name = "helios64-udev-ups";
|
||||
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p "$out/etc/udev/rules.d/";
|
||||
install -Dm644 "${./bsp/90-helios64-ups.rules}" \
|
||||
"$out/etc/udev/rules.d/90-helios64-ups.rules"
|
||||
substituteInPlace "$out/etc/udev/rules.d/90-helios64-ups.rules" \
|
||||
--replace '/bin/ln' '${lib.getBin coreutils}/bin/ln' \
|
||||
--replace '/usr/bin/systemctl' '${lib.getBin systemd}/bin/systemctl'
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Udev rules for UPS for the Helios64";
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
) {})
|
||||
];
|
||||
}
|
||||
32
machines/storage/s0/helios64/modules/usbnet.nix
Normal file
32
machines/storage/s0/helios64/modules/usbnet.nix
Normal file
@@ -0,0 +1,32 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
services.udev.packages = [
|
||||
# this one will set the usb net ethernet into the right mode
|
||||
# and stop it from spamming the console.
|
||||
(pkgs.callPackage (
|
||||
{ stdenv, lib, coreutils }:
|
||||
stdenv.mkDerivation {
|
||||
name = "helios64-udev-usb-net";
|
||||
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p "$out/etc/udev/rules.d/";
|
||||
install -Dm644 "${./bsp/50-usb-realtek-net.rules}" \
|
||||
"$out/etc/udev/rules.d/50-usb-realtek-net.rules"
|
||||
install -Dm644 "${./bsp/70-keep-usb-lan-as-eth1.rules}" \
|
||||
"$out/etc/udev/rules.d/70-keep-usb-lan-as-eth1.rules"
|
||||
substituteInPlace "$out/etc/udev/rules.d/50-usb-realtek-net.rules" \
|
||||
--replace '/bin/ln' '${lib.getBin coreutils}/bin/ln'
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Udev rules for the USB network interface for the Helios64";
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
) {})
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user