Merge branch 'master' into acer-predator-helios-300-g3-571

This commit is contained in:
Noah Trinite authored and GitHub committed 2026-11-30 13:46:41 -05:00
commit b63feee9c9
21 files changed
+424 -220

No files matched your search

+1
View File
@@ -94,6 +94,7 @@ See code for all available configurations.
| Model | Path | Flake Module |
| --------------------------------------------------------------------------------- | ------------------------------------------------------- | -------------------------------------- |
| [Acer Aspire 4810T](acer/aspire/4810t) | `<nixos-hardware/acer/aspire/4810t>` | `acer-aspire-4810t` |
| [Acer Nitro 5 (AN515-55)](acer/nitro/5/an515-55) | `<nixos-hardware/acer/nitro/5/an515-55>` | `acer-nitro-5-an515-55` |
| [Acer Predator Helios 300 (PH315-51)](acer/predator/helios/300/ph315-51/) | `<nixos-hardware/acer/predator/helios/300/ph315-51/>` | `acer-predator-helios-300-ph315-51` |
| [Acer Predator Helios 300 (G3-571)](acer/predator/helios/300/g3-571/) | `<nixos-hardware/acer/predator/helios/300/g3-571/>` | `acer-predator-helios-300-g3-571` |
| [Airis N990](airis/n990) | `<nixos-hardware/airis/n990>` | `airis-n990` |
+22
View File
@@ -0,0 +1,22 @@
# Acer Nitro 5 (AN515-55)
## Hardware Configuration
- Intel Core i5-10500H
- Intel UHD Graphics + NVIDIA GeForce GTX 1650 Mobile (Turing, TU117M)
- M.2 NVMe SSD
## Notes
- PRIME offload works via `nvidia-offload <cmd>` (enabled by default
via `common/gpu/nvidia/prime.nix`). GPU runtime D3 is not supported
on this chassis — the discrete GPU stays powered on at all times,
even when idle.
- NVIDIA open kernel modules work on this Turing GPU (enabled by
default via `common/gpu/nvidia/turing`), tested with the 595 series.
- `acer_wmi` loads and registers the `platform_profile` driver, but
no sysfs interface is exposed (`/sys/firmware/acpi/platform_profile`
does not exist). Fan/performance modes are only reachable through
Acer's proprietary WMI methods (NitroSense on Windows).
- Keyboard backlight is not exposed via the standard LED class
(`/sys/class/leds`) — `brightnessctl` only controls panel brightness.
+21
View File
@@ -0,0 +1,21 @@
{ lib, ... }:
{
imports = [
../../../../common/cpu/intel
../../../../common/gpu/nvidia/prime.nix
../../../../common/gpu/nvidia/turing
../../../../common/pc/laptop
../../../../common/pc/ssd
];
hardware.nvidia = {
modesetting.enable = lib.mkDefault true;
powerManagement.enable = lib.mkDefault true;
prime = {
intelBusId = "PCI:0@0:2:0";
nvidiaBusId = "PCI:1@0:0:0";
};
};
}
+45 -34
View File
@@ -8,34 +8,47 @@
let
inherit (lib) types;
audioFiles = pkgs.fetchFromGitHub {
owner = "kekrby";
repo = "t2-better-audio";
rev = "e46839a28963e2f7d364020518b9dac98236bcae";
hash = "sha256-x7K0qa++P1e1vuCGxnsFxL1d9+nwMtZUJ6Kd9e27TFs=";
t2bce-alsa-ucm = pkgs.stdenvNoCC.mkDerivation (_: {
name = "t2bce-alsa-ucm";
src = pkgs.fetchFromGitHub {
owner = "deqrocks";
repo = "t2bce";
rev = "967465dc67d3a9b1e48dea620f7258baa526f4f2";
hash = "sha256-EVUvNg30bFhJCtcyPAGbWjGX0+CORs4nWG5Bpvbr590=";
};
meta = {
description = "ALSA Usage Configuration Manager configuration for T2 Macs";
license = lib.licenses.mit;
};
dontBuild = true;
installPhase = ''
runHook preInstall
cd ./t2bce_audio-alsa-ucm-conf
mkdir -p "$out/share/alsa/"
cp -vR ./ucm2 "$out/share/alsa/"
runHook postInstall
'';
});
patched-alsa-ucm = pkgs.symlinkJoin {
inherit (t2bce-alsa-ucm) src meta;
name = "t2bce-alsa-ucm-patched";
paths = [
pkgs.alsa-ucm-conf
t2bce-alsa-ucm
];
};
audioFilesUdevRules = pkgs.runCommand "audio-files-udev-rules" { } ''
mkdir -p $out/lib/udev/rules.d
cp ${audioFiles}/files/*.rules $out/lib/udev/rules.d
substituteInPlace $out/lib/udev/rules.d/*.rules --replace "/usr/bin/sed" "${pkgs.gnused}/bin/sed"
'';
overrideAudioFiles =
package: pluginsPath:
package.overrideAttrs (
_new: old: {
preConfigurePhases = old.preConfigurePhases or [ ] ++ [ "postPatchPhase" ];
postPatchPhase = ''
cp -r ${audioFiles}/files/{profile-sets,paths} ${pluginsPath}/alsa/mixer/
'';
}
);
pipewirePackage = overrideAudioFiles pkgs.pipewire "spa/plugins/";
patchedAudioAlsaEnv = lib.genAttrs [ "pipewire" "wireplumber" "pulseaudio" ] (_: {
environment.ALSA_CONFIG_UCM2 = config.environment.variables.ALSA_CONFIG_UCM2;
});
t2Cfg = config.hardware.apple-t2;
in
{
imports = [
@@ -85,9 +98,7 @@ in
if t2Cfg.kernelChannel == "stable" then ./pkgs/linux-t2 else ./pkgs/linux-t2/latest.nix
) { }
);
boot.initrd.kernelModules = [ "apple-bce" ];
services.udev.packages = [ audioFilesUdevRules ];
boot.initrd.kernelModules = [ "t2bce-vhci" ];
# For audio and suspend
boot.kernelParams = [
@@ -96,19 +107,19 @@ in
"pm_async=off"
];
services.pipewire.package = pipewirePackage;
services.pipewire.wireplumber.package = pkgs.wireplumber.override {
pipewire = pipewirePackage;
# audio configuration
# https://github.com/nix-community/nixos-apple-silicon/blob/66d8dd2c27f99bd5420c99938b60695aac1785c4/apple-silicon-support/modules/sound/default.nix#L46
environment.variables.ALSA_CONFIG_UCM2 = "${patched-alsa-ucm}/share/alsa/ucm2";
# setting systemd.globalEnvironment is likely going to have unexpected side effects
systemd = {
services = patchedAudioAlsaEnv;
user.services = patchedAudioAlsaEnv;
};
# Make sure post-resume.service exists
powerManagement.enable = true;
}
{
services.pulseaudio.package = overrideAudioFiles pkgs.pulseaudio "src/modules/";
}
(lib.mkIf t2Cfg.enableIGPU {
# Enable the iGPU by default if present
environment.etc."modprobe.d/apple-gmux.conf".text = ''
+2 -5
View File
@@ -1,6 +1,3 @@
{ callPackage, linux_6_18, ... }@args:
{ callPackage, ... }@args:
callPackage ./generic.nix args {
kernel = linux_6_18;
patchesFile = ./stable.json;
}
callPackage ./generic.nix args ./stable.json
+38 -13
View File
@@ -1,13 +1,13 @@
{
lib,
fetchurl, # fetchpatch does unnecessary normalization
buildLinux,
linuxKernel,
...
}@args:
{
kernel,
patchesFile,
}:
patchesFile:
let
inherit (builtins) readFile fromJSON;
@@ -23,33 +23,58 @@ let
}
) patchset.patches;
in
kernel.override (
args
// {
buildLinux (
{
pname = "linux-t2";
version = patchset.kernel.version;
src = fetchurl {
inherit (patchset.kernel) url hash;
};
structuredExtraConfig = with lib.kernel; {
APPLE_BCE = module;
T2BCE_CORE = module;
T2BCE_VHCI = module;
T2BCE_AUDIO = module;
T2BCE_AVE = module;
APPLE_GMUX = module;
APFS_FS = module;
BRCMFMAC = module;
BT_BCM = module;
BT_HCIBCM4377 = module;
BT_HCIUART_BCM = yes;
BT_HCIUART = module;
BT_HCIUART_BCM = yes;
DRM_APPLETBDRM = module;
HID_APPLE = module;
HID_APPLETB_BL = module;
HID_APPLETB_KBD = module;
HID_APPLE = module;
HID_MAGICMOUSE = module;
DRM_APPLETBDRM = module;
HID_SENSOR_ALS = module;
SENSORS_APPLESMC = module;
SND_PCM = module;
STAGING = yes;
# required for t2bce_ave
I2C = yes;
MEDIA_SUPPORT = yes;
MEDIA_CAMERA_SUPPORT = yes;
MEDIA_ANALOG_TV_SUPPORT = yes;
MEDIA_DIGITAL_TV_SUPPORT = yes;
MEDIA_RADIO_SUPPORT = yes;
MEDIA_SDR_SUPPORT = yes;
MEDIA_PLATFORM_SUPPORT = yes;
MEDIA_TEST_SUPPORT = yes;
};
kernelPatches = t2-patches ++ (args.kernelPatches or [ ]);
kernelPatches = [
# include default patches for good measure
linuxKernel.kernelPatches.request_key_helper
linuxKernel.kernelPatches.bridge_stp_helper
]
++ t2-patches
++ (args.kernelPatches or [ ]);
argsOverride.extraMeta = {
extraMeta = {
description = "The Linux kernel (with patches from the T2 Linux project)";
# take responsibility for the downstream kernel
+41 -16
View File
@@ -1,25 +1,30 @@
{
"base_url": "https://raw.githubusercontent.com/t2linux/linux-t2-patches/7ee7d19c38e5df31a386b2a0c35ca8f064003960/",
"base_url": "https://raw.githubusercontent.com/t2linux/linux-t2-patches/65fdd4d492d7e219a05742ce4768f16e5ba4f976/",
"kernel": {
"version": "7.2.9",
"url": "mirror://kernel/linux/kernel/v7.x/linux-7.2.9.tar.xz",
"hash": "sha256:1fnqp28vrikz9gqhb42k0dsggqf8i07j0s9qy33scr53a6zdzidl"
},
"patches": [
{
"name": "1001-Add-apple-bce-driver.patch",
"hash": "sha256-v/P3Ws3x+OPnmX3vSFLxARON0HNjjDRe7QJ+KP9tVsc="
"name": "1001-Add-t2bce-driver-stack.patch",
"hash": "sha256-QeAffMClzGsGdHC5Qce744X2WUcx6PI0CJ5BQ8txxQ8="
},
{
"name": "1002-Put-apple-bce-in-drivers-staging.patch",
"hash": "sha256-rK1lQ3fjHJH//50n37xgWrUs4CZ8lmFw0iDpbq5zoaY="
"name": "1002-Integrate-t2bce-driver-stack.patch",
"hash": "sha256-nPAPGV9IROyxSQzSztwNS1fY0ziGQJ7evKBs1ZSHwiE="
},
{
"name": "2008-i915-4-lane-quirk-for-mbp15-1.patch",
"hash": "sha256-S2osR1aSjqJiO7rNZP1sKt2+Uxyitwse/6BXMJvE9as="
"hash": "sha256-gTYP7WHV/Qulobdi1nNdYsv1CWgkM8pGvsCFQ+rvhrw="
},
{
"name": "2009-apple-gmux-allow-switching-to-igpu-at-probe.patch",
"hash": "sha256-6i+fh/Ifle0di5/tMOdMm0NMkEmeUb17hYM/g2j2dfI="
"hash": "sha256-OczfcYSvkw2lBZQzZjCV4LHSe6CnaJ1J8GBkgEbiOXk="
},
{
"name": "3001-applesmc-convert-static-structures-to-drvdata.patch",
"hash": "sha256-7KGC0pCos351wKNhwJI/Qoc7w+orOPpiTkdCN50G8nI="
"hash": "sha256-FVtOCXInI5OUqpTVDVsZ1taMwj3z+d3PeRgjnQQljG4="
},
{
"name": "3002-applesmc-make-io-port-base-addr-dynamic.patch",
@@ -55,35 +60,55 @@
},
{
"name": "4001-asahi-trackpad.patch",
"hash": "sha256-ANHSNoy5nK2b+rSAG0bJ8j6ZBmNqgeCddHXVS31KyDw="
"hash": "sha256-RuYI0t+rMu29wSkVT4suYJgGzS1ZruN/HBZWkLivlDw="
},
{
"name": "4003-HID-apple-ignore-the-trackpad-on-T2-Macs.patch",
"hash": "sha256-T2tYcFLeWUdx6QawANe3ZNVSRxmo1IdPiSpGLQk4IDY="
"hash": "sha256-LLZzcysLTuQrSXWXbdq7AASxfMInQoqpWzRNZAKws9k="
},
{
"name": "4004-HID-magicmouse-Add-support-for-trackpads-found-on-T2.patch",
"hash": "sha256-ubchCEv1BZ7t/zkI9DpHA4gUln9cdu4yHzVJI2TNlS0="
},
{
"name": "4005-HID-magicmouse-fix-regression-breaking-support-for-M.patch",
"hash": "sha256-oT+3AeETnKfzblxtcTD18c61BKoD9yAsga0AL3R8u7k="
"hash": "sha256-kUnbtl/54cihscirl9kP0Gsot7bdP0rYKlj6gQ10hk0="
},
{
"name": "5001-HID-appletb-kbd-add-option-to-switch-default-layer-o.patch",
"hash": "sha256-KV5DTjALzNugs92Jum6VUt0wgblK/6PG1KorovHcIX0="
},
{
"name": "5002-drm-appletbdrm-Add-suspend-and-resume-support.patch",
"hash": "sha256-NFa5ZpNguUC9ELfphvCrVHEh59tN/ZA9vQl6YD1avbI="
},
{
"name": "6001-drm-amd-pm-Fix-boot-problems-in-5300.patch",
"hash": "sha256-l6pyVkpumURgoQ/f1kGfw47YhMuuMjpiHgjP6QN8dNE="
},
{
"name": "7001-drm-i915-fbdev-Discard-BIOS-framebuffers-exceeding-h.patch",
"hash": "sha256-/EKN7JsAxcpAgfJFtPp2NLYaGqQ0kl8wjJEXifSzJpY="
},
{
"name": "7002-drm-amdgpu-reset-VI-ASIC-on-MacBookPro15-1.patch",
"hash": "sha256-lLruG4lJAI6fI94w2LzHmrbspXArrq+rbI/SJmhwXqo="
},
{
"name": "7003-amdgpu-add-support-for-5K.patch",
"hash": "sha256-RX3tiju4gNFlrrYWOMdUr0HAdSN5RliliiPAQw5I6/M="
},
{
"name": "8001-Add-APFS-driver.patch",
"hash": "sha256-EbIbfkncp5Jax2suny/jlFt+cD9MyYMV2rWFJIbgbg4="
"hash": "sha256-DU/jX8wuM6Y/5iZztg05GjWlzVlo8DfVpCJ3BxFoTJo="
},
{
"name": "8002-Necessary-modifications-to-build-APFS-with-the-kerne.patch",
"hash": "sha256-zCTetF2NPhMH2BknPumhPz2sf26X9Lcra7xCA3R2WMY="
},
{
"name": "9001-ACPI-x86-Apple-T2-systems-need-early-CPU-offlining.patch",
"hash": "sha256-camFPvnBQMErjVrbsdPPfsbyy59w0e0iPkVR1Juzv8o="
},
{
"name": "9002-Bluetooth-hci_event-strip-Broadcom-vendor-bits-from-adv-type.patch",
"hash": "sha256-oikMBjD4gyqTs351q7nTz6lI6rJqOe1/LfxpHAieEOs="
}
]
}
+2 -5
View File
@@ -1,6 +1,3 @@
{ callPackage, linux_7_0, ... }@args:
{ callPackage, ... }@args:
callPackage ./generic.nix args {
kernel = linux_7_0;
patchesFile = ./latest.json;
}
callPackage ./generic.nix args ./latest.json
+28 -15
View File
@@ -1,17 +1,26 @@
{
"base_url": "https://raw.githubusercontent.com/t2linux/linux-t2-patches/facf1c778667c3ef62104949ef64c75ce7e43b0a/",
"base_url": "https://raw.githubusercontent.com/t2linux/linux-t2-patches/2eed0f6c812e8f36cb7a7f7bcde69f6f87074bdf/",
"kernel": {
"version": "6.18.55",
"url": "mirror://kernel/linux/kernel/v6.x/linux-6.18.55.tar.xz",
"hash": "sha256:1yadaa2gz74nh3pawpwv6lamalnd7wpiv1xb88pw2rd1c606647l"
},
"patches": [
{
"name": "1001-Add-apple-bce-driver.patch",
"hash": "sha256-rrL3oVkYeq5ZslnjCQw4hcEK6knsm6U/wp1XnJmQTSA="
"name": "1001-Add-t2bce-driver-stack.patch",
"hash": "sha256-OG4Y7cN75pHWF7huV+2Fqtq0ik2aITMWtF43mD+RFCU="
},
{
"name": "1002-Put-apple-bce-in-drivers-staging.patch",
"hash": "sha256-deWROYcncl51sOmtvUHM61e5FM1beHbOJVp4iI31LHM="
"name": "1002-Integrate-t2bce-driver-stack.patch",
"hash": "sha256-z3g3IOAL+Nze88oKDSYpLHVtFnhz2kP1Udap5J64WmM="
},
{
"name": "1003-Fix-for-6.18.patch",
"hash": "sha256-ozJkJFm11oGDW1Gwrp4AR4Ifv9X8Yix6uF9ZBFJ76+M="
},
{
"name": "2008-i915-4-lane-quirk-for-mbp15-1.patch",
"hash": "sha256-S2osR1aSjqJiO7rNZP1sKt2+Uxyitwse/6BXMJvE9as="
"hash": "sha256-gTYP7WHV/Qulobdi1nNdYsv1CWgkM8pGvsCFQ+rvhrw="
},
{
"name": "2009-apple-gmux-allow-switching-to-igpu-at-probe.patch",
@@ -19,7 +28,7 @@
},
{
"name": "3001-applesmc-convert-static-structures-to-drvdata.patch",
"hash": "sha256-7KGC0pCos351wKNhwJI/Qoc7w+orOPpiTkdCN50G8nI="
"hash": "sha256-c/d+c5eKzhbtfUKtLC7AB+6vMXge4ZzPJAUbNENWH7g="
},
{
"name": "3002-applesmc-make-io-port-base-addr-dynamic.patch",
@@ -55,31 +64,35 @@
},
{
"name": "4001-asahi-trackpad.patch",
"hash": "sha256-+YXyIjtlVrLo8allTO3M1A+xold5FUXaZ8dwD2j5HDc="
"hash": "sha256-2h3TdPsX9HBXx5jkZ2S2GJkjFcdL8vKD1G69iqd9IWg="
},
{
"name": "4003-HID-apple-ignore-the-trackpad-on-T2-Macs.patch",
"hash": "sha256-T2tYcFLeWUdx6QawANe3ZNVSRxmo1IdPiSpGLQk4IDY="
"hash": "sha256-LLZzcysLTuQrSXWXbdq7AASxfMInQoqpWzRNZAKws9k="
},
{
"name": "4004-HID-magicmouse-Add-support-for-trackpads-found-on-T2.patch",
"hash": "sha256-ubchCEv1BZ7t/zkI9DpHA4gUln9cdu4yHzVJI2TNlS0="
},
{
"name": "4005-HID-magicmouse-fix-regression-breaking-support-for-M.patch",
"hash": "sha256-oT+3AeETnKfzblxtcTD18c61BKoD9yAsga0AL3R8u7k="
"hash": "sha256-kUnbtl/54cihscirl9kP0Gsot7bdP0rYKlj6gQ10hk0="
},
{
"name": "5001-HID-appletb-kbd-add-option-to-switch-default-layer-o.patch",
"hash": "sha256-KV5DTjALzNugs92Jum6VUt0wgblK/6PG1KorovHcIX0="
},
{
"name": "5002-drm-appletbdrm-Add-suspend-and-resume-support.patch",
"hash": "sha256-NFa5ZpNguUC9ELfphvCrVHEh59tN/ZA9vQl6YD1avbI="
},
{
"name": "7001-drm-i915-fbdev-Discard-BIOS-framebuffers-exceeding-h.patch",
"hash": "sha256-/EKN7JsAxcpAgfJFtPp2NLYaGqQ0kl8wjJEXifSzJpY="
},
{
"name": "7002-drm-amdgpu-reset-VI-ASIC-on-MacBookPro15-1.patch",
"hash": "sha256-lLruG4lJAI6fI94w2LzHmrbspXArrq+rbI/SJmhwXqo="
},
{
"name": "8001-Add-APFS-driver.patch",
"hash": "sha256-2By3Zlg/i5rUUJDlWc6JoiqapUnbVplk2lHzDhvAhzI="
"hash": "sha256-fL9TftzTd5PurxIDrzaPsysGExrMySGOsm6H8NFd7JY="
},
{
"name": "8002-Necessary-modifications-to-build-APFS-with-the-kerne.patch",
+33 -7
View File
@@ -15,21 +15,26 @@ API_BASE = "https://api.github.com"
PATCH_PATTERN = re.compile(r"^\d{4}-.*\.patch$")
parser = argparse.ArgumentParser(
description="Update linux-t2 patches from a GitHub repository."
description="Update linux-t2 patches from a GitHub repository.",
epilog='''
If both --branch and --reference flags are given, the argument of --reference will be used to fetch the Git
revision for patches and --branch as the kernel branch.
If only --branch is given, the argument will be used for both resolving the Git ref and the kernel branch.
''',
)
parser.add_argument("filename", help="the output filename")
parser.add_argument(
"--repository",
help="the source github repository",
help="the source github repository (default: %(default)s)",
default="t2linux/linux-t2-patches",
nargs="?",
)
ref_group = parser.add_mutually_exclusive_group()
ref_group.add_argument(
parser.add_argument(
"--reference", help="the git reference for the patches", default=None, nargs="?"
)
ref_group.add_argument(
"--branch", help="the git branch to fetch", default=None, nargs="?"
parser.add_argument(
"--branch", help="the kernel branch to fetch (default: latest, example: 6.18)", default=None, nargs="?"
)
@@ -62,6 +67,27 @@ def main():
reference = args.reference
branch = args.branch
print("Fetching kernel releases")
releases = requests.get("https://kernel.org/releases.json").json()['releases']
match = None
patched_url = ""
if not branch:
print("Branch not provided, fetching latest non-mainline kernel version")
# if the json schema changes this script would break, hopefully won't happen
match = next(filter(lambda x: x["moniker"] != "mainline", releases), None)
else:
match = next(filter(lambda x: x["version"].startswith(branch), releases), None)
if not match:
print(f"ERROR: could not find a kernel release for branch {branch}.")
return 1
patched_url = match['source'].replace('https://cdn.kernel.org/pub', 'mirror://kernel')
release_hash = subprocess.check_output(["nix-prefetch-url", "--type", "sha256", patched_url]).decode().strip()
print(f" Kernel: {match['version']}")
print(f" URL: {patched_url}")
print(f" Hash: sha256:{release_hash}")
kernel = {"version": match["version"], "url": patched_url, "hash": f"sha256:{release_hash}"}
if reference is None:
if branch is None:
print("Branch and reference not provided, fetching default branch")
@@ -85,7 +111,7 @@ def main():
for future in as_completed(futures):
patches_with_hash.append(future.result())
result = {"base_url": base_url, "patches": sorted(patches_with_hash, key=lambda p: p["name"])}
result = {"base_url": base_url, "kernel": kernel, "patches": sorted(patches_with_hash, key=lambda p: p["name"])}
with open(args.filename, "w+") as f:
json.dump(result, f, indent=2)
+1
View File
@@ -43,6 +43,7 @@
in
{
acer-aspire-4810t = import ./acer/aspire/4810t;
acer-nitro-5-an515-55 = import ./acer/nitro/5/an515-55;
acer-predator-helios-300-ph315-51 = import ./acer/predator/helios/300/ph315-51;
acer-predator-helios-300-g3-571 = import ./acer/predator/helios/300/g3-571;
airis-n990 = import ./airis/n990;
+9 -48
View File
@@ -1,50 +1,11 @@
{ lib, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.hardware.raspberry-pi."4".audio;
in
{
options.hardware = {
raspberry-pi."4".audio = {
enable = lib.mkEnableOption "configuration for audio";
};
};
config = lib.mkIf cfg.enable {
hardware.deviceTree = {
overlays = [
# Equivalent to dtparam=audio=on
{
name = "audio-on-overlay";
dtsText = ''
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2711";
fragment@0 {
target = <&audio>;
__overlay__ {
status = "okay";
};
};
};
'';
}
];
};
# set tsched=0 in pulseaudio config to avoid audio glitches
# see https://wiki.archlinux.org/title/PulseAudio/Troubleshooting#Glitches,_skips_or_crackling
hardware.pulseaudio.configFile = lib.mkOverride 990 (
pkgs.runCommand "default.pa" { } ''
sed 's/module-udev-detect$/module-udev-detect tsched=0/' ${config.hardware.pulseaudio.package}/etc/pulse/default.pa > $out
''
);
};
imports = [
../common
(lib.mkRenamedOptionModule
[ "hardware" "raspberry-pi" "4" "audio" "enable" ]
[ "hardware" "raspberry-pi" "audio" "enable" ]
)
];
}
+85 -52
View File
@@ -5,7 +5,9 @@ NixOS profiles and modules for Raspberry Pi boards.
## What's here
- `common/` has the shared bits: the `linux-rpi` kernel build (vendor defconfig, matching firmware), the `config.txt` generation module, a pinned wireless firmware, and the firmware-partition install module.
- `1/`, `2/`, `3/`, `4/`, `5/` are the board profiles. They select vendor kernels and configure board-specific boot and hardware settings. Pi 4 and 5 also set DT filters and the initrd modules they need.
- `1/`, `2/`, `3/`, `4/`, `5/` are the board profiles.
They select vendor kernels and configure board-specific boot and hardware settings.
Pi 4 and 5 also set DT filters and the initrd modules they need.
- The extra files under `4/` are opt-in toggles for Pi 4 hardware: audio, GPIO, I2C, LEDs, touchscreens, and so on.
- Where provided, `sd-image.nix` and `sd-image-installer.nix` combine a board profile with nixpkgs' SD-image builder, optionally adding the NixOS installation environment.
@@ -19,17 +21,24 @@ NixOS profiles and modules for Raspberry Pi boards.
}
```
These profiles assume the `generic-extlinux-compatible` bootloader (the NixOS module that writes an `extlinux.conf` for U-Boot to read), which is what aarch64 NixOS SD images use by default. There is no `boot.loader.raspberry-pi` module here. U-Boot and the GPU boot code still have to land on the firmware partition somehow: either your image builder does it, or you use the firmware install module below.
These profiles assume the `generic-extlinux-compatible` bootloader (the NixOS module that writes an `extlinux.conf` for U-Boot to read), which is what aarch64 NixOS SD images use by default.
There is no `boot.loader.raspberry-pi` module here.
U-Boot and the GPU boot code still have to land on the firmware partition somehow: either your image builder does it, or you use the firmware install module below.
## Firmware install
`hardware.raspberry-pi.firmware` stages the files the Pi firmware needs before Linux starts onto the firmware partition (default `/boot/firmware`): GPU boot code (`bootcode.bin`, `start*.elf`, `fixup*.dat`), vendor device trees and overlays, the rendered `config.txt`, and optionally U-Boot. It is not a new boot method; it just supplies the files the existing `generic-extlinux-compatible` + U-Boot path needs.
`hardware.raspberry-pi.firmware` stages the files the Pi firmware needs before Linux starts onto the firmware partition (default `/boot/firmware`): GPU boot code (`bootcode.bin`, `start*.elf`, `fixup*.dat`), vendor device trees and overlays, the rendered `config.txt`, and optionally U-Boot.
It is not a new boot method; it just supplies the files the existing `generic-extlinux-compatible` + U-Boot path needs.
When you build an SD image, the module sets `sdImage.populateFirmwareCommands` itself, so the firmware partition is populated at build time with no extra configuration. For cross-compilation, set `nixpkgs.buildPlatform` to the build machine's architecture and `nixpkgs.hostPlatform` to the target board's architecture, unless the profile already selects it.
When you build an SD image, the module sets `sdImage.populateFirmwareCommands` itself, so the firmware partition is populated at build time with no extra configuration.
For cross-compilation, set `nixpkgs.buildPlatform` to the build machine's architecture and `nixpkgs.hostPlatform` to the target board's architecture, unless the profile already selects it.
For a running system, set `hardware.raspberry-pi.firmware.enable = true`. An activation script then repopulates the firmware partition on every `nixos-rebuild switch`. It is off by default.
For a running system, set `hardware.raspberry-pi.firmware.enable = true`.
An activation script then repopulates the firmware partition on every `nixos-rebuild switch`.
It is off by default.
To chainload U-Boot from the firmware, enable `uboot.enable`. It copies `u-boot.bin` to the firmware partition and sets `config.txt`'s `kernel` line for you:
To chainload U-Boot from the firmware, enable `uboot.enable`.
It copies `u-boot.bin` to the firmware partition and sets `config.txt`'s `kernel` line for you:
```nix
{
@@ -40,11 +49,15 @@ To chainload U-Boot from the firmware, enable `uboot.enable`. It copies `u-boot.
}
```
The shared firmware module defaults `uboot.package` to `pkgs.ubootRaspberryPiAarch64`, built from `rpi_arm64_defconfig` for 64-bit Pi 3/4/5 systems. Board profiles can override this default. For 32-bit systems, use the package matching the board: `pkgs.ubootRaspberryPi` for Pi 1, `pkgs.ubootRaspberryPi2` for Pi 2, or `pkgs.ubootRaspberryPi3_32bit` for Pi 3. On the Pi 5 this boots from SD, but U-Boot can't drive USB/PCIe/RP1 yet, so USB boot, NVMe boot, and a USB keyboard at the U-Boot prompt don't work until Linux takes over.
The shared firmware module defaults `uboot.package` to `pkgs.ubootRaspberryPiAarch64`, built from `rpi_arm64_defconfig` for 64-bit Pi 3/4/5 systems.
Board profiles can override this default.
For 32-bit systems, use the package matching the board: `pkgs.ubootRaspberryPi` for Pi 1, `pkgs.ubootRaspberryPi2` for Pi 2, or `pkgs.ubootRaspberryPi3_32bit` for Pi 3.
On the Pi 5 this boots from SD, but U-Boot can't drive USB/PCIe/RP1 yet, so USB boot, NVMe boot, and a USB keyboard at the U-Boot prompt don't work until Linux takes over.
## `config.txt`
Board profiles import `hardware.raspberry-pi.configtxt`, which renders `config.txt` from Nix options. The Pi 2–5 profiles also import `common/config-txt-defaults.nix`, which tracks the Raspberry Pi OS pi-gen image: camera and display autodetect, KMS, audio on, `arm_boost`.
Board profiles import `hardware.raspberry-pi.configtxt`, which renders `config.txt` from Nix options.
The Pi 2–5 profiles also import `common/config-txt-defaults.nix`, which tracks the Raspberry Pi OS pi-gen image: camera and display autodetect, KMS, audio on, `arm_boost`.
```nix
{
@@ -69,28 +82,43 @@ dtparam=audio=on
dtparam=i2c_arm=on
```
Top-level attrs are conditional sections (`all`, `pi4`, `pi5`, `cm4`, and so on). Nesting stacks filters. Set a board profile's `mkDefault` value to `null` to remove it. Use `mkForce null` when overriding a value with normal priority.
Top-level attrs are conditional sections (`all`, `pi4`, `pi5`, `cm4`, and so on).
Nesting stacks filters.
Set a board profile's `mkDefault` value to `null` to remove it.
Use `mkForce null` when overriding a value with normal priority.
Every rendered group opens with `[all]` and then its own filters. Filters of different types stack rather than replace, so `[all]` is what clears the previous group before the next one starts.
Every rendered group opens with `[all]` and then its own filters.
Filters of different types stack rather than replace, so `[all]` is what clears the previous group before the next one starts.
The firmware applies these filters at boot, not Nix at evaluation time. This matters in two cases. One image can boot on more than one board, such as a CM4 and a CM5 swapped into the same carrier. Filters like `[EDID=...]`, `[gpio4=1]`, `[tryboot]` and `[bootvar0=42]` also depend on state that Nix cannot see: the attached monitor, a jumper, an EEPROM value.
The firmware applies these filters at boot, not Nix at evaluation time.
This matters in two cases.
One image can boot on more than one board, such as a CM4 and a CM5 swapped into the same carrier.
Filters like `[EDID=...]`, `[gpio4=1]`, `[tryboot]` and `[bootvar0=42]` also depend on state that Nix cannot see: the attached monitor, a jumper, an EEPROM value.
### Device tree overlays
Overlays go in `configtxt.deviceTreeOverlays`, not in a `dtoverlay` key under `settings`. Filters nest the same way, and the leaf is an ordered list where each element names one overlay and its parameters:
Before switching to the firmware-provided device tree, migrate other `hardware.deviceTree.overlays` to `hardware.raspberry-pi.configtxt`.
Overlays go in `configtxt.deviceTreeOverlays`, not in a `dtoverlay` key under `settings`.
Filters nest the same way, and the leaf is an ordered list where each element names one overlay and its parameters:
```nix
{
boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = false;
hardware.raspberry-pi.configtxt.deviceTreeOverlays.pi4 = [
{ dwc2.dr_mode = "host"; }
{
gpio-fan = {
gpiopin = 14;
gpiopin = 12;
temp = 80000;
};
}
{
gpio-led = {
gpio = 16;
label = "status";
};
}
];
}
```
@@ -100,42 +128,53 @@ This renders after `configtxt.settings` as:
```ini
[all]
[pi4]
dtoverlay=dwc2
dtparam=dr_mode=host
dtoverlay=
dtoverlay=gpio-fan
dtparam=gpiopin=14
dtparam=gpiopin=12
dtparam=temp=80000
dtoverlay=
dtoverlay=gpio-led
dtparam=gpio=16
dtparam=label=status
dtoverlay=
```
A separate option is necessary because `settings` groups values by key. That grouping cannot keep an overlay next to the `dtparam` lines that belong to it. The order is functional. A `dtparam` applies to the overlay that loaded last, and the parameters of an overlay stay in scope only until the next overlay loads. The bare `dtoverlay=` line closes that scope, so later parameters apply to the base device tree. The order between overlays can also matter, because one overlay can build on another.
A separate option is necessary because `settings` groups values by key.
That grouping cannot keep an overlay next to the `dtparam` lines that belong to it.
The order is functional.
A `dtparam` applies to the overlay that loaded last, and the parameters of an overlay stay in scope only until the next overlay loads.
The bare `dtoverlay=` line closes that scope, so later parameters apply to the base device tree.
The order between overlays can also matter, because one overlay can build on another.
Overlays render after `settings`. This order keeps base parameters such as `dtparam=audio=on` out of the scope of an overlay. An overlay can export a parameter with the same name as a base parameter. While that overlay is in scope, the firmware uses the parameter of the overlay.
Overlays render after `settings`.
This order keeps base parameters such as `dtparam=audio=on` out of the scope of an overlay.
An overlay can export a parameter with the same name as a base parameter.
While that overlay is in scope, the firmware uses the parameter of the overlay.
Each parameter becomes its own `dtparam` line rather than an addition to the `dtoverlay` line, which keeps them clear of the 98-character line limit. Booleans render as `on` or `off`. Use `null` with `mkForce` to remove a parameter.
Each parameter becomes its own `dtparam` line rather than an addition to the `dtoverlay` line, which keeps them clear of the 98-character line limit.
Booleans render as `on` or `off`.
Use `null` with `mkForce` to remove a parameter.
The module concatenates lists from separate modules, but the order is not the order of definition. If one overlay must load before another, set the order with `mkBefore` or `mkAfter`.
The module concatenates lists from separate modules, but the order is not the order of definition.
If one overlay must load before another, set the order with `mkBefore` or `mkAfter`.
The Raspberry Pi firmware applies these overlays before U-Boot starts. Set `boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = false` so U-Boot keeps that device tree instead of loading one from the NixOS generation. Enabling `hardware.raspberry-pi.firmware.uboot.enable` sets this automatically.
For overlay names and hardware-specific parameters, use the [Raspberry Pi overlay reference](https://github.com/raspberrypi/linux/blob/rpi-6.18.y/arch/arm/boot/dts/overlays/README).
The firmware partition must contain the generated `config.txt` and stock overlays. SD image builds populate it automatically. On a running system, set `hardware.raspberry-pi.firmware.enable = true`.
The Raspberry Pi firmware applies these overlays before U-Boot starts.
Set `boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = false` so U-Boot keeps that device tree instead of loading one from the NixOS generation.
Enabling `hardware.raspberry-pi.firmware.uboot.enable` sets this automatically.
#### DWC2 USB controller
The firmware partition must contain the generated `config.txt` and stock overlays.
SD image builds populate it automatically.
On a running system, set `hardware.raspberry-pi.firmware.enable = true`.
Use the stock `dwc2` overlay to enable the USB 2.0 controller on the Pi 4B USB-C connector:
To supply your own file, set `configtxt.file`.
The module then ignores `settings` and `deviceTreeOverlays`.
```nix
{
hardware.raspberry-pi.configtxt.deviceTreeOverlays."board-type=0x11" = [
{ dwc2 = { }; }
];
}
```
#### Overriding board defaults
`board-type=0x11` matches the Pi 4B. The broader `pi4` filter also matches Pi 400, CM4, and CM4S.
[Raspberry Pi OS sets `otg_mode=1` on CM4](https://github.com/RPi-Distro/pi-gen/blob/master/stage1/00-boot-files/files/config.txt#L39-L43), and [nixos-hardware sets the same default](./common/config-txt-defaults.nix). Set it to `null` before loading DWC2:
The shared board defaults are defined in [`common/config-txt-defaults.nix`](./common/config-txt-defaults.nix) with `lib.mkDefault`.
Set a `hardware.raspberry-pi.configtxt.settings` value to `null` to omit that default from the generated `config.txt`.
For example, to remove the default `otg_mode` setting before loading `dwc2` on CM4, use:
```nix
{
@@ -148,31 +187,25 @@ Use the stock `dwc2` overlay to enable the USB 2.0 controller on the Pi 4B USB-C
}
```
The `cm4` filter matches CM4 only. Set `dwc2.dr_mode` to `host`, `peripheral`, or `otg` to override the overlay default. The overlay also accepts `g-rx-fifo-size` and `g-np-tx-fifo-size`.
## Audio
#### PoE HATs
The original [PoE HAT](https://www.raspberrypi.com/products/poe-hat/) and the [PoE+ HAT](https://www.raspberrypi.com/products/poe-plus-hat/) use the stock `rpi-poe` and `rpi-poe-plus` overlays. Both HATs support the Pi 3B+ and Pi 4B.
To enable the headphone jack on Raspberry Pi 2, 3, or 4:
```nix
{
hardware.raspberry-pi.configtxt.deviceTreeOverlays."board-type=0x11" = [
{
rpi-poe = {
poe_fan_temp0 = 50000;
poe_fan_temp0_hyst = 2000;
};
}
];
hardware.raspberry-pi.audio.enable = true;
}
```
Use `board-type=0x0d` for the Pi 3B+ and `board-type=0x11` for the Pi 4B. Replace `rpi-poe` with `rpi-poe-plus` for the PoE+ HAT. All overlay parameters are optional.
To supply your own file, set `configtxt.file`. The module then ignores `settings` and `deviceTreeOverlays`.
The audio module loads the [`snd_bcm2835` kernel module](https://github.com/raspberrypi/linux/blob/rpi-6.18.y/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c) to enable headphone audio.
If you use PulseAudio, the module also provides a default configuration to avoid audio glitches.
## Current limits
- No bootloader module: There's no `boot.loader.raspberry-pi` here. Boards rely on `generic-extlinux-compatible` plus U-Boot. Raspberry Pi OS has the GPU firmware load the kernel directly; we go through U-Boot so it reads `extlinux.conf`, which is what gives you the NixOS boot-generation menu and rollbacks. The firmware install module just stages the boot code and (optionally) U-Boot; it doesn't add a firmware-level direct-boot path. Pi 5 boots from SD via U-Boot, but USB, PCIe, and the RP1 don't come up until Linux takes over, so a USB keyboard at the U-Boot prompt won't work on Pi 5 today.
- No bootloader module: There's no `boot.loader.raspberry-pi` here.
Boards rely on `generic-extlinux-compatible` plus U-Boot.
Raspberry Pi OS has the GPU firmware load the kernel directly; we go through U-Boot so it reads `extlinux.conf`, which is what gives you the NixOS boot-generation menu and rollbacks.
The firmware install module just stages the boot code and (optionally) U-Boot; it doesn't add a firmware-level direct-boot path.
Pi 5 boots from SD via U-Boot, but USB, PCIe, and the RP1 don't come up until Linux takes over, so a USB keyboard at the U-Boot prompt won't work on Pi 5 today.
- Single pinned kernel: `common/kernel.nix` pins one `linux-rpi` version rather than matching each kernel to its firmware release.
- No Pi Zero or Zero 2 board profiles.
+71
View File
@@ -0,0 +1,71 @@
{
config,
lib,
options,
pkgs,
...
}:
let
cfg = config.hardware.raspberry-pi.audio;
in
{
options.hardware.raspberry-pi.audio = {
enable = lib.mkEnableOption "onboard audio through snd_bcm2835 on Raspberry Pi 2, 3, and 4";
};
config = lib.mkIf cfg.enable {
assertions = [
{
assertion = config.hardware.deviceTree.overlays == [ ];
message = ''
hardware.raspberry-pi.audio.enable uses the firmware-provided device tree
and cannot be combined with hardware.deviceTree.overlays.
Migrate those overlays to hardware.raspberry-pi.configtxt.deviceTreeOverlays.
See "Device tree overlays" in raspberry-pi/README.md for migration and
firmware installation.
'';
}
{
assertion = !config.boot.loader.generic-extlinux-compatible.useGenerationDeviceTree;
message = ''
hardware.raspberry-pi.audio.enable requires
boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = false
so U-Boot keeps the firmware's audio configuration.
Remove the conflicting override or set it to false.
'';
}
{
assertion = config.hardware.raspberry-pi.firmware.enable || (options ? sdImage);
message = ''
Outside SD-image builds, hardware.raspberry-pi.audio.enable requires
hardware.raspberry-pi.firmware.enable = true to install the firmware configuration.
Enable automatic firmware installation as described in "Firmware install" in raspberry-pi/README.md.
'';
}
];
# Omit FDT/FDTDIR so U-Boot keeps the firmware's audio=on change.
boot.loader.generic-extlinux-compatible.useGenerationDeviceTree = lib.mkDefault false;
# The board profiles use KMS for HDMI audio. Leave firmware-driven HDMI
# kernel parameters to users.
boot.kernelModules = [ "snd_bcm2835" ];
services.pulseaudio.configFile =
lib.pipe
{
name = "default.pa";
src = "${lib.getBin config.services.pulseaudio.package}/etc/pulse/default.pa";
substitutions = [
"--replace-fail"
"load-module module-udev-detect"
"load-module module-udev-detect tsched=0"
];
}
[
pkgs.substitute
# Override NixOS's mkDefault (1000), but let explicit user configuration win.
(lib.mkOverride 990)
];
};
}
+1
View File
@@ -1,5 +1,6 @@
{
imports = [
./audio.nix
./config-txt.nix
./config-txt-defaults.nix
./firmware.nix
+7 -13
View File
@@ -10,9 +10,9 @@
let
# NOTE: raspberryPiWirelessFirmware should be updated with this
modDirVersion = "6.18.60";
tag = "stable_20261103";
hash = "sha256-Qx3D2+K7lkH5P1NI4NKqcHXVGoPqAeEiu+bZqBfSdDs=";
modDirVersion = "6.18.65";
tag = "stable_20261127";
hash = "sha256-VbyXdyMxhWvNv3GGJvs0D330xzc1pwP6IpXpe2Q/o4g=";
inherit (lib.kernel) freeform yes no;
in
(buildLinux (
@@ -45,16 +45,10 @@ in
isLTS = true;
kernelPatches =
with pkgs.kernelPatches;
[
bridge_stp_helper
request_key_helper
]
# Include 128-bit types patch if available
# Make it a required patch once https://github.com/NixOS/nixpkgs/pull/581990 is available on a stable channel
# Remove it once the Raspberry Pi vendor kernel is 7.3+
++ lib.optional (pkgs.kernelPatches ? tools_128bit_types) tools_128bit_types;
kernelPatches = with pkgs.kernelPatches; [
bridge_stp_helper
request_key_helper
];
# Override nixpkgs common-config.nix defaults that conflict with the RPi vendor defconfigs.
# See: https://github.com/raspberrypi/linux/tree/rpi-6.18.y/arch/arm64/configs
@@ -6,22 +6,22 @@
stdenvNoCC.mkDerivation {
pname = "raspberrypi-wireless-firmware";
version = "0-unstable-2026-11-09";
version = "0-unstable-2026-11-23";
srcs = [
(fetchFromGitHub {
name = "bluez-firmware";
owner = "RPi-Distro";
repo = "bluez-firmware";
rev = "cdf61dc691a49ff01a124752bd04194907f0f9cd";
hash = "sha256-35pnbQV/zcikz9Vic+2a1QAS72riruKklV8JHboL9NY=";
rev = "924fde7d1f0613d796e4512ac44ac33e4b91c4e3";
hash = "sha256-Ff0pzWidPgoEXpBqh81jmQWcpW90J1hH+gY61Wb8TEk=";
})
(fetchFromGitHub {
name = "firmware-nonfree";
owner = "RPi-Distro";
repo = "firmware-nonfree";
rev = "5d2295b633d94641253e16ba90fc847436fc9d4a";
hash = "sha256-Wt3kwrCnYpBllnumHUvy4Vl9/oUpHBtJ7Aandkfrjb8=";
rev = "b1833f18a816cf8fd73ca86e27f9eecea11bf991";
hash = "sha256-fe2oZV/qPBkemtG34cx9s2+4RhMn5XF0zl3EkmFDiZg=";
})
];
-1
View File
@@ -68,7 +68,6 @@
"ext4"
"vfat"
];
boot.initrd.systemd.enable = lib.mkDefault true;
system.nixos-init.enable = lib.mkDefault true;
system.etc.overlay.enable = lib.mkDefault true;
services.userborn.enable = lib.mkDefault true;
+4 -2
View File
@@ -4,8 +4,10 @@
../../.
];
# Add Motorcomm YT6801 Driver if available
# Add Motorcomm YT6801 Driver if available and kernel version is below 7.0
boot.extraModulePackages =
with config.boot;
lib.lists.optional (kernelPackages ? yt6801) kernelPackages.yt6801;
lib.lists.optional (
(lib.versionOlder kernelPackages.kernel.version "7.0") && (kernelPackages ? yt6801)
) kernelPackages.yt6801;
}
+4 -2
View File
@@ -4,8 +4,10 @@
../../.
];
# Add Motorcomm YT6801 Driver if available
# Add Motorcomm YT6801 Driver if available and kernel version is below 7.0
boot.extraModulePackages =
with config.boot;
lib.lists.optional (kernelPackages ? yt6801) kernelPackages.yt6801;
lib.lists.optional (
(lib.versionOlder kernelPackages.kernel.version "7.0") && (kernelPackages ? yt6801)
) kernelPackages.yt6801;
}
+4 -2
View File
@@ -4,8 +4,10 @@
../../.
];
# Add Motorcomm YT6801 Driver if available
# Add Motorcomm YT6801 Driver if available and kernel version is below 7.0
boot.extraModulePackages =
with config.boot;
lib.lists.optional (kernelPackages ? yt6801) kernelPackages.yt6801;
lib.lists.optional (
(lib.versionOlder kernelPackages.kernel.version "7.0") && (kernelPackages ? yt6801)
) kernelPackages.yt6801;
}