From d039a262cecc42897c4d8b3014e83cadbd9c46e3 Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Thu, 3 Oct 2024 18:39:26 -0400 Subject: [PATCH 01/20] disable sd-image --- flake.nix | 13 ++++++++----- rpi/default.nix | 8 ++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/flake.nix b/flake.nix index ed8be8e..c0acdc3 100644 --- a/flake.nix +++ b/flake.nix @@ -53,15 +53,18 @@ core = import ./overlays (builtins.removeAttrs srcs [ "self" ]); libcamera = import ./overlays/libcamera.nix (builtins.removeAttrs srcs [ "self" ]); }; - nixosModules.raspberry-pi = import ./rpi { - inherit pinned; - core-overlay = self.overlays.core; - libcamera-overlay = self.overlays.libcamera; + nixosModules = { + raspberry-pi = import ./rpi { + inherit pinned; + core-overlay = self.overlays.core; + libcamera-overlay = self.overlays.libcamera; + }; + sd-image = import ./sd-image; }; nixosConfigurations = { rpi-example = srcs.nixpkgs.lib.nixosSystem { system = "aarch64-linux"; - modules = [ self.nixosModules.raspberry-pi ./example ]; + modules = [ self.nixosModules.raspberry-pi self.nixosModules.sd-image ./example ]; }; }; checks.aarch64-linux = self.packages.aarch64-linux; diff --git a/rpi/default.nix b/rpi/default.nix index 02b582a..57b93a1 100644 --- a/rpi/default.nix +++ b/rpi/default.nix @@ -8,7 +8,7 @@ let kernel = pkgs.rpi-kernels."${version}"."${board}"; in { - imports = [ ../sd-image ./config.nix ./i2c.nix ]; + imports = [ ./config.nix ./i2c.nix ]; options = with lib; { raspberry-pi-nix = { @@ -93,7 +93,7 @@ in { Type = "oneshot"; MountImages = - "/dev/disk/by-label/${config.sdImage.firmwarePartitionName}:${firmware-path}"; + "/dev/disk/by-label/FIRMWARE:${firmware-path}"; StateDirectory = "raspberrypi-firmware"; ExecStart = pkgs.writeShellScript "migrate-rpi-firmware" '' shopt -s nullglob @@ -308,8 +308,8 @@ in # table, so the partition table id is a 1-indexed hex # number. So, we drop the hex prefix and stick on a "02" to # refer to the root partition. - "root=PARTUUID=${lib.strings.removePrefix "0x" config.sdImage.firmwarePartitionID}-02" - "rootfstype=ext4" + # "root=PARTUUID=${lib.strings.removePrefix "0x" config.sdImage.firmwarePartitionID}-02" + # "rootfstype=ext4" "fsck.repair=yes" "rootwait" "init=/sbin/init" From ee53143215d82acfe159009b5745795828fddb5b Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Sun, 3 Nov 2024 12:06:15 -0500 Subject: [PATCH 02/20] add initrd --- rpi/default.nix | 11 +++++++++++ sd-image/default.nix | 2 ++ 2 files changed, 13 insertions(+) diff --git a/rpi/default.nix b/rpi/default.nix index 57b93a1..8a15a9b 100644 --- a/rpi/default.nix +++ b/rpi/default.nix @@ -6,6 +6,7 @@ let version = cfg.kernel-version; board = cfg.board; kernel = pkgs.rpi-kernels."${version}"."${board}"; + initrd = "${config.system.build.initialRamdisk}/${config.system.boot.loader.initrdFile}"; in { imports = [ ./config.nix ./i2c.nix ]; @@ -130,6 +131,8 @@ in touch "$STATE_DIRECTORY/kernel-migration-in-progress" cp "$KERNEL" "$TMPFILE" mv -T "$TMPFILE" "$TARGET_FIRMWARE_DIR/kernel.img" + cp "${initrd}" "$TMPFILE" + mv -T "$TMPFILE" "$TARGET_FIRMWARE_DIR/initrd" echo "${ builtins.toString kernel }" > "$STATE_DIRECTORY/kernel-version" @@ -243,6 +246,14 @@ in enable = true; value = if cfg.uboot.enable then "u-boot-rpi-arm64.bin" else "kernel.img"; }; + ramfsfile = { + enable = !cfg.uboot.enable; + value = "initrd"; + }; + ramfsaddr = { + enable = !cfg.uboot.enable; + value = -1; + }; arm_64bit = { enable = true; value = true; diff --git a/sd-image/default.nix b/sd-image/default.nix index 9e9930a..fb9c684 100644 --- a/sd-image/default.nix +++ b/sd-image/default.nix @@ -23,6 +23,7 @@ version = cfg.kernel-version; board = cfg.board; kernel = pkgs.rpi-kernels."${version}"."${board}"; + initrd = "${config.system.build.initialRamdisk}/${config.system.boot.loader.initrdFile}"; populate-kernel = if cfg.uboot.enable then '' @@ -30,6 +31,7 @@ '' else '' cp "${kernel}/Image" firmware/kernel.img + cp "${initrd}" firmware/initrd cp "${kernel-params}" firmware/cmdline.txt ''; in From f872d7748f503af66ed577aaf9b621c69235f40c Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Sun, 3 Nov 2024 20:20:01 -0500 Subject: [PATCH 03/20] shuffle kernel params --- rpi/default.nix | 10 ++-------- sd-image/default.nix | 11 ++++++++++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/rpi/default.nix b/rpi/default.nix index 8a15a9b..3d9bb64 100644 --- a/rpi/default.nix +++ b/rpi/default.nix @@ -315,14 +315,8 @@ in kernelParams = if cfg.uboot.enable then [ ] else [ - # This is ugly and fragile, but the sdImage image has an msdos - # table, so the partition table id is a 1-indexed hex - # number. So, we drop the hex prefix and stick on a "02" to - # refer to the root partition. - # "root=PARTUUID=${lib.strings.removePrefix "0x" config.sdImage.firmwarePartitionID}-02" - # "rootfstype=ext4" - "fsck.repair=yes" - "rootwait" + "console=tty1" + "console=serial0,115200n8" "init=/sbin/init" ]; initrd = { diff --git a/sd-image/default.nix b/sd-image/default.nix index fb9c684..a9b3f68 100644 --- a/sd-image/default.nix +++ b/sd-image/default.nix @@ -9,7 +9,16 @@ boot.consoleLogLevel = lib.mkDefault 7; # https://github.com/raspberrypi/firmware/issues/1539#issuecomment-784498108 - boot.kernelParams = [ "console=serial0,115200n8" "console=tty1" ]; + boot.kernelParams = [ + # This is ugly and fragile, but the sdImage image has an msdos + # table, so the partition table id is a 1-indexed hex + # number. So, we drop the hex prefix and stick on a "02" to + # refer to the root partition. + "root=PARTUUID=${lib.strings.removePrefix "0x" config.sdImage.firmwarePartitionID}-02" + "rootfstype=ext4" + "fsck.repair=yes" + "rootwait" + ]; sdImage = let From 61d43e92fd7530d0162d9125a6cb9f27b4e1e32c Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Mon, 4 Nov 2024 22:57:26 -0500 Subject: [PATCH 04/20] use config.system.boot.loader.kernelFile --- rpi/default.nix | 2 +- sd-image/default.nix | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rpi/default.nix b/rpi/default.nix index c6d73ce..339d3f0 100644 --- a/rpi/default.nix +++ b/rpi/default.nix @@ -102,7 +102,7 @@ in TARGET_FIRMWARE_DIR="${firmware-path}" TARGET_OVERLAYS_DIR="$TARGET_FIRMWARE_DIR/overlays" TMPFILE="$TARGET_FIRMWARE_DIR/tmp" - KERNEL="${kernel}/Image" + KERNEL="${kernel}/${config.system.boot.loader.kernelFile}" SHOULD_UBOOT=${if cfg.uboot.enable then "1" else "0"} SRC_FIRMWARE_DIR="${pkgs.raspberrypifw}/share/raspberrypi/boot" STARTFILES=("$SRC_FIRMWARE_DIR"/start*.elf) diff --git a/sd-image/default.nix b/sd-image/default.nix index 99a1be4..931fb29 100644 --- a/sd-image/default.nix +++ b/sd-image/default.nix @@ -31,7 +31,7 @@ cfg = config.raspberry-pi-nix; version = cfg.kernel-version; board = cfg.board; - kernel = config.system.build.kernel; + kernel = "${config.system.build.kernel}/${config.system.boot.loader.kernelFile}"; initrd = "${config.system.build.initialRamdisk}/${config.system.boot.loader.initrdFile}"; populate-kernel = if cfg.uboot.enable @@ -39,7 +39,7 @@ cp ${cfg.uboot.package}/u-boot.bin firmware/u-boot-rpi-arm64.bin '' else '' - cp "${kernel}/Image" firmware/kernel.img + cp "${kernel}" firmware/kernel.img cp "${initrd}" firmware/initrd cp "${kernel-params}" firmware/cmdline.txt ''; From beb01f006a795fa1c3d46ca2a7a3dd199d919b0b Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Mon, 11 Nov 2024 11:36:56 -0500 Subject: [PATCH 05/20] add firmware-partition-label option --- rpi/default.nix | 7 ++++++- sd-image/sd-image.nix | 18 ++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/rpi/default.nix b/rpi/default.nix index 339d3f0..70d9509 100644 --- a/rpi/default.nix +++ b/rpi/default.nix @@ -26,6 +26,11 @@ in without the _defconfig part. ''; }; + firmware-partition-label = mkOption { + default = "FIRMWARE"; + type = types.str; + description = "label of rpi firmware partition"; + }; pin-inputs = { enable = mkOption { default = true; @@ -94,7 +99,7 @@ in { Type = "oneshot"; MountImages = - "/dev/disk/by-label/FIRMWARE:${firmware-path}"; + "/dev/disk/by-label/${cfg.firmware-partition-label}:${firmware-path}"; StateDirectory = "raspberrypi-firmware"; ExecStart = pkgs.writeShellScript "migrate-rpi-firmware" '' shopt -s nullglob diff --git a/sd-image/sd-image.nix b/sd-image/sd-image.nix index 9ca69d8..60eedfc 100644 --- a/sd-image/sd-image.nix +++ b/sd-image/sd-image.nix @@ -30,7 +30,8 @@ let } // optionalAttrs (config.sdImage.rootPartitionUUID != null) { uuid = config.sdImage.rootPartitionUUID; }); -in { +in +{ imports = [ ]; options.sdImage = { @@ -82,14 +83,6 @@ in { ''; }; - firmwarePartitionName = mkOption { - type = types.str; - default = "FIRMWARE"; - description = '' - Name of the filesystem which holds the boot firmware. - ''; - }; - rootPartitionUUID = mkOption { type = types.nullOr types.str; default = null; @@ -160,7 +153,7 @@ in { config = { fileSystems = { "/boot/firmware" = { - device = "/dev/disk/by-label/${config.sdImage.firmwarePartitionName}"; + device = "/dev/disk/by-label/${config.raspberry-pi-nix.firmware-partition-label}"; fsType = "vfat"; }; "/" = { @@ -226,7 +219,7 @@ in { # Create a FAT32 /boot/firmware partition of suitable size into firmware_part.img eval $(partx $img -o START,SECTORS --nr 1 --pairs) truncate -s $((SECTORS * 512)) firmware_part.img - faketime "1970-01-01 00:00:00" mkfs.vfat -i ${config.sdImage.firmwarePartitionID} -n ${config.sdImage.firmwarePartitionName} firmware_part.img + faketime "1970-01-01 00:00:00" mkfs.vfat -i ${config.sdImage.firmwarePartitionID} -n ${config.raspberry-pi-nix.firmware-partition-label} firmware_part.img # Populate the files intended for /boot/firmware mkdir firmware @@ -244,7 +237,8 @@ in { zstd -T$NIX_BUILD_CORES --rm $img fi ''; - }) { }; + }) + { }; boot.postBootCommands = lib.mkIf config.sdImage.expandOnBoot '' # On the first boot do some maintenance tasks From b7c3578710785c93c7d9e714bb1c8dd2421875bb Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Tue, 12 Nov 2024 12:31:36 -0500 Subject: [PATCH 06/20] move comment --- rpi/default.nix | 1 + sd-image/default.nix | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/rpi/default.nix b/rpi/default.nix index 70d9509..5900692 100644 --- a/rpi/default.nix +++ b/rpi/default.nix @@ -321,6 +321,7 @@ in if cfg.uboot.enable then [ ] else [ "console=tty1" + # https://github.com/raspberrypi/firmware/issues/1539#issuecomment-784498108 "console=serial0,115200n8" "init=/sbin/init" ]; diff --git a/sd-image/default.nix b/sd-image/default.nix index 931fb29..b845de3 100644 --- a/sd-image/default.nix +++ b/sd-image/default.nix @@ -8,7 +8,6 @@ boot.consoleLogLevel = lib.mkDefault 7; - # https://github.com/raspberrypi/firmware/issues/1539#issuecomment-784498108 boot.kernelParams = [ # This is ugly and fragile, but the sdImage image has an msdos # table, so the partition table id is a 1-indexed hex From 848c5add7f5c4ad0792c86d9db620c6aa4abc30e Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Tue, 12 Nov 2024 12:36:49 -0500 Subject: [PATCH 07/20] readme tweaks --- README.md | 67 +++++-------------------------------------------------- 1 file changed, 5 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 91ca157..4c7882e 100644 --- a/README.md +++ b/README.md @@ -19,64 +19,7 @@ and `rpi/config.nix`. The other modules are mostly wrappers that set ## Example -See the `rpi-example` config in this flake for a CI-checked example. - -```nix -{ - description = "raspberry-pi-nix example"; - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; - raspberry-pi-nix.url = "github:nix-community/raspberry-pi-nix"; - }; - - outputs = { self, nixpkgs, raspberry-pi-nix }: - let - inherit (nixpkgs.lib) nixosSystem; - basic-config = { pkgs, lib, ... }: { - # bcm2711 for rpi 3, 3+, 4, zero 2 w - # bcm2712 for rpi 5 - # See the docs at: - # https://www.raspberrypi.com/documentation/computers/linux_kernel.html#native-build-configuration - raspberry-pi-nix.board = "bcm2711"; - time.timeZone = "America/New_York"; - users.users.root.initialPassword = "root"; - networking = { - hostName = "basic-example"; - useDHCP = false; - interfaces = { - wlan0.useDHCP = true; - eth0.useDHCP = true; - }; - }; - hardware = { - bluetooth.enable = true; - raspberry-pi = { - config = { - all = { - base-dt-params = { - # enable autoprobing of bluetooth driver - # https://github.com/raspberrypi/linux/blob/c8c99191e1419062ac8b668956d19e788865912a/arch/arm/boot/dts/overlays/README#L222-L224 - krnbt = { - enable = true; - value = "on"; - }; - }; - }; - }; - }; - }; - }; - - in { - nixosConfigurations = { - rpi-example = nixosSystem { - system = "aarch64-linux"; - modules = [ raspberry-pi-nix.nixosModules.raspberry-pi basic-config ]; - }; - }; - }; -} -``` +See the `rpi-example` config in this flake for an example config built by CI. ## Using the provided cache to avoid compiling linux This repo uses the raspberry pi linux kernel fork, and compiling linux takes a @@ -87,10 +30,10 @@ to use this cache. ## Building an sd-card image -An image suitable for flashing to an sd-card can be found at the -attribute `config.system.build.sdImage`. For example, if you wanted to -build an image for `rpi-example` in the above configuration -example you could run: +Include the provided `sd-image` nixos module this flake provides, then an image +suitable for flashing to an sd-card can be found at the attribute +`config.system.build.sdImage`. For example, if you wanted to build an image for +`rpi-example` in the above configuration example you could run: ``` nix build '.#nixosConfigurations.rpi-example.config.system.build.sdImage' From aaec735faf81ff05356d65c7408136d2c1522d34 Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Mon, 18 Nov 2024 09:56:57 -0500 Subject: [PATCH 08/20] add stability note --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 4c7882e..8c94ef9 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,12 @@ The important modules are `overlay/default.nix`, `rpi/default.nix`, and `rpi/config.nix`. The other modules are mostly wrappers that set `config.txt` settings and enable required kernel modules. +## Stability note + +`master` is the development branch -- if you want to avoid breaking changes, you +should pin your flake to a specific release and refer to the release notes when +upgrading. + ## Example See the `rpi-example` config in this flake for an example config built by CI. From 4a74a0208c3ab31e4e7d07367361aef2cf648b1a Mon Sep 17 00:00:00 2001 From: empunkt <102794+nevesenin@users.noreply.github.com> Date: Tue, 26 Nov 2024 13:35:07 +0100 Subject: [PATCH 09/20] Determine partition number for root partition by PARTN column --- sd-image/sd-image.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sd-image/sd-image.nix b/sd-image/sd-image.nix index 60eedfc..b9fed6a 100644 --- a/sd-image/sd-image.nix +++ b/sd-image/sd-image.nix @@ -248,7 +248,7 @@ in # Figure out device names for the boot device and root filesystem. rootPart=$(${pkgs.util-linux}/bin/findmnt -n -o SOURCE /) bootDevice=$(lsblk -npo PKNAME $rootPart) - partNum=$(lsblk -npo MAJ:MIN $rootPart | ${pkgs.gawk}/bin/awk -F: '{print $2}') + partNum=$(lsblk -npo PARTN $rootPart) # Resize the root partition and the filesystem to fit the disk echo ",+," | sfdisk -N$partNum --no-reread $bootDevice From 97c51868c6a820951439162507b80e1b026d8ad4 Mon Sep 17 00:00:00 2001 From: Jamie Magee Date: Thu, 26 Dec 2024 11:07:45 -0800 Subject: [PATCH 10/20] Update kernel from 6.6.54 to 6.6.67 --- flake.lock | 10 +++++----- flake.nix | 2 +- overlays/default.nix | 6 +++--- rpi/default.nix | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index abb934b..e06aee3 100644 --- a/flake.lock +++ b/flake.lock @@ -59,7 +59,7 @@ "rpi-firmware-nonfree-src": "rpi-firmware-nonfree-src", "rpi-firmware-src": "rpi-firmware-src", "rpi-linux-6_10_12-src": "rpi-linux-6_10_12-src", - "rpi-linux-6_6_54-src": "rpi-linux-6_6_54-src", + "rpi-linux-6_6_67-src": "rpi-linux-6_6_67-src", "rpicam-apps-src": "rpicam-apps-src", "u-boot-src": "u-boot-src" } @@ -132,14 +132,14 @@ "type": "github" } }, - "rpi-linux-6_6_54-src": { + "rpi-linux-6_6_67-src": { "flake": false, "locked": { - "lastModified": 1728155174, - "narHash": "sha256-/8RjW35XQMnshjAE4Ey8j3oWzE2GOntnBYY6PlvZGhs=", + "lastModified": 1734790986, + "narHash": "sha256-q9swM2TmmuzbUuQnbLZk5PseKWD7/SNPwtth6bpGIqE=", "owner": "raspberrypi", "repo": "linux", - "rev": "12f0f28db3afe451a81a34c5a444f6841c10067c", + "rev": "811ff707533bcd67cdcd368bbd46223082009b12", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index c0acdc3..d48a39c 100644 --- a/flake.nix +++ b/flake.nix @@ -7,7 +7,7 @@ flake = false; url = "https://ftp.denx.de/pub/u-boot/u-boot-2024.07.tar.bz2"; }; - rpi-linux-6_6_54-src = { + rpi-linux-6_6_67-src = { flake = false; url = "github:raspberrypi/linux/rpi-6.6.y"; }; diff --git a/overlays/default.nix b/overlays/default.nix index 162330c..3d5c6d9 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,5 +1,5 @@ { u-boot-src -, rpi-linux-6_6_54-src +, rpi-linux-6_6_67-src , rpi-linux-6_10_12-src , rpi-firmware-src , rpi-firmware-nonfree-src @@ -9,7 +9,7 @@ final: prev: let versions = { - v6_6_54.src = rpi-linux-6_6_54-src; + v6_6_67.src = rpi-linux-6_6_67-src; v6_10_12 = { src = rpi-linux-6_10_12-src; patches = [ @@ -116,7 +116,7 @@ in # rpi kernels and firmware are available at # `pkgs.rpi-kernels..'. # - # For example: `pkgs.rpi-kernels.v6_6_54.bcm2712' + # For example: `pkgs.rpi-kernels.v6_6_67.bcm2712' rpi-kernels = rpi-kernels ( final.lib.cartesianProduct { board = boards; version = (builtins.attrNames versions); } diff --git a/rpi/default.nix b/rpi/default.nix index 5900692..b6be690 100644 --- a/rpi/default.nix +++ b/rpi/default.nix @@ -14,7 +14,7 @@ in options = with lib; { raspberry-pi-nix = { kernel-version = mkOption { - default = "v6_6_54"; + default = "v6_6_67"; type = types.str; description = "Kernel version to build."; }; From f85fbd621f353db2654173300c75e8c00fc8b6b5 Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Mon, 6 Jan 2025 10:19:04 -0500 Subject: [PATCH 11/20] bump nixpkgs to 24.11 --- flake.lock | 8 ++++---- flake.nix | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index e06aee3..d6df713 100644 --- a/flake.lock +++ b/flake.lock @@ -36,16 +36,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1728193676, - "narHash": "sha256-PbDWAIjKJdlVg+qQRhzdSor04bAPApDqIv2DofTyynk=", + "lastModified": 1736061677, + "narHash": "sha256-DjkQPnkAfd7eB522PwnkGhOMuT9QVCZspDpJJYyOj60=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ecbc1ca8ffd6aea8372ad16be9ebbb39889e55b6", + "rev": "cbd8ec4de4469333c82ff40d057350c30e9f7d36", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-24.05", + "ref": "nixos-24.11", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index d48a39c..652ae10 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "raspberry-pi nixos configuration"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; u-boot-src = { flake = false; url = "https://ftp.denx.de/pub/u-boot/u-boot-2024.07.tar.bz2"; From 25b46a0be002fbc4f4b5b36ba7d2ce9652d23c53 Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Wed, 8 Jan 2025 11:54:30 -0500 Subject: [PATCH 12/20] add stable kernel --- flake.lock | 18 ++++++++++++++++++ flake.nix | 4 ++++ overlays/default.nix | 2 ++ 3 files changed, 24 insertions(+) diff --git a/flake.lock b/flake.lock index d6df713..4f68be4 100644 --- a/flake.lock +++ b/flake.lock @@ -60,6 +60,7 @@ "rpi-firmware-src": "rpi-firmware-src", "rpi-linux-6_10_12-src": "rpi-linux-6_10_12-src", "rpi-linux-6_6_67-src": "rpi-linux-6_6_67-src", + "rpi-linux-stable-src": "rpi-linux-stable-src", "rpicam-apps-src": "rpicam-apps-src", "u-boot-src": "u-boot-src" } @@ -149,6 +150,23 @@ "type": "github" } }, + "rpi-linux-stable-src": { + "flake": false, + "locked": { + "lastModified": 1728403745, + "narHash": "sha256-phCxkuO+jUGZkfzSrBq6yErQeO2Td+inIGHxctXbD5U=", + "owner": "raspberrypi", + "repo": "linux", + "rev": "5aeecea9f4a45248bcf564dec924965e066a7bfd", + "type": "github" + }, + "original": { + "owner": "raspberrypi", + "ref": "stable_20241008", + "repo": "linux", + "type": "github" + } + }, "rpicam-apps-src": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index 652ae10..390d550 100644 --- a/flake.nix +++ b/flake.nix @@ -7,6 +7,10 @@ flake = false; url = "https://ftp.denx.de/pub/u-boot/u-boot-2024.07.tar.bz2"; }; + rpi-linux-stable-src = { + flake = false; + url = "github:raspberrypi/linux/stable_20241008"; + }; rpi-linux-6_6_67-src = { flake = false; url = "github:raspberrypi/linux/rpi-6.6.y"; diff --git a/overlays/default.nix b/overlays/default.nix index 3d5c6d9..325e9b2 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,4 +1,5 @@ { u-boot-src +, rpi-linux-stable-src , rpi-linux-6_6_67-src , rpi-linux-6_10_12-src , rpi-firmware-src @@ -9,6 +10,7 @@ final: prev: let versions = { + v6_6_51.src = rpi-linux-stable-src; v6_6_67.src = rpi-linux-6_6_67-src; v6_10_12 = { src = rpi-linux-6_10_12-src; From 340fc9e3806bd789418a815f2181d7d6be9045d7 Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Wed, 8 Jan 2025 11:55:38 -0500 Subject: [PATCH 13/20] default to stable kernel --- rpi/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpi/default.nix b/rpi/default.nix index b6be690..dc207eb 100644 --- a/rpi/default.nix +++ b/rpi/default.nix @@ -14,7 +14,7 @@ in options = with lib; { raspberry-pi-nix = { kernel-version = mkOption { - default = "v6_6_67"; + default = "v6_6_51"; type = types.str; description = "Kernel version to build."; }; From 85faa0f775e3590ff4223c80786862c6f26018c5 Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Wed, 8 Jan 2025 11:59:48 -0500 Subject: [PATCH 14/20] matching firmware --- flake.lock | 8 ++++---- flake.nix | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 4f68be4..5ef88a3 100644 --- a/flake.lock +++ b/flake.lock @@ -102,16 +102,16 @@ "rpi-firmware-src": { "flake": false, "locked": { - "lastModified": 1727798811, - "narHash": "sha256-eavbshXGYmkYR33y9FLcQMJoAYdYTESVEy0g/RRXnb0=", + "lastModified": 1728405098, + "narHash": "sha256-4gnK0KbqFnjBmWia9Jt2gveVWftmHrprpwBqYVqE/k0=", "owner": "raspberrypi", "repo": "firmware", - "rev": "287e6a6c2d3b50eee3e2c5b2eacdd907e5cbe09a", + "rev": "7bbb5f80d20a2335066a8781459c9f33e5eebc64", "type": "github" }, "original": { "owner": "raspberrypi", - "ref": "1.20241001", + "ref": "1.20241008", "repo": "firmware", "type": "github" } diff --git a/flake.nix b/flake.nix index 390d550..c13eab2 100644 --- a/flake.nix +++ b/flake.nix @@ -21,7 +21,7 @@ }; rpi-firmware-src = { flake = false; - url = "github:raspberrypi/firmware/1.20241001"; + url = "github:raspberrypi/firmware/1.20241008"; }; rpi-firmware-nonfree-src = { flake = false; From e94b747760d09619786a64b84fad30fd6839dd4f Mon Sep 17 00:00:00 2001 From: Jamie Magee Date: Thu, 26 Dec 2024 11:23:52 -0800 Subject: [PATCH 15/20] Drop kernel 6.10.12 in favour of 6.12.11 --- flake.lock | 12 ++++++------ flake.nix | 4 ++-- overlays/default.nix | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/flake.lock b/flake.lock index 5ef88a3..71d9a0d 100644 --- a/flake.lock +++ b/flake.lock @@ -58,7 +58,7 @@ "rpi-bluez-firmware-src": "rpi-bluez-firmware-src", "rpi-firmware-nonfree-src": "rpi-firmware-nonfree-src", "rpi-firmware-src": "rpi-firmware-src", - "rpi-linux-6_10_12-src": "rpi-linux-6_10_12-src", + "rpi-linux-6_12_11-src": "rpi-linux-6_12_11-src", "rpi-linux-6_6_67-src": "rpi-linux-6_6_67-src", "rpi-linux-stable-src": "rpi-linux-stable-src", "rpicam-apps-src": "rpicam-apps-src", @@ -116,19 +116,19 @@ "type": "github" } }, - "rpi-linux-6_10_12-src": { + "rpi-linux-6_12_11-src": { "flake": false, "locked": { - "lastModified": 1728305462, - "narHash": "sha256-LtvNmGD1D5YYv+C9xxxddAeHw69o3OX/H9M7F663L74=", + "lastModified": 1738149451, + "narHash": "sha256-NGmZcaC2vlewTEV/p0z2+6PWnHB229dkGui45kI8HOE=", "owner": "raspberrypi", "repo": "linux", - "rev": "26ee50d56618c2d98100b1bc672fd201aed4d00f", + "rev": "fab655ee33e6d647da5996c5548cfd7d43447a53", "type": "github" }, "original": { "owner": "raspberrypi", - "ref": "rpi-6.10.y", + "ref": "rpi-6.12.y", "repo": "linux", "type": "github" } diff --git a/flake.nix b/flake.nix index c13eab2..1668198 100644 --- a/flake.nix +++ b/flake.nix @@ -15,9 +15,9 @@ flake = false; url = "github:raspberrypi/linux/rpi-6.6.y"; }; - rpi-linux-6_10_12-src = { + rpi-linux-6_12_11-src = { flake = false; - url = "github:raspberrypi/linux/rpi-6.10.y"; + url = "github:raspberrypi/linux/rpi-6.12.y"; }; rpi-firmware-src = { flake = false; diff --git a/overlays/default.nix b/overlays/default.nix index 325e9b2..1ad69a6 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,7 +1,7 @@ { u-boot-src , rpi-linux-stable-src , rpi-linux-6_6_67-src -, rpi-linux-6_10_12-src +, rpi-linux-6_12_11-src , rpi-firmware-src , rpi-firmware-nonfree-src , rpi-bluez-firmware-src @@ -12,8 +12,8 @@ let versions = { v6_6_51.src = rpi-linux-stable-src; v6_6_67.src = rpi-linux-6_6_67-src; - v6_10_12 = { - src = rpi-linux-6_10_12-src; + v6_12_11 = { + src = rpi-linux-6_12_11-src; patches = [ { name = "remove-readme-target.patch"; From 25118248489e047a7da43a21409b457aa2af315e Mon Sep 17 00:00:00 2001 From: Jamie Magee Date: Wed, 29 Jan 2025 20:39:50 -0800 Subject: [PATCH 16/20] Ignore kernel configuration errors Fixes #113 See https://github.com/NixOS/nixpkgs/pull/366004 --- overlays/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/overlays/default.nix b/overlays/default.nix index 325e9b2..ffbe76c 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -63,6 +63,7 @@ let features.efiBootStub = false; kernelPatches = if kernel ? "patches" then kernel.patches else [ ]; + ignoreConfigErrors = true; }).overrideAttrs (oldAttrs: { postConfigure = '' From 36d2ee3511581cbcb58bb09a820195c6da72408b Mon Sep 17 00:00:00 2001 From: Jamie Magee Date: Tue, 4 Feb 2025 09:23:49 -0800 Subject: [PATCH 17/20] Automatically update `flake.lock` using GitHub Actions --- .github/workflows/update-flake-lock.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/update-flake-lock.yml diff --git a/.github/workflows/update-flake-lock.yml b/.github/workflows/update-flake-lock.yml new file mode 100644 index 0000000..ec1a8cd --- /dev/null +++ b/.github/workflows/update-flake-lock.yml @@ -0,0 +1,23 @@ +name: update-flake-lock + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * 0' + +permissions: + contents: write + pull-requests: write + +jobs: + lockfile: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + + - name: Install nix + uses: DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d # v16 + + - name: Update flake.lock + uses: DeterminateSystems/update-flake-lock@a2bbe0274e3a0c4194390a1e445f734c597ebc37 # v24 From 824ce252585a8fbf8b50023da67c8405d5f4ff85 Mon Sep 17 00:00:00 2001 From: Jeroen Leeuwestein Date: Sat, 8 Feb 2025 19:58:46 +0100 Subject: [PATCH 18/20] Make inclusion of console=serial0 in kernelParams (cmdline.txt) configurable --- rpi/default.nix | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/rpi/default.nix b/rpi/default.nix index dc207eb..ff0a62b 100644 --- a/rpi/default.nix +++ b/rpi/default.nix @@ -77,6 +77,18 @@ in package = mkPackageOption pkgs "uboot-rpi-arm64" { }; }; + serial-console = { + enable = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable a console on serial0. + + Corresponds with raspi-config's setting + "Would you like a login shell to be accessible over serial?" + ''; + }; + }; }; }; @@ -319,11 +331,14 @@ in boot = { kernelParams = if cfg.uboot.enable then [ ] - else [ - "console=tty1" - # https://github.com/raspberrypi/firmware/issues/1539#issuecomment-784498108 - "console=serial0,115200n8" - "init=/sbin/init" + else builtins.concatLists [ + [ "console=tty1" ] + (if cfg.serial-console.enable then [ + # https://github.com/raspberrypi/firmware/issues/1539#issuecomment-784498108 + "console=serial0,115200n8" + ] else [ ] + ) + [ "init=/sbin/init" ] ]; initrd = { availableKernelModules = [ From b54486ef66721f3e6c8fad98c83b8e7f61e2aad4 Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Mon, 17 Feb 2025 14:11:59 -0500 Subject: [PATCH 19/20] use nixpkgs upstream uboot It's more up to date and it successfully cross compiles --- flake.lock | 16 +--------------- flake.nix | 4 ---- overlays/default.nix | 9 ++------- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/flake.lock b/flake.lock index 71d9a0d..999dfd1 100644 --- a/flake.lock +++ b/flake.lock @@ -61,8 +61,7 @@ "rpi-linux-6_12_11-src": "rpi-linux-6_12_11-src", "rpi-linux-6_6_67-src": "rpi-linux-6_6_67-src", "rpi-linux-stable-src": "rpi-linux-stable-src", - "rpicam-apps-src": "rpicam-apps-src", - "u-boot-src": "u-boot-src" + "rpicam-apps-src": "rpicam-apps-src" } }, "rpi-bluez-firmware-src": { @@ -183,19 +182,6 @@ "repo": "rpicam-apps", "type": "github" } - }, - "u-boot-src": { - "flake": false, - "locked": { - "lastModified": 1719857238, - "narHash": "sha256-mJ2TBy0Y5ZtcGFgtU5RKr0UDUp5FWzojbFb+o/ebRJU=", - "type": "tarball", - "url": "https://ftp.denx.de/pub/u-boot/u-boot-2024.07.tar.bz2" - }, - "original": { - "type": "tarball", - "url": "https://ftp.denx.de/pub/u-boot/u-boot-2024.07.tar.bz2" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 1668198..8ede62a 100644 --- a/flake.nix +++ b/flake.nix @@ -3,10 +3,6 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; - u-boot-src = { - flake = false; - url = "https://ftp.denx.de/pub/u-boot/u-boot-2024.07.tar.bz2"; - }; rpi-linux-stable-src = { flake = false; url = "github:raspberrypi/linux/stable_20241008"; diff --git a/overlays/default.nix b/overlays/default.nix index 1ad69a6..83ef91f 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,5 +1,4 @@ -{ u-boot-src -, rpi-linux-stable-src +{ rpi-linux-stable-src , rpi-linux-6_6_67-src , rpi-linux-6_12_11-src , rpi-firmware-src @@ -83,14 +82,10 @@ in compressFirmwareZstd = x: x; # provide generic rpi arm64 u-boot - uboot-rpi-arm64 = final.buildUBoot rec { + uboot-rpi-arm64 = final.buildUBoot { defconfig = "rpi_arm64_defconfig"; extraMeta.platforms = [ "aarch64-linux" ]; filesToInstall = [ "u-boot.bin" ]; - version = "2024.04"; - patches = [ ]; - makeFlags = [ ]; - 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 From abd2352d0405bdae6c43d022e4c65085311d5d7d Mon Sep 17 00:00:00 2001 From: Jamie Magee Date: Sat, 1 Mar 2025 20:48:28 -0800 Subject: [PATCH 20/20] bump 6.6.y and 6.12.y kernel versions `rpi-6.6.y` went from `6.6.67` to `6.6.74`. `rpi-6.12.y` went from `6.12.11` to `6.12.17` --- flake.lock | 20 ++++++++++---------- flake.nix | 4 ++-- overlays/default.nix | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/flake.lock b/flake.lock index 999dfd1..81f91aa 100644 --- a/flake.lock +++ b/flake.lock @@ -58,8 +58,8 @@ "rpi-bluez-firmware-src": "rpi-bluez-firmware-src", "rpi-firmware-nonfree-src": "rpi-firmware-nonfree-src", "rpi-firmware-src": "rpi-firmware-src", - "rpi-linux-6_12_11-src": "rpi-linux-6_12_11-src", - "rpi-linux-6_6_67-src": "rpi-linux-6_6_67-src", + "rpi-linux-6_12_17-src": "rpi-linux-6_12_17-src", + "rpi-linux-6_6_78-src": "rpi-linux-6_6_78-src", "rpi-linux-stable-src": "rpi-linux-stable-src", "rpicam-apps-src": "rpicam-apps-src" } @@ -115,14 +115,14 @@ "type": "github" } }, - "rpi-linux-6_12_11-src": { + "rpi-linux-6_12_17-src": { "flake": false, "locked": { - "lastModified": 1738149451, - "narHash": "sha256-NGmZcaC2vlewTEV/p0z2+6PWnHB229dkGui45kI8HOE=", + "lastModified": 1740765145, + "narHash": "sha256-hoCsGc4+RC/2LmxDtswLBL5ZhWlw4vSiL4Vkl39r2MU=", "owner": "raspberrypi", "repo": "linux", - "rev": "fab655ee33e6d647da5996c5548cfd7d43447a53", + "rev": "5985ce32e511f4e8279a841a1b06a8c7d972b386", "type": "github" }, "original": { @@ -132,14 +132,14 @@ "type": "github" } }, - "rpi-linux-6_6_67-src": { + "rpi-linux-6_6_78-src": { "flake": false, "locked": { - "lastModified": 1734790986, - "narHash": "sha256-q9swM2TmmuzbUuQnbLZk5PseKWD7/SNPwtth6bpGIqE=", + "lastModified": 1740503700, + "narHash": "sha256-Y8+ot4Yi3UKwlZK3ap15rZZ16VZDvmeFkD46+6Ku7bE=", "owner": "raspberrypi", "repo": "linux", - "rev": "811ff707533bcd67cdcd368bbd46223082009b12", + "rev": "2e071057fded90e789c0101498e45a1778be93fe", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 8ede62a..fe3fc24 100644 --- a/flake.nix +++ b/flake.nix @@ -7,11 +7,11 @@ flake = false; url = "github:raspberrypi/linux/stable_20241008"; }; - rpi-linux-6_6_67-src = { + rpi-linux-6_6_78-src = { flake = false; url = "github:raspberrypi/linux/rpi-6.6.y"; }; - rpi-linux-6_12_11-src = { + rpi-linux-6_12_17-src = { flake = false; url = "github:raspberrypi/linux/rpi-6.12.y"; }; diff --git a/overlays/default.nix b/overlays/default.nix index f5e1367..b859342 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,6 +1,6 @@ { rpi-linux-stable-src -, rpi-linux-6_6_67-src -, rpi-linux-6_12_11-src +, rpi-linux-6_6_78-src +, rpi-linux-6_12_17-src , rpi-firmware-src , rpi-firmware-nonfree-src , rpi-bluez-firmware-src @@ -10,9 +10,9 @@ final: prev: let versions = { v6_6_51.src = rpi-linux-stable-src; - v6_6_67.src = rpi-linux-6_6_67-src; - v6_12_11 = { - src = rpi-linux-6_12_11-src; + v6_6_78.src = rpi-linux-6_6_78-src; + v6_12_17 = { + src = rpi-linux-6_12_17-src; patches = [ { name = "remove-readme-target.patch"; @@ -114,7 +114,7 @@ in # rpi kernels and firmware are available at # `pkgs.rpi-kernels..'. # - # For example: `pkgs.rpi-kernels.v6_6_67.bcm2712' + # For example: `pkgs.rpi-kernels.v6_6_78.bcm2712' rpi-kernels = rpi-kernels ( final.lib.cartesianProduct { board = boards; version = (builtins.attrNames versions); }