From cb2ac1c1ba92c1329041a4c3f28b26ec5af90f50 Mon Sep 17 00:00:00 2001 From: Zuckerberg Date: Sat, 11 Feb 2023 16:06:01 -0700 Subject: [PATCH] Use x86 machine for NAS --- flake.nix | 2 +- machines/storage/s0/configuration.nix | 10 --- .../storage/s0/hardware-configuration.nix | 80 ++++++++++--------- machines/storage/s0/helios64/README.md | 62 -------------- machines/storage/s0/helios64/default.nix | 27 ------- .../modules/bsp/90-helios64-hwmon.rules | 23 ------ .../modules/bsp/90-helios64-ups.rules | 11 --- .../s0/helios64/modules/fancontrol.nix | 41 ---------- .../storage/s0/helios64/modules/heartbeat.nix | 22 ----- machines/storage/s0/helios64/modules/ups.nix | 51 ------------ machines/storage/s0/helios64/recommended.nix | 8 -- 11 files changed, 43 insertions(+), 294 deletions(-) delete mode 100644 machines/storage/s0/helios64/README.md delete mode 100644 machines/storage/s0/helios64/default.nix delete mode 100755 machines/storage/s0/helios64/modules/bsp/90-helios64-hwmon.rules delete mode 100644 machines/storage/s0/helios64/modules/bsp/90-helios64-ups.rules delete mode 100644 machines/storage/s0/helios64/modules/fancontrol.nix delete mode 100644 machines/storage/s0/helios64/modules/heartbeat.nix delete mode 100644 machines/storage/s0/helios64/modules/ups.nix delete mode 100644 machines/storage/s0/helios64/recommended.nix diff --git a/flake.nix b/flake.nix index 31d5c22..a956731 100644 --- a/flake.nix +++ b/flake.nix @@ -73,7 +73,7 @@ "liza" = mkSystem "x86_64-linux" nixpkgs ./machines/liza/configuration.nix; "ponyo" = mkSystem "x86_64-linux" nixpkgs ./machines/ponyo/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; "n2" = mkSystem "aarch64-linux" nixpkgs ./machines/compute/n2/configuration.nix; "n3" = mkSystem "aarch64-linux" nixpkgs ./machines/compute/n3/configuration.nix; diff --git a/machines/storage/s0/configuration.nix b/machines/storage/s0/configuration.nix index 249a029..e656040 100644 --- a/machines/storage/s0/configuration.nix +++ b/machines/storage/s0/configuration.nix @@ -2,29 +2,19 @@ { imports =[ - ./helios64 ./hardware-configuration.nix ]; networking.hostName = "s0"; - boot.loader.grub.enable = false; - boot.loader.generic-extlinux-compatible.enable = true; - system.autoUpgrade.enable = true; - boot.supportedFilesystems = [ "bcachefs" ]; - services.zerotierone.enable = true; # for education purposes only services.pykms.enable = true; services.pykms.openFirewallPort = true; - users.users.googlebot.packages = with pkgs; [ - bcachefs-tools - ]; - services.samba.enable = true; services.navidrome = { diff --git a/machines/storage/s0/hardware-configuration.nix b/machines/storage/s0/hardware-configuration.nix index 6299383..855f993 100644 --- a/machines/storage/s0/hardware-configuration.nix +++ b/machines/storage/s0/hardware-configuration.nix @@ -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, ... }: { @@ -8,51 +5,58 @@ [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot.initrd.availableKernelModules = [ - "ahci" - "usb_storage" - "bcache" - ]; + # boot + efi.enable = true; + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "uas" "sd_mod" "rtsx_pci_sdmmc" ]; boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; - boot.initrd.luks.devices."enc-pv1" = { - device = "/dev/disk/by-uuid/e3b588b6-d07f-4221-a194-e1e900299752"; - 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 - }; + # firmware + firmware.x86_64.enable = true; + ### 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."/" = - { 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"; - fsType = "bcachefs"; + { device = "rpool/nixos/root"; + 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" = - { device = "/dev/disk/by-uuid/8F7E-53C4"; + { device = "/dev/disk/by-uuid/4FB4-738E"; fsType = "vfat"; }; + swapDevices = [ ]; - swapDevices = [ - { - device = "/dev/mmcblk1p2"; - randomEncryption.enable = true; - } - ]; + networking.interfaces.eth0.useDHCP = true; - # The global useDHCP flag is deprecated, therefore explicitly set to false here. - # 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"; + powerManagement.cpuFreqGovernor = "powersave"; } diff --git a/machines/storage/s0/helios64/README.md b/machines/storage/s0/helios64/README.md deleted file mode 100644 index 2a43a5b..0000000 --- a/machines/storage/s0/helios64/README.md +++ /dev/null @@ -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). - diff --git a/machines/storage/s0/helios64/default.nix b/machines/storage/s0/helios64/default.nix deleted file mode 100644 index 3c638b5..0000000 --- a/machines/storage/s0/helios64/default.nix +++ /dev/null @@ -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; -} diff --git a/machines/storage/s0/helios64/modules/bsp/90-helios64-hwmon.rules b/machines/storage/s0/helios64/modules/bsp/90-helios64-hwmon.rules deleted file mode 100755 index b43bf4a..0000000 --- a/machines/storage/s0/helios64/modules/bsp/90-helios64-hwmon.rules +++ /dev/null @@ -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" - diff --git a/machines/storage/s0/helios64/modules/bsp/90-helios64-ups.rules b/machines/storage/s0/helios64/modules/bsp/90-helios64-ups.rules deleted file mode 100644 index b310f35..0000000 --- a/machines/storage/s0/helios64/modules/bsp/90-helios64-ups.rules +++ /dev/null @@ -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" - diff --git a/machines/storage/s0/helios64/modules/fancontrol.nix b/machines/storage/s0/helios64/modules/fancontrol.nix deleted file mode 100644 index a04e829..0000000 --- a/machines/storage/s0/helios64/modules/fancontrol.nix +++ /dev/null @@ -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; - }; - } - ) {}) - ]; -} diff --git a/machines/storage/s0/helios64/modules/heartbeat.nix b/machines/storage/s0/helios64/modules/heartbeat.nix deleted file mode 100644 index 0059c51..0000000 --- a/machines/storage/s0/helios64/modules/heartbeat.nix +++ /dev/null @@ -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" ]; - }; -} diff --git a/machines/storage/s0/helios64/modules/ups.nix b/machines/storage/s0/helios64/modules/ups.nix deleted file mode 100644 index 2a2990c..0000000 --- a/machines/storage/s0/helios64/modules/ups.nix +++ /dev/null @@ -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; - }; - } - ) {}) - ]; -} diff --git a/machines/storage/s0/helios64/recommended.nix b/machines/storage/s0/helios64/recommended.nix deleted file mode 100644 index 99e554b..0000000 --- a/machines/storage/s0/helios64/recommended.nix +++ /dev/null @@ -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; -}