Use x86 machine for NAS

This commit is contained in:
Zuckerberg 2023-02-11 16:06:01 -07:00
parent 7f1e304012
commit cb2ac1c1ba
11 changed files with 43 additions and 294 deletions

View File

@ -73,7 +73,7 @@
"liza" = mkSystem "x86_64-linux" nixpkgs ./machines/liza/configuration.nix; "liza" = mkSystem "x86_64-linux" nixpkgs ./machines/liza/configuration.nix;
"ponyo" = mkSystem "x86_64-linux" nixpkgs ./machines/ponyo/configuration.nix; "ponyo" = mkSystem "x86_64-linux" nixpkgs ./machines/ponyo/configuration.nix;
"router" = mkSystem "x86_64-linux" nixpkgs-unstable ./machines/router/configuration.nix; "router" = mkSystem "x86_64-linux" nixpkgs-unstable ./machines/router/configuration.nix;
"s0" = mkSystem "aarch64-linux" nixpkgs-unstable ./machines/storage/s0/configuration.nix; "s0" = mkSystem "x86_64-linux" nixpkgs-unstable ./machines/storage/s0/configuration.nix;
"n1" = mkSystem "aarch64-linux" nixpkgs ./machines/compute/n1/configuration.nix; "n1" = mkSystem "aarch64-linux" nixpkgs ./machines/compute/n1/configuration.nix;
"n2" = mkSystem "aarch64-linux" nixpkgs ./machines/compute/n2/configuration.nix; "n2" = mkSystem "aarch64-linux" nixpkgs ./machines/compute/n2/configuration.nix;
"n3" = mkSystem "aarch64-linux" nixpkgs ./machines/compute/n3/configuration.nix; "n3" = mkSystem "aarch64-linux" nixpkgs ./machines/compute/n3/configuration.nix;

View File

@ -2,29 +2,19 @@
{ {
imports =[ imports =[
./helios64
./hardware-configuration.nix ./hardware-configuration.nix
]; ];
networking.hostName = "s0"; networking.hostName = "s0";
boot.loader.grub.enable = false;
boot.loader.generic-extlinux-compatible.enable = true;
system.autoUpgrade.enable = true; system.autoUpgrade.enable = true;
boot.supportedFilesystems = [ "bcachefs" ];
services.zerotierone.enable = true; services.zerotierone.enable = true;
# for education purposes only # for education purposes only
services.pykms.enable = true; services.pykms.enable = true;
services.pykms.openFirewallPort = true; services.pykms.openFirewallPort = true;
users.users.googlebot.packages = with pkgs; [
bcachefs-tools
];
services.samba.enable = true; services.samba.enable = true;
services.navidrome = { services.navidrome = {

View File

@ -1,6 +1,3 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: { config, lib, pkgs, modulesPath, ... }:
{ {
@ -8,51 +5,58 @@
[ (modulesPath + "/installer/scan/not-detected.nix") [ (modulesPath + "/installer/scan/not-detected.nix")
]; ];
boot.initrd.availableKernelModules = [ # boot
"ahci" efi.enable = true;
"usb_storage" boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "uas" "sd_mod" "rtsx_pci_sdmmc" ];
"bcache"
];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ]; boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
boot.initrd.luks.devices."enc-pv1" = { # firmware
device = "/dev/disk/by-uuid/e3b588b6-d07f-4221-a194-e1e900299752"; firmware.x86_64.enable = true;
allowDiscards = true; # SSD
};
boot.initrd.luks.devices."enc-pv2".device = "/dev/disk/by-uuid/514231c1-5934-401f-80e1-e3b6b62dc9d5";
boot.initrd.luks.devices."enc-pv3".device = "/dev/disk/by-uuid/f45abe73-d0c6-446f-b28c-7a96a3f87851";
boot.initrd.luks.devices."enc-pv4".device = "/dev/disk/by-uuid/e2c7402a-e72c-4c4a-998f-82e4c10187bc";
boot.initrd.luks.devices."enc-pv5".device = "/dev/disk/by-uuid/5d1002b8-a0ed-4a1c-99f5-24b8816d9e38";
boot.initrd.luks.devices."enc-pvUSB" = {
device = "/dev/disk/by-uuid/c8e18f86-a950-4e4e-8f3c-366cc78db29b";
allowDiscards = true; # SSD
};
### disks ###
# zfs
networking.hostId = "5e6791f0";
boot.supportedFilesystems = [ "zfs" ];
boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
# luks
boot.initrd.luks.devices."enc-pv1".device = "/dev/disk/by-uuid/d52e99a9-8825-4d0a-afc1-8edbef7e0a86";
boot.initrd.luks.devices."enc-pv2".device = "/dev/disk/by-uuid/f7275585-7760-4230-97de-36704b9a2aa3";
boot.initrd.luks.devices."enc-pv3".device = "/dev/disk/by-uuid/5d1002b8-a0ed-4a1c-99f5-24b8816d9e38";
boot.initrd.luks.devices."enc-pv4".device = "/dev/disk/by-uuid/e2c7402a-e72c-4c4a-998f-82e4c10187bc";
# mounts
fileSystems."/" = fileSystems."/" =
{ device = "/dev/mapper/enc-pv1:/dev/mapper/enc-pv2:/dev/mapper/enc-pv3:/dev/mapper/enc-pv4:/dev/mapper/enc-pv5:/dev/mapper/enc-pvUSB"; { device = "rpool/nixos/root";
fsType = "bcachefs"; fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
};
fileSystems."/home" =
{ device = "rpool/nixos/home";
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
};
fileSystems."/var/lib" =
{ device = "rpool/nixos/var/lib";
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
};
fileSystems."/var/log" =
{ device = "rpool/nixos/var/log";
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
}; };
fileSystems."/data" =
{ device = "rpool/nixos/data";
fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ];
};
fileSystems."/boot" = fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/8F7E-53C4"; { device = "/dev/disk/by-uuid/4FB4-738E";
fsType = "vfat"; fsType = "vfat";
}; };
swapDevices = [ ];
swapDevices = [ networking.interfaces.eth0.useDHCP = true;
{
device = "/dev/mmcblk1p2";
randomEncryption.enable = true;
}
];
# The global useDHCP flag is deprecated, therefore explicitly set to false here. powerManagement.cpuFreqGovernor = "powersave";
# Per-interface useDHCP will be mandatory in the future, so this generated config
# replicates the default behaviour.
networking.useDHCP = lib.mkDefault false;
networking.interfaces.eth0.useDHCP = lib.mkDefault true;
networking.interfaces.eth1.useDHCP = lib.mkDefault true;
powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand";
} }

