From a389e1395d31f05f46daff6db645cb981228e7fb Mon Sep 17 00:00:00 2001 From: coolneng Date: Thu, 27 Feb 2025 18:00:49 +0100 Subject: [PATCH] Remove Raspberry Pi 4 specific bits --- configuration.nix | 51 +++++++++++++++++++------------ flake.nix | 4 +-- modules/device.nix | 41 ------------------------- modules/periodic.nix | 16 ---------- scripts/SATA-hat.sh | 71 -------------------------------------------- 5 files changed, 34 insertions(+), 149 deletions(-) delete mode 100644 modules/device.nix delete mode 100755 scripts/SATA-hat.sh diff --git a/configuration.nix b/configuration.nix index e7ff512..d8f0e2d 100644 --- a/configuration.nix +++ b/configuration.nix @@ -9,6 +9,34 @@ with pkgs; { + # Kernel configuration + boot = { + blacklistedKernelModules = [ + "btusb" + "bluetooth" + ]; + kernelParams = [ + "zfs.zfs_arc_max=8589934592" + "zfs.zfs_arc_min=1073741824" + ]; + supportedFilesystems = [ "zfs" ]; + zfs = { + requestEncryptionCredentials = true; + extraPools = [ "vault" ]; + }; + }; + + # Secure boot using lanzaboote + boot.loader = { + efi.canTouchEfiVariables = true; + systemd-boot = { + enable = false; + configurationLimit = 50; + editor = false; + }; + timeout = 3; + }; + # Declare system packages environment.systemPackages = [ libraspberrypi @@ -57,12 +85,6 @@ with pkgs; time.timeZone = "Europe/Brussels"; services.timesyncd.enable = true; - # Enable ZFS support - boot.supportedFilesystems = [ "zfs" ]; - - # Don't import encrypted datasets - boot.zfs.requestEncryptionCredentials = false; - # Scrub zpool monthly services.zfs.autoScrub = { enable = true; @@ -73,9 +95,9 @@ with pkgs; nix = { settings = { auto-optimise-store = true; - experimental-features = [ - "nix-command" - "flakes" + trusted-users = [ + "root" + "coolneng" ]; }; gc = { @@ -87,6 +109,7 @@ with pkgs; keep-outputs = true keep-derivations = true gc-keep-outputs = true + experimental-features = nix-command flakes ''; }; @@ -199,15 +222,6 @@ with pkgs; ]; }; - # Limit the memory and CPU use of Nix - systemd.services.nixos-upgrade.serviceConfig = { - MemoryHigh = [ "500M" ]; - MemoryMax = [ "2G" ]; - MemorySwapMax = [ "500M" ]; - CPUWeight = [ "50" ]; - CPUQuota = [ "50%" ]; - }; - # Configure git for auto-upgrade programs.git = { enable = true; @@ -233,7 +247,6 @@ with pkgs; ./modules/periodic.nix ./modules/communication.nix ./modules/information.nix - ./modules/device.nix ./modules/containers.nix ]; diff --git a/flake.nix b/flake.nix index 6561c73..d421734 100644 --- a/flake.nix +++ b/flake.nix @@ -26,7 +26,7 @@ ... }@inputs: let - system = "aarch64-linux"; + system = "x86_64-linux"; pkgs = import pkgs { inherit system; }; @@ -41,8 +41,8 @@ modules = [ (import ./configuration.nix) agenix.nixosModules.age - nixos-hardware.nixosModules.raspberry-pi-4 nix-matrix-appservices.nixosModule + inputs.nixos-hardware.nixosModules.aoostar-r1-n100 ]; specialArgs = { inherit inputs; diff --git a/modules/device.nix b/modules/device.nix deleted file mode 100644 index 537bab0..0000000 --- a/modules/device.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: - -with pkgs; - -{ - # A bunch of boot parameters needed for optimal runtime on RPi 4B - boot.kernelPackages = linuxPackages_rpi4; - boot.kernelParams = [ - "zfs.zfs_arc_max=134217728" - "console=TTYAMA0,115200" - "console=tty1" - "8250.nr_uarts=1" - "iomem=relaxed" - "strict-devmem=0" - ]; - - # Enable SATA-HAT GPIO features - boot.loader = { - grub.enable = false; - generic-extlinux-compatible.enable = lib.mkForce false; - raspberryPi = { - enable = true; - version = 4; - firmwareConfig = '' - iomem=relaxed - strict-devmem=0 - ''; - }; - }; - - # Load PWM hardware timers - hardware.raspberry-pi."4".pwm0.enable = true; - - # Enable I2C - hardware.raspberry-pi."4".i2c1.enable = true; -} diff --git a/modules/periodic.nix b/modules/periodic.nix index a6470b2..bf39514 100644 --- a/modules/periodic.nix +++ b/modules/periodic.nix @@ -35,22 +35,6 @@ in startAt = "02:00:00"; }; - # Enable SATA HAT fans - systemd.services.sata-hat = { - description = "Enable software support for SATA Hat"; - wantedBy = [ "default.target" ]; - script = '' - ${pkgs.bash}/bin/bash -c "/home/coolneng/system/scripts/SATA-hat.sh on" - ''; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = "yes"; - ExecStop = '' - ${pkgs.bash}/bin/bash -c "/home/coolneng/system/scripts/SATA-hat.sh off" - ''; - }; - }; - # Push zion changes to git daily systemd.user.services.zion-push = { description = "Push zion changes to git"; diff --git a/scripts/SATA-hat.sh b/scripts/SATA-hat.sh deleted file mode 100755 index a409752..0000000 --- a/scripts/SATA-hat.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh - -BASE_PATH=/sys/class -GPIO_PATH="$BASE_PATH"/gpio -PWM_PATH="$BASE_PATH"/pwm/pwmchip0 - -# GPIO pins -CPU_FAN=12 -HDD_FAN=13 - -# Values -LOW=0 -HIGH=1 - -export_pin() { - if [ ! -e $GPIO_PATH/gpio"$1" ]; then - echo "$1" >$GPIO_PATH/export - fi -} - -unexport_pin() { - if [ -e $GPIO_PATH/gpio"$1" ]; then - echo "$1" >$GPIO_PATH/unexport - fi -} - -set_gpio() { - export_pin "$1" - echo "out" >$GPIO_PATH/gpio"$1"/direction - echo "$2" >$GPIO_PATH/gpio"$1"/value - if [ "$3" = "clean" ]; then - unexport_pin "$1" - fi -} - -enable_pwm_channel() { - echo "$1" >$PWM_PATH/export - echo 40000 >$PWM_PATH/pwm"$1"/period - echo 30000 >$PWM_PATH/pwm"$1"/duty_cycle - echo 1 >$PWM_PATH/pwm"$1"/enable -} - -set_pwm() { - if [ "$1" = "clean" ]; then - echo 1 >$PWM_PATH/unexport - else - enable_pwm_channel 1 - fi -} - -turn_on() { - set_gpio $CPU_FAN $HIGH - set_gpio $HDD_FAN $HIGH - set_pwm -} - -turn_off() { - set_gpio $CPU_FAN $LOW clean - set_gpio $HDD_FAN $LOW clean - set_pwm clean -} - -trap turn_off INT - -if [ "$1" = "on" ]; then - turn_on -else - turn_off -fi - -exit 0