From 1f99ca0d370114710b1718b61e6b0a9e960d22ce Mon Sep 17 00:00:00 2001 From: Hermes Date: Fri, 12 Jun 2026 16:02:13 -0400 Subject: [PATCH] feat(uconsole): add cm5 cross-compiled nixosConfiguration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - New host: uconsole-cm5 (aarch64-linux, cross-built from x86_64) - SSH authorizedKeys: gortium.main + ai-worker.main - NetworkManager enabled (WiFi password via agenix later) - Display: vc4/panel_cwu50/rp1_dsi with empty initrd - Config.txt [pi5] section (not [cm5]) - Backlight fix service - nixos-raspberrypi → gortium/cm5-cross-v1 fork (PR #197) - nixpkgs-uconsole pinned to nixos-25.11 (kernel patch compat) V3 branch saved as archive/uconsole-cm5-v3 (Reticulum/SDR/HAM config). --- flake.nix | 57 ++++++++- hosts/uconsole-cm5/configuration.nix | 112 ++++++++++++++++++ hosts/uconsole-cm5/hardware-configuration.nix | 30 +++++ 3 files changed, 198 insertions(+), 1 deletion(-) create mode 100644 hosts/uconsole-cm5/configuration.nix create mode 100644 hosts/uconsole-cm5/hardware-configuration.nix diff --git a/flake.nix b/flake.nix index 8f8b51a..3828560 100644 --- a/flake.nix +++ b/flake.nix @@ -12,10 +12,23 @@ url = "git+https://git.lix.systems/lix-project/lix?ref=main"; inputs.nixpkgs.follows = "nixpkgs"; }; + + # uConsole CM5 — pinned nixpkgs for kernel patch compatibility + nixpkgs-uconsole.url = "github:NixOS/nixpkgs/nixos-25.11"; + nixos-uconsole = { + url = "github:nixos-uconsole/nixos-uconsole/v1.1.0"; + inputs.nixpkgs.follows = "nixpkgs-uconsole"; + }; + nixos-raspberrypi = { + url = "github:gortium/nixos-raspberrypi/cm5-cross-v1"; + inputs.nixpkgs.follows = "nixpkgs-uconsole"; + }; self.submodules = true; }; - outputs = { self, nixpkgs, agenix, lix, ... }@inputs: + outputs = { self, nixpkgs, agenix, lix + , nixpkgs-uconsole, nixos-uconsole, nixos-raspberrypi + , ... }@inputs: let system = "x86_64-linux"; keys = import ./lib/keys.nix; @@ -80,6 +93,48 @@ ./hosts/cyt-pi/hardware-configuration.nix ]; }; + + # ============================================================ + # uConsole CM5 — cross-compilé (build sur x86_64, run sur ARM) + # Approche incrémentale pour fixer l'écran + # ============================================================ + uconsole-cm5 = nixpkgs-uconsole.lib.nixosSystem { + system = "aarch64-linux"; + specialArgs = { + inherit self keys paths inputs; + nixos-raspberrypi = nixos-raspberrypi; + isCM4 = false; + }; + modules = [ + { + # Cross-compile : build sur x86_64, run sur aarch64 + nixpkgs.buildPlatform = "x86_64-linux"; + nixpkgs.hostPlatform = "aarch64-linux"; + nixpkgs.config.allowUnfree = true; + boot.loader.raspberry-pi.bootloader = "kernel"; + } + # nixos-raspberrypi — crée pkgs.rpi avec kernel/firmware cross-compilés + nixos-raspberrypi.nixosModules.nixpkgs-rpi + { + nixpkgs.overlays = [ + nixos-raspberrypi.overlays.bootloader + nixos-raspberrypi.overlays.vendor-kernel + nixos-raspberrypi.overlays.vendor-firmware + nixos-raspberrypi.overlays.kernel-and-firmware + nixos-raspberrypi.overlays.vendor-pkgs + nixos-raspberrypi.overlays.pkgs + ]; + } + # nixos-uconsole CM5 modules + nixos-uconsole.nixosModules.kernel + nixos-uconsole.nixosModules.configtxt + (nixos-uconsole.nixosModules.cm { lib = nixpkgs-uconsole.lib; isCM4 = false; }) + nixos-uconsole.nixosModules.base + # Notre config + ./hosts/uconsole-cm5/configuration.nix + ./hosts/uconsole-cm5/hardware-configuration.nix + ]; + }; }; devShells.${system}.default = devShell; }; diff --git a/hosts/uconsole-cm5/configuration.nix b/hosts/uconsole-cm5/configuration.nix new file mode 100644 index 0000000..3b4cf52 --- /dev/null +++ b/hosts/uconsole-cm5/configuration.nix @@ -0,0 +1,112 @@ +{ config, lib, pkgs, keys, ... }: + +{ + # Basic Host Info + networking.hostName = "uConsole"; + time.timeZone = "America/Montreal"; + i18n.defaultLocale = "en_CA.UTF-8"; + system.stateVersion = "25.11"; + + # ============================================================ + # SSH Access — ta clé + clé de déploiement + # ============================================================ + services.openssh = { + enable = true; + settings.PermitRootLogin = "prohibit-password"; + settings.PasswordAuthentication = false; + }; + + users.users.root = { + openssh.authorizedKeys.keys = [ + keys.users.gortium.main + keys.users.ai-worker.main + ]; + }; + + # ============================================================ + # Networking — WiFi via NetworkManager + # ============================================================ + networking.networkmanager.enable = true; + + # WiFi connection — Thierry ajoutera le password dans un secret agenix + # networking.networkmanager.connections = { ... }; + + # ============================================================ + # Kernel parameters from nixos-uconsole CM5 module + # ============================================================ + boot.kernelParams = [ + "8250.nr_uarts=1" + "console=tty1" + ]; + + # ============================================================ + # Console font for 5" 720x1280 display + # ============================================================ + console = { + earlySetup = true; + font = "ter-v24n"; + packages = with pkgs; [ terminus_font ]; + }; + + # ============================================================ + # Display — vc4/panel_cwu50 loaded AFTER RP1 PCIe init + # Rien dans initrd — tout RP1 est derrière PCIe + # ============================================================ + hardware.graphics.enable = true; + + boot.kernelModules = [ + "panel_cwu50" # uConsole DSI panel driver + "vc4" # VideoCore 4 KMS GPU driver + "rp1_dsi" # RP1 DSI bridge driver + ]; + + boot.initrd.kernelModules = lib.mkForce [ ]; + + # ============================================================ + # CM5 Config.txt — [pi5] section (pas [cm5]) + # ============================================================ + hardware.raspberry-pi.extra-config = '' + [all] + gpio=10=ip,np + gpio=11=op,dh + + [pi5] + dtparam=pciex1=off + dtoverlay=clockworkpi-uconsole-cm5 + dtoverlay=dwc2,dr_mode=host + dtoverlay=vc4-kms-v3d-pi5,cma-384 + dtparam=nohdmi1=off + ''; + + # ============================================================ + # CM5 Display Backlight Fix + # ============================================================ + systemd.services.cm5-backlight-fix = { + description = "CM5 Display Backlight Fix"; + after = [ "multi-user.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "oneshot"; + ExecStart = let + fixScript = pkgs.writeShellScript "backlight-fix" '' + for bl in /sys/class/backlight/*/brightness; do + if [ -f "$bl" ]; then + max=$(cat "$(dirname "$bl")/max_brightness" 2>/dev/null || echo 100) + echo "$max" > "$bl" 2>/dev/null || true + fi + done + ''; + in "${fixScript}"; + }; + }; + + # ============================================================ + # Minimal packages + # ============================================================ + environment.systemPackages = with pkgs; [ + git + vim + htop + libgpiod # GPIO control + ]; +} diff --git a/hosts/uconsole-cm5/hardware-configuration.nix b/hosts/uconsole-cm5/hardware-configuration.nix new file mode 100644 index 0000000..c952ffb --- /dev/null +++ b/hosts/uconsole-cm5/hardware-configuration.nix @@ -0,0 +1,30 @@ +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "usbhid" "usb_storage" "sdhci_pci" "nvme" ]; + boot.initrd.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + # SD card partitions (nixos-uconsole layout) + fileSystems."/" = { + device = "/dev/disk/by-label/NIXOS_SD"; + fsType = "ext4"; + options = [ "noatime" ]; + }; + + fileSystems."/boot/firmware" = { + device = "/dev/disk/by-label/FIRMWARE"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; + + swapDevices = [ ]; + + nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux"; + hardware.enableRedistributableFirmware = true; + powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand"; +}