WIP: Infini-RASPBERRY: improve config

This commit is contained in:
Infinidoge 2024-06-23 21:33:02 +00:00
parent c50c9710f0
commit a2adaa5182
Signed by: Infinidoge
SSH key fingerprint: SHA256:oAMyvotlNFraMmZmr+p6AxnNfW/GioTs1pOn3V4tQ7A
3 changed files with 75 additions and 68 deletions

View file

@ -9,6 +9,7 @@ with lib;
system.stateVersion = "23.11"; system.stateVersion = "23.11";
modules = { modules = {
hardware.form.raspi = true; hardware.form.raspi = true;
boot.ignore = true;
}; };
nixpkgs.overlays = [ nixpkgs.overlays = [
@ -18,7 +19,7 @@ with lib;
}) })
]; ];
nixpkgs.hostPlatform.system = "aarch64-linux"; nixpkgs.hostPlatform = lib.mkForce "aarch64-linux";
modules.hardware = { modules.hardware = {
wireless.enable = mkDefault true; wireless.enable = mkDefault true;
@ -46,11 +47,16 @@ with lib;
}; };
}; };
fileSystems."/" = {
device = "/dev/nmcblk0p2";
fsType = "ext4";
};
documentation = { documentation = {
enable = false; enable = false;
doc.enable = false; doc.enable = false;
man.enable = false; man.enable = false;
man.man-dp.enable = false; man.man-db.enable = false;
man.mandoc.enable = false; man.mandoc.enable = false;
nixos.enable = false; nixos.enable = false;
}; };

View file

@ -1,15 +1,15 @@
{ modulesPath, config, lib, pkgs, ... }: { modulesPath, config, lib, pkgs, ... }:
{ {
formatAttr = "sdImage"; #formatAttr = "sdImage";
imports = [ #imports = [
"${modulesPath}/installer/sd-card/sd-image.nix" # "${modulesPath}/installer/sd-card/sd-image.nix"
"${modulesPath}/profiles/installation-device.nix" # "${modulesPath}/profiles/installation-device.nix"
]; #];
# sd-image-aarch64-installer/sd-image-raspberrypi-installer # sd-image-aarch64-installer/sd-image-raspberrypi-installer
installer.cloneConfig = false; #installer.cloneConfig = false;
# sd-image-raspberrypi # sd-image-raspberrypi
boot.consoleLogLevel = lib.mkDefault 7; boot.consoleLogLevel = lib.mkDefault 7;
@ -20,68 +20,68 @@
# - ttyAMA0: for QEMU's -machine virt # - ttyAMA0: for QEMU's -machine virt
boot.kernelParams = [ "console=ttyS0,115200n8" "console=ttyAMA0,115200n8" "console=tty0" ]; boot.kernelParams = [ "console=ttyS0,115200n8" "console=ttyAMA0,115200n8" "console=tty0" ];
sdImage = { #sdImage = {
populateFirmwareCommands = # populateFirmwareCommands =
let # let
configTxt = pkgs.writeText "config.txt" '' # configTxt = pkgs.writeText "config.txt" ''
[pi3] # [pi3]
kernel=u-boot-rpi3.bin # kernel=u-boot-rpi3.bin
[pi02] # [pi02]
kernel=u-boot-rpi3.bin # kernel=u-boot-rpi3.bin
[pi4] # [pi4]
kernel=u-boot-rpi4.bin # kernel=u-boot-rpi4.bin
enable_gic=1 # enable_gic=1
armstub=armstub8-gic.bin # armstub=armstub8-gic.bin
#
# # Otherwise the resolution will be weird in most cases, compared to
# # what the pi3 firmware does by default.
# disable_overscan=1
#
# # Supported in newer board revisions
# arm_boost=1
#
# [cm4]
# # Enable host mode on the 2711 built-in XHCI USB controller.
# # This line should be removed if the legacy DWC2 controller is required
# # (e.g. for USB device mode) or if USB support is not required.
# otg_mode=1
#
# [all]
# # Boot in 64-bit mode.
# arm_64bit=1
#
# # U-Boot needs this to work, regardless of whether UART is actually used or not.
# # Look in arch/arm/mach-bcm283x/Kconfig in the U-Boot tree to see if this is still
# # a requirement in the future.
# enable_uart=1
#
# # Prevent the firmware from smashing the framebuffer setup done by the mainline kernel
# # when attempting to show low-voltage or overtemperature warnings.
# avoid_warnings=1
# '';
# in
# ''
# (cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/firmware/)
# Otherwise the resolution will be weird in most cases, compared to # # Add the config
# what the pi3 firmware does by default. # cp ${configTxt} firmware/config.txt
disable_overscan=1
# Supported in newer board revisions # # Add pi3 specific files
arm_boost=1 # cp ${pkgs.ubootRaspberryPi3_64bit}/u-boot.bin firmware/u-boot-rpi3.bin
[cm4] # # Add pi4 specific files
# Enable host mode on the 2711 built-in XHCI USB controller. # cp ${pkgs.ubootRaspberryPi4_64bit}/u-boot.bin firmware/u-boot-rpi4.bin
# This line should be removed if the legacy DWC2 controller is required # cp ${pkgs.raspberrypi-armstubs}/armstub8-gic.bin firmware/armstub8-gic.bin
# (e.g. for USB device mode) or if USB support is not required. # cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-4-b.dtb firmware/
otg_mode=1 # cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-400.dtb firmware/
# cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-cm4.dtb firmware/
[all] # cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-cm4s.dtb firmware/
# Boot in 64-bit mode. # '';
arm_64bit=1 # populateRootCommands = ''
# mkdir -p ./files/boot
# U-Boot needs this to work, regardless of whether UART is actually used or not. # ${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot
# Look in arch/arm/mach-bcm283x/Kconfig in the U-Boot tree to see if this is still # '';
# a requirement in the future. #};
enable_uart=1
# Prevent the firmware from smashing the framebuffer setup done by the mainline kernel
# when attempting to show low-voltage or overtemperature warnings.
avoid_warnings=1
'';
in
''
(cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/firmware/)
# Add the config
cp ${configTxt} firmware/config.txt
# Add pi3 specific files
cp ${pkgs.ubootRaspberryPi3_64bit}/u-boot.bin firmware/u-boot-rpi3.bin
# Add pi4 specific files
cp ${pkgs.ubootRaspberryPi4_64bit}/u-boot.bin firmware/u-boot-rpi4.bin
cp ${pkgs.raspberrypi-armstubs}/armstub8-gic.bin firmware/armstub8-gic.bin
cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-4-b.dtb firmware/
cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-400.dtb firmware/
cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-cm4.dtb firmware/
cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-cm4s.dtb firmware/
'';
populateRootCommands = ''
mkdir -p ./files/boot
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot
'';
};
} }

View file

@ -14,13 +14,14 @@ in
efiSysMountPoint = mkOpt path "/boot/efi"; efiSysMountPoint = mkOpt path "/boot/efi";
}; };
systemd-boot.enable = mkBoolOpt false; systemd-boot.enable = mkBoolOpt false;
ignore = mkBoolOpt false;
}; };
config = mkMerge [ config = mkMerge [
{ {
assertions = [ assertions = [
{ {
assertion = (count (v: v) [ cfg.grub.enable cfg.systemd-boot.enable config.wsl.enable ]) == 1; assertion = (count (v: v) [ cfg.grub.enable cfg.systemd-boot.enable config.wsl.enable cfg.ignore ]) == 1;
message = "Must enable one and only one bootloader"; message = "Must enable one and only one bootloader";
} }
]; ];