dtsoverlays
This commit is contained in:
30
modules/nixos/hardware/raspberry-pi/audio.nix
Normal file
30
modules/nixos/hardware/raspberry-pi/audio.nix
Normal 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";
|
||||
}
|
||||
]);
|
||||
};
|
||||
};
|
||||
}
|
||||
30
modules/nixos/hardware/raspberry-pi/bluetooth.nix
Normal file
30
modules/nixos/hardware/raspberry-pi/bluetooth.nix
Normal 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";
|
||||
}
|
||||
]);
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -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
|
||||
|
||||
61
modules/nixos/hardware/raspberry-pi/i2c.nix
Normal file
61
modules/nixos/hardware/raspberry-pi/i2c.nix
Normal 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";
|
||||
}
|
||||
]);
|
||||
};
|
||||
};
|
||||
}
|
||||
35
modules/nixos/hardware/raspberry-pi/modesetting.nix
Normal file
35
modules/nixos/hardware/raspberry-pi/modesetting.nix
Normal 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";
|
||||
}
|
||||
]);
|
||||
};
|
||||
};
|
||||
}
|
||||
26
modules/nixos/hardware/raspberry-pi/pwm.nix
Normal file
26
modules/nixos/hardware/raspberry-pi/pwm.nix
Normal 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"
|
||||
);
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
34
modules/nixos/hardware/raspberry-pi/wifi.nix
Normal file
34
modules/nixos/hardware/raspberry-pi/wifi.nix
Normal 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";
|
||||
}
|
||||
]);
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user