dtsoverlays

This commit is contained in:
mjallen18
2025-12-29 19:22:11 -06:00
parent 82e062a7e8
commit 209e776640
14 changed files with 315 additions and 53 deletions

View File

@@ -74,6 +74,7 @@ in
dolphin-emu
heroic
mgba
moonlight-qt
prismlauncher
ryubing
omnissa-horizon-client

View File

@@ -0,0 +1,30 @@
{ config, lib, pkgs, namespace, ... }:
let
cfg = config.${namespace}.hardware.raspberry-pi.audio;
variant = config.${namespace}.hardware.raspberry-pi.variant;
in
{
options.${namespace}.hardware.raspberry-pi.audio = {
enable = lib.mkEnableOption "enable audio dt overlays";
};
config = lib.mkIf cfg.enable {
hardware.deviceTree = {
overlays =
[ ] ++ (if (variant == "5") then
[
{
name = "pisound-pi5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/pisound-pi5-overlay.dts";
}
]
else
[
{
name = "pisound-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/pisound-overlay.dts";
}
]);
};
};
}

View File

@@ -0,0 +1,30 @@
{ config, lib, pkgs, namespace, ... }:
let
cfg = config.${namespace}.hardware.raspberry-pi.disable-bluetooth;
variant = config.${namespace}.hardware.raspberry-pi.variant;
in
{
options.${namespace}.hardware.raspberry-pi.disable-bluetooth = {
enable = lib.mkEnableOption "enable disablewifi dt overlays";
};
config = lib.mkIf cfg.enable {
hardware.deviceTree = {
overlays =
[ ] ++ (if (variant == "5") then
[
{
name = "disable-bt-pi5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/disable-bt-pi5-overlay.dts";
}
]
else
[
{
name = "disable-bt-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/disable-bt-overlay.dts";
}
]);
};
};
}

View File

