diff --git a/flake.lock b/flake.lock index b954c28..d248256 100644 --- a/flake.lock +++ b/flake.lock @@ -1,24 +1,126 @@ { "nodes": { - "nixpkgs": { + "libcamera-apps-src": { + "flake": false, "locked": { - "lastModified": 1652182392, - "narHash": "sha256-H9Bmor+kfogrE0X7Fi5sh0gCUWDG4pnmYxedJyIT41A=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "aa2f845096f72dde4ad0c168eeec387cbd2eae04", + "lastModified": 1674645888, + "narHash": "sha256-UBTDHN0lMj02enB8im4Q+f/MCm/G2mFPP3pLImrZc5A=", + "owner": "raspberrypi", + "repo": "libcamera-apps", + "rev": "9f08463997b82c4bf60e12c4ea43577959a8ae15", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixos-21.11", - "repo": "nixpkgs", + "owner": "raspberrypi", + "ref": "v1.1.1", + "repo": "libcamera-apps", "type": "github" } }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "libcamera-apps-src": "libcamera-apps-src", + "rpi-bluez-firmware-src": "rpi-bluez-firmware-src", + "rpi-firmware-nonfree-src": "rpi-firmware-nonfree-src", + "rpi-firmware-stable-src": "rpi-firmware-stable-src", + "rpi-linux-5_15-src": "rpi-linux-5_15-src", + "rpi-linux-5_15_87-src": "rpi-linux-5_15_87-src", + "u-boot-src": "u-boot-src" + } + }, + "rpi-bluez-firmware-src": { + "flake": false, + "locked": { + "lastModified": 1672928175, + "narHash": "sha256-gKGK0XzNrws5REkKg/JP6SZx3KsJduu53SfH3Dichkc=", + "owner": "RPi-Distro", + "repo": "bluez-firmware", + "rev": "9556b08ace2a1735127894642cc8ea6529c04c90", + "type": "github" + }, + "original": { + "owner": "RPi-Distro", + "repo": "bluez-firmware", + "type": "github" + } + }, + "rpi-firmware-nonfree-src": { + "flake": false, + "locked": { + "lastModified": 1674638139, + "narHash": "sha256-54JKmwypD7PRQdd7k6IcF7wL8ifMavEM0UwZwmA24O4=", + "owner": "RPi-Distro", + "repo": "firmware-nonfree", + "rev": "7f29411baead874b859eda53efdc2472345ea454", + "type": "github" + }, + "original": { + "owner": "RPi-Distro", + "repo": "firmware-nonfree", + "type": "github" + } + }, + "rpi-firmware-stable-src": { + "flake": false, + "locked": { + "lastModified": 1673003776, + "narHash": "sha256-tdaH+zZwmILNFBge2gMqtzj/1Hydj9cxhPvhw+7jTrU=", + "owner": "raspberrypi", + "repo": "firmware", + "rev": "78852e166b4cf3ebb31d051e996d54792f0994b0", + "type": "github" + }, + "original": { + "owner": "raspberrypi", + "ref": "stable", + "repo": "firmware", + "type": "github" + } + }, + "rpi-linux-5_15-src": { + "flake": false, + "locked": { + "lastModified": 1675874870, + "narHash": "sha256-oy+VgoB4IdFZjGwkx88dDSpwWZj2D5t3PyXPIwDsY1Q=", + "owner": "raspberrypi", + "repo": "linux", + "rev": "14b35093ca68bf2c81bbc90aace5007142b40b40", + "type": "github" + }, + "original": { + "owner": "raspberrypi", + "ref": "rpi-5.15.y", + "repo": "linux", + "type": "github" + } + }, + "rpi-linux-5_15_87-src": { + "flake": false, + "locked": { + "lastModified": 1673628667, + "narHash": "sha256-hNLVfhalmRhhRfvu2mR/qDmmGl//Ic1eqR7N1HFj2CY=", + "owner": "raspberrypi", + "repo": "linux", + "rev": "da4c8e0ffe7a868b989211045657d600be3046a1", + "type": "github" + }, + "original": { + "owner": "raspberrypi", + "repo": "linux", + "rev": "da4c8e0ffe7a868b989211045657d600be3046a1", + "type": "github" + } + }, + "u-boot-src": { + "flake": false, + "locked": { + "narHash": "sha256-30fe8klLHRsEtEQ1VpYh4S+AflG5yCQYWlGmpWyFL8w=", + "type": "tarball", + "url": "https://ftp.denx.de/pub/u-boot/u-boot-2023.01.tar.bz2" + }, + "original": { + "type": "tarball", + "url": "https://ftp.denx.de/pub/u-boot/u-boot-2023.01.tar.bz2" } } }, diff --git a/flake.nix b/flake.nix index 9e5dd41..868a89f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,10 +1,35 @@ { description = "raspberry-pi nixos configuration"; - inputs = { }; + inputs = { + u-boot-src = { + flake = false; + url = "https://ftp.denx.de/pub/u-boot/u-boot-2023.01.tar.bz2"; + }; + rpi-linux-5_15-src = { + flake = false; + url = "github:raspberrypi/linux/rpi-5.15.y"; + }; + rpi-firmware-stable-src = { + flake = false; + url = "github:raspberrypi/firmware/stable"; + }; + rpi-firmware-nonfree-src = { + flake = false; + url = "github:RPi-Distro/firmware-nonfree"; + }; + rpi-bluez-firmware-src = { + flake = false; + url = "github:RPi-Distro/bluez-firmware"; + }; + libcamera-apps-src = { + flake = false; + url = "github:raspberrypi/libcamera-apps/v1.1.1"; + }; + }; - outputs = { self }: { - overlay = import ./overlay; + outputs = srcs@{ self, ... }: { + overlay = import ./overlay (builtins.removeAttrs srcs [ "self" ]); rpi = import ./rpi { overlay = self.overlay; }; }; } diff --git a/overlay/default.nix b/overlay/default.nix index dbcc745..14e133e 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -1,7 +1,9 @@ +{ u-boot-src, rpi-linux-5_15-src, rpi-firmware-stable-src +, rpi-firmware-nonfree-src, rpi-bluez-firmware-src, libcamera-apps-src }: final: prev: let # The version to stick at `pkgs.rpi-kernels.latest' - latest = "v5_15_87"; + latest = "v5_15_92"; # Helpers for building the `pkgs.rpi-kernels' map. rpi-kernel = { kernel, version, fw, wireless-fw, argsOverride ? null }: @@ -31,7 +33,8 @@ in { compressFirmwareXz = x: x; # A recent known working version of libcamera-apps - libcamera-apps = final.callPackage ./libcamera-apps.nix { }; + libcamera-apps = + final.callPackage ./libcamera-apps.nix { inherit libcamera-apps-src; }; # provide generic rpi arm64 u-boot uboot_rpi_arm64 = prev.buildUBoot rec { @@ -39,10 +42,7 @@ in { extraMeta.platforms = [ "aarch64-linux" ]; filesToInstall = [ "u-boot.bin" ]; version = "2023.01"; - src = prev.fetchurl { - url = "ftp://ftp.denx.de/pub/u-boot/u-boot-${version}.tar.bz2"; - sha256 = "03wm651ix783s4idj223b0nm3r6jrdnrxs1ncs8s128g72nknhk9"; - }; + src = u-boot-src; # In raspberry pi sbcs the firmware manipulates the device tree in # a variety of ways before handing it off to the linux kernel. [1] # Since we have installed u-boot in place of a linux kernel we may @@ -68,42 +68,15 @@ in { # `pkgs.rpi-kernels..{kernel,firmware,wireless-firmware}'. # # For example: `pkgs.rpi-kernels.v5_15_87.kernel' - rpi-kernels = rpi-kernels [ - { - version = "5.15.36"; - kernel = prev.fetchFromGitHub { - owner = "raspberrypi"; - repo = "linux"; - rev = "9af1cc301e4dffb830025207a54d0bc63bec16c7"; - sha256 = "fsMTUdz1XZhPaSXpU1uBV4V4VxoZKi6cwP0QJcrCy1o="; - fetchSubmodules = true; - }; - fw = prev.fetchFromGitHub { - owner = "raspberrypi"; - repo = "firmware"; - rev = "2cf8a179b3f2e6e5e5ceba4e8e544def10a49020"; - sha256 = "YG1bryflbV3W62MhZ/XMSgUJXMhCl/fe86x+CT7XZ4U="; - }; - wireless-fw = import ./raspberrypi-wireless-firmware/5.10.36.nix; - } - { - version = "5.15.87"; - kernel = prev.fetchFromGitHub { - owner = "raspberrypi"; - repo = "linux"; - rev = "da4c8e0ffe7a868b989211045657d600be3046a1"; - sha256 = "hNLVfhalmRhhRfvu2mR/qDmmGl//Ic1eqR7N1HFj2CY="; - fetchSubmodules = true; - }; - fw = prev.fetchFromGitHub { - owner = "raspberrypi"; - repo = "firmware"; - rev = "78852e166b4cf3ebb31d051e996d54792f0994b0"; - sha256 = "tdaH+zZwmILNFBge2gMqtzj/1Hydj9cxhPvhw+7jTrU="; - }; - wireless-fw = import ./raspberrypi-wireless-firmware/5.10.87.nix; - } - ] // { + rpi-kernels = rpi-kernels [{ + version = "5.15.92"; + kernel = rpi-linux-5_15-src; + fw = rpi-firmware-stable-src; + wireless-fw = import ./raspberrypi-wireless-firmware.nix { + bluez-firmware = rpi-bluez-firmware-src; + firmware-nonfree-src = rpi-firmware-nonfree-src; + }; + }] // { latest = final.rpi-kernels."${latest}"; }; } diff --git a/overlay/libcamera-apps.nix b/overlay/libcamera-apps.nix index 2271d6b..139a641 100644 --- a/overlay/libcamera-apps.nix +++ b/overlay/libcamera-apps.nix @@ -1,17 +1,11 @@ -{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, pkg-config, libjpeg, libtiff -, libpng, libcamera, libepoxy, boost, libexif }: +{ libcamera-apps-src, lib, stdenv, fetchFromGitHub, fetchpatch, cmake +, pkg-config, libjpeg, libtiff, libpng, libcamera, libepoxy, boost, libexif }: stdenv.mkDerivation rec { pname = "libcamera-apps"; version = "v1.1.0"; - src = fetchFromGitHub { - owner = "raspberrypi"; - repo = "libcamera-apps"; - rev = "4fea2eed68300dcc88e89aa30da6079d10dce822"; - sha256 = "T6BpC1lEZD00TBZ7SXChKh/m+vKYnVzSTLxBHIEJYn8="; - fetchSubmodules = true; - }; + src = libcamera-apps-src; nativeBuildInputs = [ cmake pkg-config ]; buildInputs = [ libjpeg libtiff libcamera libepoxy boost libexif libpng ]; diff --git a/overlay/raspberrypi-wireless-firmware/5.10.87.nix b/overlay/raspberrypi-wireless-firmware.nix similarity index 74% rename from overlay/raspberrypi-wireless-firmware/5.10.87.nix rename to overlay/raspberrypi-wireless-firmware.nix index 846307d..e673922 100644 --- a/overlay/raspberrypi-wireless-firmware/5.10.87.nix +++ b/overlay/raspberrypi-wireless-firmware.nix @@ -1,25 +1,11 @@ +{ bluez-firmware-src, firmware-nonfree-src }: { lib, stdenvNoCC, fetchFromGitHub }: stdenvNoCC.mkDerivation { pname = "raspberrypi-wireless-firmware"; version = "2023-01-19"; - srcs = [ - (fetchFromGitHub { - name = "bluez-firmware"; - owner = "RPi-Distro"; - repo = "bluez-firmware"; - rev = "9556b08ace2a1735127894642cc8ea6529c04c90"; - sha256 = "gKGK0XzNrws5REkKg/JP6SZx3KsJduu53SfH3Dichkc="; - }) - (fetchFromGitHub { - name = "firmware-nonfree"; - owner = "RPi-Distro"; - repo = "firmware-nonfree"; - rev = "8e349de20c8cb5d895b3568777ec53cbb333398f"; - sha256 = "45/FnaaZTEG6jLmbaXohpNpS6BEZu3DBDHqquq8ukXc="; - }) - ]; + srcs = [ bluez-firmware-src firmware-nonfree-src ]; sourceRoot = "."; diff --git a/overlay/raspberrypi-wireless-firmware/5.10.36.nix b/overlay/raspberrypi-wireless-firmware/5.10.36.nix deleted file mode 100644 index ff3e405..0000000 --- a/overlay/raspberrypi-wireless-firmware/5.10.36.nix +++ /dev/null @@ -1,56 +0,0 @@ -{ lib, stdenv, fetchFromGitHub }: - -stdenv.mkDerivation { - pname = "raspberrypi-wireless-firmware"; - version = "2021-06-28"; - - srcs = [ - (fetchFromGitHub { - name = "bluez-firmware"; - owner = "RPi-Distro"; - repo = "bluez-firmware"; - rev = "e7fd166981ab4bb9a36c2d1500205a078a35714d"; - sha256 = "1dkg8mzn7n4afi50ibrda2s33nw2qj52jjjdv9w560q601gms47b"; - }) - (fetchFromGitHub { - name = "firmware-nonfree"; - owner = "RPi-Distro"; - repo = "firmware-nonfree"; - rev = "00de3194a96397c913786945ac0af1fd6fbec45b"; - sha256 = "1xnr364dkiq6gmr21lcrj23hwc0g9y5qad8dm2maij647bgzp07r"; - }) - ]; - - sourceRoot = "."; - - dontBuild = true; - # Firmware blobs do not need fixing and should not be modified - dontFixup = true; - - installPhase = '' - runHook preInstall - mkdir -p "$out/lib/firmware/brcm" - - # Wifi firmware - for filename in firmware-nonfree/brcm/brcmfmac434??-sdio.*; do - cp "$filename" "$out/lib/firmware/brcm" - done - - # Bluetooth firmware - cp bluez-firmware/broadcom/*.hcd "$out/lib/firmware/brcm" - runHook postInstall - ''; - - outputHashMode = "recursive"; - outputHashAlgo = "sha256"; - outputHash = "0a54gyrq6jfxxvimaa4yjfiyfwf7wv58v0a32l74yrzyarr3ldby"; - - meta = with lib; { - description = - "Firmware for builtin Wifi/Bluetooth devices in the Raspberry Pi 3+ and Zero W"; - homepage = "https://github.com/RPi-Distro/firmware-nonfree"; - license = licenses.unfreeRedistributableFirmware; - platforms = platforms.linux; - maintainers = with maintainers; [ lopsided98 ]; - }; -} diff --git a/sd-image/default.nix b/sd-image/default.nix index 43aa90c..eb57c26 100644 --- a/sd-image/default.nix +++ b/sd-image/default.nix @@ -9,77 +9,80 @@ }; }; - boot.loader.grub.enable = false; - boot.loader.generic-extlinux-compatible.enable = true; + config = { + boot.loader.grub.enable = false; + boot.loader.generic-extlinux-compatible.enable = true; - boot.consoleLogLevel = lib.mkDefault 7; + boot.consoleLogLevel = lib.mkDefault 7; - # https://github.com/raspberrypi/firmware/issues/1539#issuecomment-784498108 - boot.kernelParams = [ "console=serial0,115200n8" "console=tty1" ]; + # https://github.com/raspberrypi/firmware/issues/1539#issuecomment-784498108 + boot.kernelParams = [ "console=serial0,115200n8" "console=tty1" ]; - sdImage = { - populateFirmwareCommands = let - inherit (pkgs) raspberrypifw; - configTxt = pkgs.writeText "config.txt" '' - [pi02] - kernel=u-boot-rpi_arm64.bin + sdImage = { + populateFirmwareCommands = let + inherit (pkgs) raspberrypifw; + configTxt = pkgs.writeText "config.txt" '' + [pi02] + kernel=u-boot-rpi_arm64.bin - [pi3+] - kernel=u-boot-rpi_arm64.bin + [pi3+] + kernel=u-boot-rpi_arm64.bin - [pi4] - kernel=u-boot-rpi_arm64.bin - enable_gic=1 - armstub=armstub8-gic.bin - arm_boost=1 - dtoverlay=vc4-fkms-v3d-pi4 - dtoverlay= + [pi4] + kernel=u-boot-rpi_arm64.bin + enable_gic=1 + armstub=armstub8-gic.bin + arm_boost=1 + dtoverlay=vc4-fkms-v3d-pi4 + dtoverlay= - # Otherwise the resolution will be weird in most cases, compared to - # what the pi3 firmware does by default. - disable_overscan=1 + # Otherwise the resolution will be weird in most cases, compared to + # what the pi3 firmware does by default. + disable_overscan=1 - [all] - # Boot in 64-bit mode. - arm_64bit=1 - dtparam=audio=on - dtparam=krnbt=on + [all] + # Boot in 64-bit mode. + arm_64bit=1 + dtparam=audio=on + dtparam=krnbt=on - # 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 + # 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 - '' ++ config.hardware.raspberry-pi.extra-config; - in '' - (cd ${raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/firmware/) + # 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 + ${config.hardware.raspberry-pi.extra-config} + ''; + in '' + (cd ${raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/firmware/) - # Add the config - cp ${configTxt} firmware/config.txt + # Add the config + cp ${configTxt} firmware/config.txt - # Add rpi generic u-boot - cp ${pkgs.uboot_rpi_arm64}/u-boot.bin firmware/u-boot-rpi_arm64.bin + # Add rpi generic u-boot + cp ${pkgs.uboot_rpi_arm64}/u-boot.bin firmware/u-boot-rpi_arm64.bin - # Add pi3 specific files - cp ${raspberrypifw}/share/raspberrypi/boot/bcm2710-rpi-3-b-plus.dtb firmware/ + # Add pi3 specific files + cp ${raspberrypifw}/share/raspberrypi/boot/bcm2710-rpi-3-b-plus.dtb firmware/ - # Add pi4 specific files - cp ${pkgs.raspberrypi-armstubs}/armstub8-gic.bin firmware/armstub8-gic.bin - cp ${raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-4-b.dtb firmware/ + # Add pi4 specific files + cp ${pkgs.raspberrypi-armstubs}/armstub8-gic.bin firmware/armstub8-gic.bin + cp ${raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-4-b.dtb firmware/ - # Add pi-zero-2 specific files - cp ${raspberrypifw}/share/raspberrypi/boot/bcm2710-rpi-zero-2.dtb firmware/ - cp ${raspberrypifw}/share/raspberrypi/boot/bcm2710-rpi-zero-2-w.dtb firmware/ + # Add pi-zero-2 specific files + cp ${raspberrypifw}/share/raspberrypi/boot/bcm2710-rpi-zero-2.dtb firmware/ + cp ${raspberrypifw}/share/raspberrypi/boot/bcm2710-rpi-zero-2-w.dtb firmware/ - # Add overlays - cp -r ${raspberrypifw}/share/raspberrypi/boot/overlays firmware/ - ''; - populateRootCommands = '' - mkdir -p ./files/boot - ${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot - ''; + # Add overlays + cp -r ${raspberrypifw}/share/raspberrypi/boot/overlays firmware/ + ''; + populateRootCommands = '' + mkdir -p ./files/boot + ${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot + ''; + }; }; }