View File

@ -1,62 +0,0 @@
Kobol Helios64
==============
The `default.nix` module provides the required setup for the system to work.
The `recommended.nix` module adds recommended settings for the system.
Status
------
### Works
- SATA hard drives
- Ethernet (1gbps)
- Serial through USB type-c (`ttyS2`)
### Untested
- Ethernet (2.5gbps)
- DP video out
- UPS behaviour
- `rootfs` on SATA drives
### Disabled
Due to misbehaviour, `ttyS0` (`&uart0`, `serial@ff180000`) has been disabled
via a kernel patch.
Without this change, using, or attempting to use `ttyS0` will break serial
output from `ttyS2`.
Kernel
------
Only Linux 5.10 (LTS) is supported, using the patch set derived from Armbian.
Requirements
------------
A *platform firmware* needs to be provided out of band for the system.
The author recommends Tow-Boot, for which a [draft pull request](https://github.com/Tow-Boot/Tow-Boot/pull/54)
adds support for the Helios64.
Any other supported *platform firmware* should work too.
> **NOTE**: at the time of writing (2021-10-10) the *platform firmware*
> **must** make use of the proprietary ram training. The open source equivalent
> will make the system unstable, and worse, will cause silent memory
> corruption, in addition to loud memory corruption.
Notes
-----
### Baud rate
The serial baud rate is configured for `115200`, which is a more common default
than the usual for Rockchip at `1500000`. See [the rationale for the decision](https://github.com/Tow-Boot/Tow-Boot/pull/33).

View File

@ -1,27 +0,0 @@
{ config, pkgs, lib, ... }:
{
imports = [
./modules/fancontrol.nix
./modules/heartbeat.nix
./modules/ups.nix
];
boot.kernelParams = lib.mkAfter [
"console=ttyS2,115200n8"
"earlycon=uart8250,mmio32,0xff1a0000"
];
# Required for rootfs on sata
boot.initrd.availableKernelModules = [
"pcie-rockchip-host" # required for rootfs on pcie sata disks
"phy-rockchip-pcie" # required for rootfs on pcie sata disks
"phy-rockchip-usb" # maybe not needed
"uas" # required for rootfs on USB 3.0 sata disks
];
# bcachefs kernel is 5.15. but need patches that are only in 5.16+
# Patch the device tree to add support for getting the cpu thermal temp
hardware.deviceTree.enable = true;
hardware.deviceTree.kernelPackage = pkgs.linux_latest;
}

View File

@ -1,23 +0,0 @@
# Helios64 persistent hwmon
ACTION=="remove", GOTO="helios64_hwmon_end"
#
KERNELS=="fan1", SUBSYSTEMS=="platform", ENV{_HELIOS64_FAN_}="p6", ENV{_IS_HELIOS64_FAN_}="1", ENV{IS_HELIOS64_HWMON}="1"
KERNELS=="fan2", 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_thermal", 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"

View File

@ -1,11 +0,0 @@
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"

View File

@ -1,41 +0,0 @@
{ 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;
};
}
) {})
];
}

View File

@ -1,22 +0,0 @@
{ 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\\:green\\:status/trigger'
# this led is not supported yet in the kernel i'm using
# ${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" ];
};
}

View File

@ -1,51 +0,0 @@
{ 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;
};
}
) {})
];
}

View File

@ -1,8 +0,0 @@
{ lib, ... }:
{
# Since 20.03, you must explicitly specify to use dhcp on an interface
networking.interfaces.eth0.useDHCP = lib.mkDefault true;
# Helps with 4GiB of RAM
zramSwap.enable = lib.mkDefault true;
}