@@ -36,7 +36,13 @@ in
};
imports = [
./audio.nix
./bluetooth.nix
./i2c.nix
./leds.nix
./modesetting.nix
./pwm.nix
./wifi.nix
];
config = lib.mkIf cfg.enable {
@@ -92,7 +98,7 @@ in
hardware = {
deviceTree = {
filter = lib.mkDefault (if (cfg.variant == "5") then "bcm2712-rpi-*.dtb" else "bcm2711-rpi-*.dtb");
overlays = lib.mkIf (cfg.variant == "4") [
overlays = (if (cfg.variant == "4") then [
{
name = "rpi4-cpu-revision";
dtsText = ''
@@ -131,24 +137,25 @@ in
};
'';
}
];
] else
[
{
name = "bcm2712d0-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/bcm2712d0-overlay.dts";
}
]);
};
firmware = [ pkgs.${namespace}.raspberryPiWirelessFirmware ];
graphics.enable32Bit = lib.mkForce false;
i2c.enable = lib.mkDefault true;
};
# Pi specific system tags
# system.nixos.tags = (
# let
# bootCfg = config.boot.loader.raspberry-pi;
# in
# [
# "raspberry-pi-${bootCfg.variant}"
# bootCfg.bootloader
# config.boot.kernelPackages.kernel.version
# ]
# );
Pi specific system tags
system.nixos.tags =[
"raspberry-pi-${cfg.variant}"
# config.boot.loader.raspberry-pi.bootloader
config.boot.kernelPackages.kernel.version
];
# Common programs
programs.kdeconnect.enable = lib.mkDefault false;
@@ -183,51 +190,12 @@ in
'';
};
nixpkgs.overlays = [
# (_self: super: {
# ffmpeg = super.${namespace}.ffmpeg-rpi;
# })
# (_self: super: {
# libraspberrypi = super.${namespace}.libraspberrypi;
# })
# (_self: super: {
# raspberrypi-utils = super.${namespace}.raspberrypi-utils;
# })
] ++ (if cfg.variant == "5" then [
nixpkgs.overlays = [ ] ++ (if cfg.variant == "5" then [
(final: prev: {
ubootRaspberryPi5 = prev.uboot.ubootRaspberryPi4_64Bit.override {
defconfig = "rpi_5_defconfig";
};
})
# (final: prev:
# let
# mkPi5 = drv:
# prev.lib.overrideDerivation
# (drv // {
# # Make sure we build the BCM2712 defconfig regardless of internal mapping
# argsOverride = (drv.argsOverride or {}) // {
# defconfig = "bcm2712_defconfig";
# };
# # Limit platforms to aarch64 for Pi 5
# extraMeta = (drv.extraMeta or {}) // {
# platforms = with prev.lib.platforms; prev.lib.intersectLists aarch64 linux;
# hydraPlatforms = [ "aarch64-linux" ];
# };
# })
# (old: {
# postFixup = (old.postFixup or "") + ''
# dtbDir=${if old.stdenv.hostPlatform.isAarch64 then "$out/dtbs/broadcom" else "$out/dtbs"}
# copyDTB() { cp -v "$dtbDir/$1" "$dtbDir/$2"; }
# # Pi 5 alias (only if your boot chain expects bcm283x-style names)
# if [ -e "$dtbDir/bcm2712-rpi-5-b.dtb" ]; then
# copyDTB bcm2712-rpi-5-b.dtb bcm2839-rpi-5-b.dtb
# fi
# '';
# });
# in {
# # Assuming your package is exposed as pkgs.linux-rpi; adapt the name if different
# linux-rpi5 = mkPi5 (prev.linux_rpi4.override { rpiVersion = 5; });
# })
(final: prev: {
# https://github.com/nvmd/nixos-raspberrypi/issues/64
# credit for the initial version of this snippet goes to @micahcc

View File

@@ -0,0 +1,61 @@
{ config, lib, pkgs, namespace, ... }:
let
cfg = config.${namespace}.hardware.raspberry-pi.i2c;
variant = config.${namespace}.hardware.raspberry-pi.variant;
in
{
options.${namespace}.hardware.raspberry-pi.i2c = {
enable = lib.mkEnableOption "enable i2c dt overlays";
};
config = lib.mkIf cfg.enable {
hardware.deviceTree = {
overlays = (if (variant == "5") then
[
{
name = "i2c0-pi5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/i2c0-pi5-overlay.dts";
}
{
name = "i2c1-pi5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/i2c1-pi5-overlay.dts";
}
{
name = "i2c2-pi5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/i2c2-pi5-overlay.dts";
}
{
name = "i2c3-pi5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/i2c3-pi5-overlay.dts";
}
]
else
[
{
name = "i2c0-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/i2c0-overlay.dts";
}
{
name = "i2c1-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/i2c1-overlay.dts";
}
{
name = "i2c3-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/i2c3-overlay.dts";
}
{
name = "i2c4-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/i2c4-overlay.dts";
}
{
name = "i2c5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/i2c5-overlay.dts";
}
{
name = "i2c6-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/i2c6-overlay.dts";
}
]);
};
};
}

View File

@@ -0,0 +1,35 @@
{ config, lib, pkgs, namespace, ... }:
let
cfg = config.${namespace}.hardware.raspberry-pi.modesetting;
variant = config.${namespace}.hardware.raspberry-pi.variant;
in
{
options.${namespace}.hardware.raspberry-pi.modesetting = {
enable = lib.mkEnableOption "enable modesetting dt overlays";
};
config = lib.mkIf cfg.enable {
hardware.deviceTree = {
overlays =
[
{
name = "vc4-fkms-v3d-pi4-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/vc4-fkms-v3d-pi4-overlay.dts";
}
] ++ (if (variant == "5") then
[
{
name = "vc4-kms-v3d-pi5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/vc4-kms-v3d-pi5-overlay.dts";
}
]
else
[
{
name = "vc4-kms-v3d-pi4-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/vc4-kms-v3d-pi4-overlay.dts";
}
]);
};
};
}

View File

@@ -0,0 +1,26 @@
{ config, lib, pkgs, namespace, ... }:
let
cfg = config.${namespace}.hardware.raspberry-pi.pwm;
variant = config.${namespace}.hardware.raspberry-pi.variant;
in
{
options.${namespace}.hardware.raspberry-pi.pwm = {
enable = lib.mkEnableOption "enable pwm dt overlay";
};
config = lib.mkIf cfg.enable {
hardware.deviceTree = {
overlays = [
{
name = "enable-pwm";
filter = (if (variant == "5") then "*pi5*" else "*rpi-4-b*");
dtsFile = (
if (variant == "5")
then "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/pwm-pio-rp1.dts"
else "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/pwm1-overlay.dts"
);
}
];
};
};
}

View File

@@ -0,0 +1,34 @@
{ config, lib, pkgs, namespace, ... }:
let
cfg = config.${namespace}.hardware.raspberry-pi.disable-wifi;
variant = config.${namespace}.hardware.raspberry-pi.variant;
in
{
options.${namespace}.hardware.raspberry-pi.disable-wifi = {
enable = lib.mkEnableOption "enable disablewifi dt overlays";
};
config = lib.mkIf cfg.enable {
hardware.deviceTree = {
overlays =
[ ] ++ (if (variant == "5") then
[
{
name = "disable-wifi-pi5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/disable-wifi-pi5-overlay.dts";
}
]
else
[
{
name = "disable-wifi-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/disable-wifi-overlay.dts";
}
{
name = "wifimac-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/share/raspberrypi-overlays/wifimac-overlay.dts";
}
]);
};
};
}

View File

@@ -0,0 +1,32 @@
{
config,
pkgs,
lib,
namespace,
...
}:
with lib;
let
name = "sunshine";
cfg = config.${namespace}.services.${name};
module = lib.${namespace}.mkModule {
inherit config name;
description = "Sunshine, a self-hosted game stream host for Moonlight";
options = { };
moduleConfig = {
services.sunshine = {
enable = true;
openFirewall = cfg.openFirewall;
autoStart = true;
capSysAdmin = true;
applications.apps = with pkgs; [
steam
];
};
};
};
in
{
imports = [ module ];
}

View File

@@ -10,6 +10,7 @@ in
[
disko
nil
nix-output-monitor
nixos-anywhere
qemu
udisks2

View File

@@ -0,0 +1,36 @@
{
lib,
stdenvNoCC,
fetchFromGitHub,
}:
stdenvNoCC.mkDerivation rec {
# NOTE: this should be updated with linux_rpi
pname = "raspberrypi-dtoverlays";
version = "stable_20250916";
src = fetchFromGitHub {
owner = "raspberrypi";
repo = "linux";
tag = version;
hash = "sha256-HG8Oc04V2t54l0SOn4gKmNJWQUrZfjWusgKcWvx74H0==";
};
installPhase = ''
mkdir -p $out/share/raspberrypi-overlays/
mv arch/arm/boot/dts/overlays/* "$out/share/raspberrypi-overlays/"
'';
dontConfigure = true;
dontBuild = true;
dontFixup = true;
meta = with lib; {
description = "Overlays for the Raspberry Pi board";
homepage = "https://github.com/raspberrypi/linux";
maintainers = with maintainers; [ ];
# Hash mismatch on source, mystery.
# Maybe due to https://github.com/NixOS/nix/issues/847
broken = stdenvNoCC.hostPlatform.isDarwin;
};
}

View File

@@ -50,6 +50,10 @@
raspberry-pi = {
enable = true;
variant = "5";
pwm.enable = true;
disable-wifi.enable = true;
modesetting.enable = true;
i2c.enable = true;
};
};

View File

@@ -173,6 +173,9 @@ in
enable = true;
port = 8008;
};
sunshine = {
enable = true;
};
tdarr = {
enable = false;
port = 8265;

View File

@@ -2,6 +2,7 @@
config,
lib,
pkgs,
namespace,
...
}:
let