This commit is contained in:
mjallen18
2026-01-02 20:30:05 -06:00
parent b7380317b9
commit 56154fe941
38 changed files with 1188 additions and 594 deletions

View File

@@ -128,7 +128,7 @@ in
};
services = {
nextcloud-client.enable = false;#lib.mkDefault hasDestopEnvironment;
nextcloud-client.enable = false; # lib.mkDefault hasDestopEnvironment;
pass-secret-service = lib.mkDefault enabled;
kdeconnect = {
enable = lib.mkDefault hasDestopEnvironment;

View File

@@ -1,4 +1,10 @@
{ config, lib, pkgs, namespace, ... }:
{
config,
lib,
pkgs,
namespace,
...
}:
let
cfg = config.${namespace}.hardware.raspberry-pi.audio;
variant = config.${namespace}.hardware.raspberry-pi.variant;
@@ -11,11 +17,15 @@ in
config = lib.mkIf cfg.enable {
hardware.deviceTree = {
overlays =
[ ] ++ (if (variant == "5") then
[ ]
++ (
if (variant == "5") then
[
{
name = "pisound-pi5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/pisound-pi5-overlay.dts";
dtsFile = "${
pkgs.${namespace}.raspberrypi-overlays
}/dtbs/raspberrypi-overlays/pisound-pi5-overlay.dts";
}
]
else
@@ -24,7 +34,8 @@ in
name = "pisound-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/pisound-overlay.dts";
}
]);
]
);
};
};
}

View File

@@ -1,4 +1,10 @@
{ config, lib, pkgs, namespace, ... }:
{
config,
lib,
pkgs,
namespace,
...
}:
let
cfg = config.${namespace}.hardware.raspberry-pi.disable-bluetooth;
variant = config.${namespace}.hardware.raspberry-pi.variant;
@@ -11,20 +17,27 @@ in
config = lib.mkIf cfg.enable {
hardware.deviceTree = {
overlays =
[ ] ++ (if (variant == "5") then
[ ]
++ (
if (variant == "5") then
[
{
name = "disable-bt-pi5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/disable-bt-pi5-overlay.dts";
dtsFile = "${
pkgs.${namespace}.raspberrypi-overlays
}/dtbs/raspberrypi-overlays/disable-bt-pi5-overlay.dts";
}
]
else
[
{
name = "disable-bt-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/disable-bt-overlay.dts";
dtsFile = "${
pkgs.${namespace}.raspberrypi-overlays
}/dtbs/raspberrypi-overlays/disable-bt-overlay.dts";
}
]);
]
);
};
};
}

View File

@@ -4,66 +4,92 @@
# with modifications
# https://raw.githubusercontent.com/nvmd/raspberry-pi-nix/refs/heads/master/rpi/config.nix
{ lib, config, pkgs, namespace, ... }:
{
lib,
config,
namespace,
...
}:
let
cfg = config.${namespace}.hardware.raspberry-pi;
render-raspberrypi-config = let
render-raspberrypi-config =
let
render-kvs = kvs: let
render-kv = k: v:
if isNull v.value then k
else "${k}=${toString v.value}";
in lib.attrsets.mapAttrsToList render-kv
(lib.filterAttrs (k: v: v.enable) kvs);
render-kvs =
kvs:
let
render-kv = k: v: if isNull v.value then k else "${k}=${toString v.value}";
in
lib.attrsets.mapAttrsToList render-kv (lib.filterAttrs (_k: v: v.enable) kvs);
render-dt-param = x: "dtparam=" + x;
render-dt-params = params:
lib.strings.concatMapStringsSep "\n" render-dt-param (render-kvs params);
render-dt-params = params: lib.strings.concatMapStringsSep "\n" render-dt-param (render-kvs params);
render-dt-overlay = { overlay, params }:
lib.concatStringsSep "\n" (lib.filter (x: x != "") [
render-dt-overlay =
{ overlay, params }:
lib.concatStringsSep "\n" (
lib.filter (x: x != "") [
("dtoverlay=" + overlay)
(render-dt-params params)
"dtoverlay="
]);
]
);
render-options = opts:
lib.strings.concatStringsSep "\n" (render-kvs opts);
render-options = opts: lib.strings.concatStringsSep "\n" (render-kvs opts);
render-base-dt-params = render-dt-params;
render-dt-overlays = overlays:
lib.strings.concatMapStringsSep "\n" render-dt-overlay
(lib.attrsets.mapAttrsToList
(overlay: params: {
render-dt-overlays =
overlays:
lib.strings.concatMapStringsSep "\n" render-dt-overlay (
lib.attrsets.mapAttrsToList (overlay: params: {
inherit overlay;
inherit (params) params;
})
(lib.filterAttrs (k: v: v.enable) overlays));
}) (lib.filterAttrs (_k: v: v.enable) overlays)
);
render-config-section = conditionalFilter:
{ options, base-dt-params, dt-overlays }:
let all-config = lib.concatStringsSep "\n" (lib.filter (x: x != "") [
render-config-section =
conditionalFilter:
{
options,
base-dt-params,
dt-overlays,
}:
let
all-config = lib.concatStringsSep "\n" (
lib.filter (x: x != "") [
(render-options options)
(render-base-dt-params base-dt-params)
(render-dt-overlays dt-overlays)
]);
in ''
]
);
in
''
[${conditionalFilter}]
${all-config}
'';
in conf: lib.strings.concatStringsSep "\n"
((lib.attrsets.mapAttrsToList render-config-section conf)
++ [ cfg.extra-config ]);
in {
in
conf:
lib.strings.concatStringsSep "\n" (
(lib.attrsets.mapAttrsToList render-config-section conf) ++ [ cfg.extra-config ]
);
in
{
options.${namespace}.hardware.raspberry-pi = {
config = let
config =
let
rpi-config-param = {
options = {
enable = lib.mkEnableOption "attr";
value = lib.mkOption {
type = with lib.types; oneOf [ int str bool ];
type =
with lib.types;
oneOf [
int
str
bool
];
};
};
};
@@ -71,7 +97,13 @@ in {
options = {
enable = lib.mkEnableOption "attr";
value = lib.mkOption {
type = with lib.types; nullOr (oneOf [ int str bool ]);
type =
with lib.types;
nullOr (oneOf [
int
str
bool
]);
default = null;
};
};
@@ -81,7 +113,7 @@ in {
enable = lib.mkEnableOption "overlay";
params = lib.mkOption {
type = with lib.types; attrsOf (submodule dt-param);
default = {};
default = { };
};
};
};
@@ -96,7 +128,8 @@ in {
<https://www.raspberrypi.com/documentation/computers/config_txt.html#common-hardware-configuration-options>
'';
example = {
arm_boost = { # arm_boost=1
arm_boost = {
# arm_boost=1
enable = true;
value = true;
};
@@ -111,11 +144,13 @@ in {
<https://www.raspberrypi.com/documentation/computers/configuration.html#part3.2>
'';
example = {
i2c = { # dtparam=i2c=on
i2c = {
# dtparam=i2c=on
enable = true;
value = "on";
};
ant2 = { # dtparam=ant2
ant2 = {
# dtparam=ant2
enable = true;
};
};
@@ -134,7 +169,8 @@ in {
<https://www.raspberrypi.com/documentation/computers/configuration.html#part3.1>
'';
example = {
vc4-kms-v3d = { # dtoverlay=vc4-kms-v3d,cma-256
vc4-kms-v3d = {
# dtoverlay=vc4-kms-v3d,cma-256
enable = true;
params = {
cma-256 = {
@@ -143,14 +179,16 @@ in {
};
};
};
disable-bt = { # dtoverlay=disable-bt
disable-bt = {
# dtoverlay=disable-bt
enable = true;
};
};
};
};
};
in lib.mkOption {
in
lib.mkOption {
type = with lib.types; attrsOf (submodule raspberry-pi-config-options);
description = ''
Configures `config.txt` file for Raspberry Pi devices.

View File

@@ -13,24 +13,6 @@ let
};
};
ubootBinName = "u-boot.bin";
deviceTree = ({ pkgs
, firmware
}: pkgs.replaceVarsWith {
src = ./generational/install-device-tree.sh;
isExecutable = true;
replacements = {
inherit (pkgs) bash;
path = pkgs.lib.makeBinPath [
pkgs.coreutils
];
inherit firmware;
};
});
# installs raspberry's firmware independent of the nixos generations
# sometimes referred to as "boot code"
raspberryPiFirmware = ({ pkgs
@@ -50,9 +32,45 @@ let
};
});
# Builders used to write during system activation
firmwareBuilder = import ./firmware-builder.nix {
kernelbootGenBuilder = ({ pkgs
, deviceTreeInstaller
}: pkgs.replaceVarsWith {
src = ./generational/kernelboot-gen-builder.sh;
isExecutable = true;
replacements = {
inherit (pkgs) bash;
path = pkgs.lib.makeBinPath [
pkgs.coreutils
];
installDeviceTree = deviceTreeInstaller;
};
});
deviceTree = ({ pkgs
, firmware
}: pkgs.replaceVarsWith {
src = ./generational/install-device-tree.sh;
isExecutable = true;
replacements = {
inherit (pkgs) bash;
path = pkgs.lib.makeBinPath [
pkgs.coreutils
];
inherit firmware;
};
});
mkBootloader = pkgs: bootloader {
inherit pkgs;
inherit (cfg) nixosGenerationsDir;
firmwareInstaller = "${raspberryPiFirmware {
inherit pkgs;
firmware = pkgs.${namespace}.raspberrypifw;
configTxt = pkgs.writeTextFile {
name = "config.txt";
text = ''
@@ -64,19 +82,73 @@ let
${config.${namespace}.hardware.raspberry-pi.config-generated}
'';
};
firmware = pkgs.${namespace}.raspberrypifw;
}}";
nixosGenBuilder = "${kernelbootGenBuilder {
inherit pkgs;
deviceTreeInstaller = let
cmd = deviceTree {
inherit pkgs;
firmware = cfg.firmwarePackage;
};
args = lib.optionalString (!cfg.useGenerationDeviceTree) " -r";
in "${cmd} ${args}";
}}";
};
bootloader = ({ pkgs
, nixosGenerationsDir
, firmwareInstaller
, nixosGenBuilder
}: pkgs.replaceVarsWith {
src = ./generational/nixos-generations-builder.sh;
isExecutable = true;
replacements = {
inherit (pkgs) bash;
path = pkgs.lib.makeBinPath [
pkgs.coreutils
pkgs.gnused
];
# NixOS-generations -independent
installFirmwareBuilder = firmwareInstaller;
# NixOS-generations -dependent
inherit nixosGenerationsDir nixosGenBuilder;
};
});
# Builders used to write during system activation
ubootBuilder = import ./uboot-builder.nix {
inherit pkgs;
ubootPackage = (if (cfg.variant == "5") then pkgs.${namespace}.uboot-pi5 else pkgs.${namespace}.uboot-pi4);
ubootPackage = (
if (cfg.variant == "5") then pkgs.${namespace}.uboot-pi5 else pkgs.${namespace}.uboot-pi4
);
firmwareBuilder = firmwarePopulateCmd;
extlinuxConfBuilder = config.boot.loader.generic-extlinux-compatible.populateCmd;
};
uefiBuilder = import ./uefi-builder.nix{
populateUbootBuilder = import ./uboot-builder.nix {
pkgs = pkgs.buildPackages;
ubootPackage = (
if (cfg.variant == "5") then pkgs.${namespace}.uboot-pi5 else pkgs.${namespace}.uboot-pi4
);
firmwareBuilder = firmwarePopulateCmd;
extlinuxConfBuilder = config.boot.loader.generic-extlinux-compatible.populateCmd;
};
kernelbootBuilder = import ./kernelboot-builder.nix {
inherit pkgs;
uefiPackage = (if (cfg.variant == "5") then pkgs.${namespace}.uefi-rpi5 else pkgs.${namespace}.uefi-rpi4);
firmwareBuilder = firmwarePopulateCmd;
};
uefiBuilder = import ./uefi-builder.nix {
inherit pkgs;
uefiPackage = (
if (cfg.variant == "5") then pkgs.${namespace}.uefi-rpi5 else pkgs.${namespace}.uefi-rpi4
);
firmwareBuilder = firmwarePopulateCmd;
};
@@ -97,12 +169,9 @@ let
firmware = pkgs.${namespace}.raspberrypifw;
};
populateUbootBuilder = import ./uboot-builder.nix {
inherit ubootBinName;
populateKernelbootBuilder = import ./kernelboot-builder.nix {
pkgs = pkgs.buildPackages;
ubootPackage = (if (cfg.variant == "5") then pkgs.${namespace}.uboot-pi5 else pkgs.${namespace}.uboot-pi4);
firmwareBuilder = firmwarePopulateCmd;
extlinuxConfBuilder = config.boot.loader.generic-extlinux-compatible.populateCmd;
};
firmwarePopulateCmd = "${populateFirmwareBuilder} ${firmwareBuilderArgs}";
@@ -114,6 +183,12 @@ let
# system.build.installBootLoader
uboot = "${ubootBuilder} -f /boot/firmware -b /boot -c";
uefi = "${uefiBuilder} -f /boot/firmware -b /boot -c";
kernel = builtins.concatStringsSep " " [
"${mkBootloader pkgs}"
"-g ${toString 10}"
"-f /boot/firmware"
"-c"
];
};
# firmware: caller must provide `-c <nixos configuration>` and `-f <firmware target path>`
@@ -123,6 +198,14 @@ let
firmware = "${populateUbootBuilder}";
boot = "${populateUbootBuilder}";
};
kernel = let cmd = builtins.concatStringsSep " " [
"${mkBootloader pkgs.buildPackages}"
"-g ${toString cfg.configurationLimit}"
];
in {
firmware = "${cmd}";
boot = "${cmd}";
};
};
in
{
@@ -141,6 +224,7 @@ in
type = lib.types.enum [
"uefi"
"uboot"
"kernel"
];
default = "uefi";
};
@@ -172,23 +256,31 @@ in
initrd.availableKernelModules = [
"usbhid"
"usb-storage"
] ++ (if (cfg.variant == "5") then [
]
++ (
if (cfg.variant == "5") then
[
"nvme"
] else
]
else
[
"vc4"
"pcie-brcmstb" # required for the pcie bus to work
"reset-raspberrypi" # required for vl805 firmware to load
]);
]
);
loader = {
# kernelFile = pkgs.stdenv.hostPlatform.linux-kernel.target;
generic-extlinux-compatible = {
enable = lib.mkDefault (if cfg.bootType == "uefi" then false else true);
useGenerationDeviceTree = lib.mkOverride 60 (if cfg.bootType == "uefi" then false else true);
};
systemd-boot.enable = (if cfg.bootType == "uefi" then true else false);
systemd-boot.extraInstallCommands = let
bootloaderInstaller = (if cfg.bootType == "uefi" then (builder."uefi") else (builder."uboot")); # todo
in ''
systemd-boot.extraInstallCommands =
let
bootloaderInstaller = (builder."${cfg.bootType}");
in
''
${bootloaderInstaller} -f /boot/firmware -b /boot -c
'';
grub.enable = lib.mkForce false;
@@ -224,11 +316,38 @@ in
];
};
${namespace}.hardware.raspberry-pi = {
config = {
all = {
options = {
os_prefix = lib.mkIf (cfg.bootType == "kernel") {
enable = true;
value = "${cfg.nixosGenerationsDir}/default/"; # "nixos/<generation-name>/"
};
kernel = lib.mkIf (cfg.bootType == "kernel" || cfg.bootType == "uboot") {
enable = true;
value = (if cfg.bootType == "uboot" then "u-boot.bin" else if cfg.bootType == "kernel" then "kernel.img" else "");
};
};
};
};
extra-config = let
# https://www.raspberrypi.com/documentation/computers/config_txt.html#initramfs
ramfsfile = "initrd";
ramfsaddr = "followkernel"; # same as 0 = "after the kernel image"
in ''
[all]
initramfs ${ramfsfile} ${ramfsaddr}
'';
};
# Common hardware settings
hardware = {
deviceTree = {
filter = lib.mkDefault (if (cfg.variant == "5") then "bcm2712-rpi-*.dtb" else "bcm2711-rpi-*.dtb");
overlays = (if (cfg.variant == "4") then [
overlays = (
if (cfg.variant == "4") then
[
{
name = "rpi4-cpu-revision";
dtsText = ''
@@ -267,13 +386,15 @@ in
# };
# '';
# }
] else
]
else
[
{
name = "bcm2712d0-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/bcm2712d0-overlay.dts";
}
]);
# {
# name = "bcm2712d0-overlay";
# dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/bcm2712d0-overlay.dts";
# }
]
);
};
firmware = [ pkgs.${namespace}.raspberryPiWirelessFirmware ];
graphics.enable32Bit = lib.mkForce false;
@@ -303,12 +424,12 @@ in
users = {
users.root.shell = pkgs.zsh;
extraGroups = {
gpio = {};
i2c = {};
input = {};
plugdev = {};
spi = {};
video = {};
gpio = { };
i2c = { };
input = { };
plugdev = { };
spi = { };
video = { };
};
};
@@ -316,10 +437,12 @@ in
udev.packages = [
pkgs.${namespace}.udev-rules
];
xserver.extraConfig = let
xserver.extraConfig =
let
identifier = "rp1";
driver = "rp1-vec|rp1-dsi|rp1-dpi";
in ''
in
''
Section "OutputClass"
Identifier "${identifier}"
MatchDriver "${driver}"
@@ -329,20 +452,29 @@ in
'';
};
nixpkgs.overlays = [ ] ++ (if cfg.variant == "5" then [
(final: prev: {
nixpkgs.overlays =
[ ]
++ (
if cfg.variant == "5" then
[
(_final: prev: {
# https://github.com/nvmd/nixos-raspberrypi/issues/64
# credit for the initial version of this snippet goes to @micahcc
jemalloc = prev.jemalloc.overrideAttrs (old: {
# --with-lg-page=(log2 page_size)
# RPi5 (bcm2712): since our page size is 16384 (2**14), we need 14
configureFlags = let
configureFlags =
let
pageSizeFlag = "--with-lg-page";
in (prev.lib.filter (flag: prev.lib.hasPrefix pageSizeFlag flag == false) old.configureFlags)
in
(prev.lib.filter (flag: prev.lib.hasPrefix pageSizeFlag flag == false) old.configureFlags)
++ [ "${pageSizeFlag}=14" ];
});
})
] else [ ])
]
else
[ ]
)
++ (if cfg.apply-overlays-dtmerge.enable then [ dt_ao_overlay ] else [ ]);
};
}

View File

@@ -1,6 +1,7 @@
{ pkgs
, configTxt
, firmware ? pkgs.raspberrypifw
{
pkgs,
configTxt,
firmware ? pkgs.raspberrypifw,
}:
pkgs.replaceVarsWith {

View File

@@ -0,0 +1,68 @@
#! @bash@/bin/sh -e
# shellcheck disable=SC3037,SC3043,SC3044
shopt -s nullglob
export PATH=/empty:@path@
copyForced() {
local src="$1"
local dst="$2"
local dstTmp="$dst.tmp.$$"
cp "$src" "$dstTmp"
mv "$dstTmp" "$dst"
}
# Copy generation's kernel, initrd, cmdline to `genDir`.
addEntry() {
local generationPath="$1"
local generationName="$2"
local genDir="$3"
if ! { [ -e "$generationPath/kernel" ] && [ -e "$generationPath/initrd" ]; }; then
return
fi
echo -n "kernel..."
local kernel="$(readlink -f "$generationPath/kernel")"
local initrd="$(readlink -f "$generationPath/initrd")"
readlink -f "$generationPath" > "$genDir/system-link"
echo "$kernel" > "$genDir/kernel-link"
copyForced "$kernel" "$genDir/kernel.img"
copyForced "$initrd" "$genDir/initrd"
echo "$(cat "$generationPath/kernel-params") init=$generationPath/init" > "$genDir/cmdline.txt"
echo -n "device tree..."
@installDeviceTree@ -c "$generationPath" -d "$genDir"
echo
}
usage() {
echo "usage: $0 -c <path-to-configuration> -n <configuration-name> -d <installation-directory>" >&2
exit 1
}
generationPath= # Path to nixos configuration/generation
generationName= # Name of the generation
target=/boot/firmware # Target directory
echo "$0: $@"
while getopts "c:n:d:" opt; do
case "$opt" in
c) generationPath="$OPTARG" ;;
n) generationName="$OPTARG" ;;
d) target="$OPTARG" ;;
\?) usage ;;
esac
done
addEntry "$generationPath" "$generationName" "$target"
echo "kernel boot files installed for nixos generation '$generationName'"

View File

@@ -1,4 +1,10 @@
{ config, lib, pkgs, namespace, ... }:
{
config,
lib,
pkgs,
namespace,
...
}:
let
cfg = config.${namespace}.hardware.raspberry-pi.i2c;
variant = config.${namespace}.hardware.raspberry-pi.variant;
@@ -10,23 +16,32 @@ in
config = lib.mkIf cfg.enable {
hardware.deviceTree = {
overlays = (if (variant == "5") then
overlays = (
if (variant == "5") then
[
{
name = "i2c0-pi5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c0-pi5-overlay.dts";
dtsFile = "${
pkgs.${namespace}.raspberrypi-overlays
}/dtbs/raspberrypi-overlays/i2c0-pi5-overlay.dts";
}
{
name = "i2c1-pi5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c1-pi5-overlay.dts";
dtsFile = "${
pkgs.${namespace}.raspberrypi-overlays
}/dtbs/raspberrypi-overlays/i2c1-pi5-overlay.dts";
}
{
name = "i2c2-pi5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c2-pi5-overlay.dts";
dtsFile = "${
pkgs.${namespace}.raspberrypi-overlays
}/dtbs/raspberrypi-overlays/i2c2-pi5-overlay.dts";
}
{
name = "i2c3-pi5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c3-pi5-overlay.dts";
dtsFile = "${
pkgs.${namespace}.raspberrypi-overlays
}/dtbs/raspberrypi-overlays/i2c3-pi5-overlay.dts";
}
]
else
@@ -55,7 +70,8 @@ in
name = "i2c6-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c6-overlay.dts";
}
]);
]
);
};
};
}

View File

@@ -0,0 +1,19 @@
{ pkgs
, firmwareBuilder
}:
pkgs.replaceVarsWith {
src = ./kernelboot-builder.sh;
isExecutable = true;
replacements = {
inherit (pkgs) bash;
path = pkgs.lib.makeBinPath [
pkgs.coreutils
pkgs.gnused
];
inherit firmwareBuilder;
copyKernels = true;
};
}

View File

@@ -0,0 +1,147 @@
#! @bash@/bin/sh -e
shopt -s nullglob
export PATH=/empty:@path@
# used to track copied files to decide which are obsolete
# and need to be removed
declare -A filesCopied
# Convert a path to a file in the Nix store such as
# /nix/store/<hash>-<name>/file to <hash>-<name>-<file>.
cleanName() {
local path="$1"
echo "$path" | sed 's|^/nix/store/||' | sed 's|/|-|g'
}
# Copy a file from the Nix store to `kernelsDir`.
copyToKernelsDir() {
local src="$1"
local kernelsDir="$2"
local dst="$kernelsDir/$(cleanName $src)"
# Don't copy the file if $dst already exists. This means that we
# have to create $dst atomically to prevent partially copied
# kernels or initrd if this script is ever interrupted.
if ! test -e $dst; then
local dstTmp=$dst.tmp.$$
cp $src $dstTmp
mv $dstTmp $dst
fi
filesCopied[$dst]=1
result=$dst
}
copyForced() {
local src="$1"
local dst="$2"
cp $src $dst.tmp
mv $dst.tmp $dst
}
# Copy generation's kernel and initrd to `kernelsDir`.
# Default generation's are also copied to `outdir`
addEntry() {
local generationPath="$1"
local generationName="$2"
local outdir="$3"
local kernelsDir="$4"
if ! test -e $generationPath/kernel -a -e $generationPath/initrd; then
return
fi
local kernel=$(readlink -f $generationPath/kernel)
local initrd=$(readlink -f $generationPath/initrd)
if test "1" = "@copyKernels@"; then
copyToKernelsDir $kernel $kernelsDir; kernel=$result
copyToKernelsDir $initrd $kernelsDir; initrd=$result
fi
echo $(readlink -f $generationPath) > $kernelsDir/$generationName-system
echo $(readlink -f $generationPath/init) > $kernelsDir/$generationName-init
cp $generationPath/kernel-params $kernelsDir/$generationName-cmdline.txt
echo $initrd > $kernelsDir/$generationName-initrd
echo $kernel > $kernelsDir/$generationName-kernel
if test "$generationName" = "default"; then
copyForced $kernel $outdir/kernel.img
copyForced $initrd $outdir/initrd
cp "$(readlink -f "$generationPath/init")" $outdir/nixos-init
echo "`cat $generationPath/kernel-params` init=$generationPath/init" >$outdir/cmdline.txt
fi
}
removeObsolete() {
local path="$1"
# Remove obsolete files from $path and $path/old.
for fn in $path/*linux* $path/*initrd-initrd*; do
if ! test "${filesCopied[$fn]}" = 1; then
rm -vf -- "$fn"
fi
done
}
addAllEntries() {
local defaultGenerationPath="$1"
local outdir="$2"
local kernelsDir="$outdir/nixos-kernels"
mkdir -p $kernelsDir || true
# Add default generation
addEntry $defaultGenerationPath default $outdir $kernelsDir
# Add all generations of the system profile to the menu, in reverse
# (most recent to least recent) order.
for generation in $(
(cd /nix/var/nix/profiles && ls -d system-*-link) \
| sed 's/system-\([0-9]\+\)-link/\1/' \
| sort -n -r); do
link=/nix/var/nix/profiles/system-$generation-link
addEntry $link $generation $outdir $kernelsDir
done
removeObsolete $kernelsDir
}
usage() {
echo "usage: $0 -c <path-to-default-configuration> [-d <boot-dir>]" >&2
exit 1
}
default= # Default configuration
echo "kernelboot-builder: $@"
while getopts "c:b:f:" opt; do
case "$opt" in
c) default="$OPTARG" ;;
b) boottarget="$OPTARG" ;;
f) fwtarget="$OPTARG" ;;
\?) usage ;;
esac
done
if [ -z "$boottarget" ] && [ -z "$fwtarget" ]; then
echo "Error: at least one of \`-b <boot-dir>\` and \`-f <firmware-dir>\` must be set"
usage
fi
if [ -n "$fwtarget" ]; then
@firmwareBuilder@ -c $default -d $fwtarget
echo "updating the boot generations directory..."
addAllEntries $default $fwtarget
fi
if [ -n "$boottarget" ]; then
echo "'-b $boottarget' isn't used when loading the kernel directly with kernelboot: \
kernels are copied directly to <firmware-dir>"
fi
echo "kernelboot bootloader installed"

View File

@@ -1,4 +1,9 @@
{ config, lib, namespace, ... }:
{
config,
lib,
namespace,
...
}:
let
cfg = config.${namespace}.hardware.raspberry-pi.leds;

View File

@@ -1,4 +1,10 @@
{ config, lib, pkgs, namespace, ... }:
{
config,
lib,
pkgs,
namespace,
...
}:
let
cfg = config.${namespace}.hardware.raspberry-pi.modesetting;
variant = config.${namespace}.hardware.raspberry-pi.variant;
@@ -11,25 +17,27 @@ in
config = lib.mkIf cfg.enable {
hardware.deviceTree = {
overlays =
[
{
name = "vc4-fkms-v3d-pi4-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/vc4-fkms-v3d-pi4-overlay.dts";
}
] ++ (if (variant == "5") then
[ ]
++ (
if (variant == "5") then
[
{
name = "vc4-kms-v3d-pi5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/vc4-kms-v3d-pi5-overlay.dts";
dtsFile = "${
pkgs.${namespace}.raspberrypi-overlays
}/dtbs/raspberrypi-overlays/vc4-kms-v3d-pi5-overlay.dts";
}
]
else
[
{
name = "vc4-kms-v3d-pi4-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/vc4-kms-v3d-pi4-overlay.dts";
name = "vc4-fkms-v3d-pi4-overlay";
dtsFile = "${
pkgs.${namespace}.raspberrypi-overlays
}/dtbs/raspberrypi-overlays/vc4-fkms-v3d-pi4-overlay.dts";
}
]);
]
);
};
};
}

View File

@@ -1,4 +1,10 @@
{ config, lib, pkgs, namespace, ... }:
{
config,
lib,
pkgs,
namespace,
...
}:
let
cfg = config.${namespace}.hardware.raspberry-pi.pwm;
variant = config.${namespace}.hardware.raspberry-pi.variant;
@@ -15,9 +21,10 @@ in
name = "enable-pwm";
filter = (if (variant == "5") then "*pi5*" else "*rpi-4-b*");
dtsFile = (
if (variant == "5")
then "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/pwm-pio-overlay.dts"
else "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/pwm1-overlay.dts"
if (variant == "5") then
"${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/pwm-pio-overlay.dts"
else
"${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/pwm1-overlay.dts"
);
}
];

View File

@@ -1,8 +1,9 @@
{ pkgs
, ubootPackage
, ubootBinName ? "u-boot.bin"
, extlinuxConfBuilder
, firmwareBuilder
{
pkgs,
ubootPackage,
ubootBinName ? "u-boot.bin",
extlinuxConfBuilder,
firmwareBuilder,
}:
pkgs.replaceVarsWith {

View File

@@ -1,6 +1,7 @@
{ pkgs
, uefiPackage
, firmwareBuilder
{
pkgs,
uefiPackage,
firmwareBuilder,
}:
pkgs.replaceVarsWith {

View File

@@ -42,7 +42,7 @@ if [ -n "$fwtarget" ]; then
@firmwareBuilder@ -c $default -d $fwtarget
echo "copying uefi firmware..."
rm -rf $fwtarget/*
# rm -rf $fwtarget/*
copyForced @uefi@ $fwtarget/
fi

View File

@@ -1,4 +1,10 @@
{ config, lib, pkgs, namespace, ... }:
{
config,
lib,
pkgs,
namespace,
...
}:
let
cfg = config.${namespace}.hardware.raspberry-pi.disable-wifi;
variant = config.${namespace}.hardware.raspberry-pi.variant;
@@ -11,24 +17,31 @@ in
config = lib.mkIf cfg.enable {
hardware.deviceTree = {
overlays =
[ ] ++ (if (variant == "5") then
[ ]
++ (
if (variant == "5") then
[
{
name = "disable-wifi-pi5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/disable-wifi-pi5-overlay.dts";
dtsFile = "${
pkgs.${namespace}.raspberrypi-overlays
}/dtbs/raspberrypi-overlays/disable-wifi-pi5-overlay.dts";
}
]
else
[
{
name = "disable-wifi-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/disable-wifi-overlay.dts";
dtsFile = "${
pkgs.${namespace}.raspberrypi-overlays
}/dtbs/raspberrypi-overlays/disable-wifi-overlay.dts";
}
{
name = "wifimac-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/wifimac-overlay.dts";
}
]);
]
);
};
};
}

View File

@@ -1,13 +1,9 @@
{
config,
lib,
pkgs,
namespace,
...
}:
let
gpuTargets = [ "gfx1102" ]; # todo update when support is added gfx1150
in
{
programs.ccache = {
enable = true;
@@ -61,37 +57,81 @@ in
(_self: super: {
${namespace} =
let
clangCcacheStdenv = super.overrideCC super.llvmPackages.stdenv (super.ccacheWrapper.override {
clangCcacheStdenv = super.overrideCC super.llvmPackages.stdenv (
super.ccacheWrapper.override {
cc = super.llvmPackages.stdenv.cc;
extraConfig = ''
export CCACHE_SLOPPINESS=include_file_ctime,time_macros
export CCACHE_DIR=/var/cache/ccache
'';
});
}
);
in
super.${namespace} // {
linuxPackages_rpi5 = super.linuxPackagesFor (super.${namespace}.linux-rpi.override { stdenv = super.ccacheStdenv; });
linuxPackages_rpi4 = super.linuxPackagesFor (super.${namespace}.linux-rpi.override { stdenv = super.ccacheStdenv; rpiVersion = 4; });
super.${namespace}
// {
linuxPackages_rpi5 = super.linuxPackagesFor (
super.${namespace}.linux-rpi.override { stdenv = super.ccacheStdenv; }
);
linuxPackages_rpi4 = super.linuxPackagesFor (
super.${namespace}.linux-rpi.override {
stdenv = super.ccacheStdenv;
rpiVersion = 4;
}
);
libraspberrypi = super.${namespace}.libraspberrypi.override { stdenv = super.ccacheStdenv; };
raspberrypi-utils = super.${namespace}.raspberrypi-utils.override { stdenv = super.ccacheStdenv; };
linuxPackages_cachyos = super.${namespace}.linuxPackages_cachyos.override { stdenv = super.ccacheStdenv; };
linuxPackages_cachyos-lto = super.${namespace}.linuxPackages_cachyos-lto.override { stdenv = clangCcacheStdenv; };
linuxPackages_cachyos-lto-full = super.${namespace}.linuxPackages_cachyos-lto-full.override { stdenv = clangCcacheStdenv; };
linuxPackages_cachyos-lts = super.${namespace}.linuxPackages_cachyos-lts.override { stdenv = super.ccacheStdenv; };
linuxPackages_cachyos-lts-lto = super.${namespace}.linuxPackages_cachyos-lts-lto.override { stdenv = clangCcacheStdenv; };
linuxPackages_cachyos-lto-znver4 = super.${namespace}.linuxPackages_cachyos-lto-znver4.override { stdenv = clangCcacheStdenv; };
linuxPackages_cachyos-server = super.${namespace}.linuxPackages_cachyos-server.override { stdenv = super.ccacheStdenv; };
linuxPackages_cachyos-server-lto = super.${namespace}.linuxPackages_cachyos-server-lto.override { stdenv = clangCcacheStdenv; };
linuxPackages_cachyos-server-lto-znver4 = super.${namespace}.linuxPackages_cachyos-server-lto-znver4.override { stdenv = clangCcacheStdenv; };
linuxPackages_cachyos-rc = super.${namespace}.linuxPackages_cachyos-rc.override { stdenv = super.ccacheStdenv; };
linuxPackages_cachyos-rc-lto = super.${namespace}.linuxPackages_cachyos-rc-lto.override { stdenv = clangCcacheStdenv; };
linuxPackages_cachyos-rc-lto-znver4 = super.${namespace}.linuxPackages_cachyos-rc-lto-znver4.override { stdenv = clangCcacheStdenv; };
linuxPackages_cachyos-hardened = super.${namespace}.linuxPackages_cachyos-hardened.override { stdenv = super.ccacheStdenv; };
linuxPackages_cachyos-hardened-lto = super.${namespace}.linuxPackages_cachyos-hardened-lto.override { stdenv = clangCcacheStdenv; };
linuxPackages_cachyos-hardened-lto-znver4 = super.${namespace}.linuxPackages_cachyos-hardened-lto-znver4.override { stdenv = clangCcacheStdenv; };
linuxPackages_cachyos-deckify = super.${namespace}.linuxPackages_cachyos-deckify.override { stdenv = super.ccacheStdenv; };
linuxPackages_cachyos-deckify-lto = super.${namespace}.linuxPackages_cachyos-deckify-lto.override { stdenv = clangCcacheStdenv; };
linuxPackages_cachyos = super.${namespace}.linuxPackages_cachyos.override {
stdenv = super.ccacheStdenv;
};
linuxPackages_cachyos-lto = super.${namespace}.linuxPackages_cachyos-lto.override {
stdenv = clangCcacheStdenv;
};
linuxPackages_cachyos-lto-full = super.${namespace}.linuxPackages_cachyos-lto-full.override {
stdenv = clangCcacheStdenv;
};
linuxPackages_cachyos-lts = super.${namespace}.linuxPackages_cachyos-lts.override {
stdenv = super.ccacheStdenv;
};
linuxPackages_cachyos-lts-lto = super.${namespace}.linuxPackages_cachyos-lts-lto.override {
stdenv = clangCcacheStdenv;
};
linuxPackages_cachyos-lto-znver4 = super.${namespace}.linuxPackages_cachyos-lto-znver4.override {
stdenv = clangCcacheStdenv;
};
linuxPackages_cachyos-server = super.${namespace}.linuxPackages_cachyos-server.override {
stdenv = super.ccacheStdenv;
};
linuxPackages_cachyos-server-lto = super.${namespace}.linuxPackages_cachyos-server-lto.override {
stdenv = clangCcacheStdenv;
};
linuxPackages_cachyos-server-lto-znver4 =
super.${namespace}.linuxPackages_cachyos-server-lto-znver4.override
{ stdenv = clangCcacheStdenv; };
linuxPackages_cachyos-rc = super.${namespace}.linuxPackages_cachyos-rc.override {
stdenv = super.ccacheStdenv;
};
linuxPackages_cachyos-rc-lto = super.${namespace}.linuxPackages_cachyos-rc-lto.override {
stdenv = clangCcacheStdenv;
};
linuxPackages_cachyos-rc-lto-znver4 =
super.${namespace}.linuxPackages_cachyos-rc-lto-znver4.override
{ stdenv = clangCcacheStdenv; };
linuxPackages_cachyos-hardened = super.${namespace}.linuxPackages_cachyos-hardened.override {
stdenv = super.ccacheStdenv;
};
linuxPackages_cachyos-hardened-lto =
super.${namespace}.linuxPackages_cachyos-hardened-lto.override
{ stdenv = clangCcacheStdenv; };
linuxPackages_cachyos-hardened-lto-znver4 =
super.${namespace}.linuxPackages_cachyos-hardened-lto-znver4.override
{ stdenv = clangCcacheStdenv; };
linuxPackages_cachyos-deckify = super.${namespace}.linuxPackages_cachyos-deckify.override {
stdenv = super.ccacheStdenv;
};
linuxPackages_cachyos-deckify-lto = super.${namespace}.linuxPackages_cachyos-deckify-lto.override {
stdenv = clangCcacheStdenv;
};
};
})
@@ -173,7 +213,7 @@ in
qt3d = super.kdePackages.qt3d.override {
qtbase = super.kdePackages.qtbase.override { stdenv = super.ccacheStdenv; };
};
qtwebengine = super.stable.kdePackages.qtwebengine; #.override { stdenv = super.ccacheStdenv; };
qtwebengine = super.stable.kdePackages.qtwebengine; # .override { stdenv = super.ccacheStdenv; };
};
})
# (_self: super: {

View File

@@ -9,10 +9,17 @@ with lib;
let
inherit (lib.${namespace}) mkOpt mkBoolOpt;
cfg = config.${namespace}.user // {
hashedPasswordFile = (if (config.${namespace}.user.hashedPassword == null &&
config.${namespace}.user.hashedPasswordFile == null &&
config.${namespace}.user.password == null) then
defaultPasswordFile else null
hashedPasswordFile = (
if
(
config.${namespace}.user.hashedPassword == null
&& config.${namespace}.user.hashedPasswordFile == null
&& config.${namespace}.user.password == null
)
then
defaultPasswordFile
else
config.${namespace}.user.hashedPasswordFile
);
};

View File

@@ -1,4 +1,9 @@
{ inputs, self, namespace, ... }:
{
inputs,
self,
namespace,
...
}:
final: prev:
let

View File

@@ -69,11 +69,6 @@ let
description = "Linux EEVDF-BORE scheduler Kernel by CachyOS built with LLVM and Thin LTO";
};
ltoFullKernelAttrs = ltoKernelAttrs // {
configPath = ./config-nix/cachyos-lto.x86_64-linux.nix;
useLTO = "full";
};
serverLtoKernelAttrs = ltoKernelAttrs // {
taste = "linux-cachyos-server";
pname = "cachyos-server-lto";
@@ -211,39 +206,58 @@ in
cachyos-gcc = mkCachyKernel gccKernelAttrs;
# GCC LTS
cachyos-lts = mkCachyKernel (gccKernelAttrs // ltsAttrs // {
cachyos-lts = mkCachyKernel (
gccKernelAttrs
// ltsAttrs
// {
taste = "linux-cachyos-lts";
pname = "cachyos-lts";
configPath = ./config-nix/${arch}-linux/cachyos-lts.${arch}-linux.nix;
});
}
);
# GCC RC
cachyos-rc = mkCachyKernel (gccKernelAttrs // rcAttrs // {
cachyos-rc = mkCachyKernel (
gccKernelAttrs
// rcAttrs
// {
taste = "linux-cachyos-rc";
pname = "cachyos-rc";
configPath = ./config-nix/${arch}-linux/cachyos-rc.${arch}-linux.nix;
});
}
);
# Server GCC
cachyos-server = mkCachyKernel (gccKernelAttrs // serverAttrs // {
cachyos-server = mkCachyKernel (
gccKernelAttrs
// serverAttrs
// {
taste = "linux-cachyos-server";
pname = "cachyos-server";
configPath = ./config-nix/${arch}-linux/cachyos-server.${arch}-linux.nix;
});
}
);
# Hardened GCC
cachyos-hardened = mkCachyKernel (gccKernelAttrs // hardenedAttrs // {
cachyos-hardened = mkCachyKernel (
gccKernelAttrs
// hardenedAttrs
// {
taste = "linux-cachyos-hardened";
pname = "cachyos-hardened";
configPath = ./config-nix/${arch}-linux/cachyos-hardened.${arch}-linux.nix;
});
}
);
# Deckify GCC
cachyos-deckify = mkCachyKernel (gccKernelAttrs // {
cachyos-deckify = mkCachyKernel (
gccKernelAttrs
// {
taste = "linux-cachyos-deckify";
pname = "cachyos-deckify";
configPath = ./config-nix/${arch}-linux/cachyos-deckify.${arch}-linux.nix;
});
}
);
# ######################################################
# LTO Kernels #
@@ -253,10 +267,13 @@ in
cachyos-lto = mkCachyKernel ltoKernelAttrs;
# LTO Full
cachyos-lto-full = mkCachyKernel (ltoKernelAttrs // {
cachyos-lto-full = mkCachyKernel (
ltoKernelAttrs
// {
configPath = ./config-nix/cachyos-lto.x86_64-linux.nix;
useLTO = "full";
});
}
);
# LTO Zen Version 4
cachyos-lto-znver4 = mkCachyKernel (
@@ -270,7 +287,8 @@ in
# LTS LTO
cachyos-lts-lto = mkCachyKernel (
ltoKernelAttrs
// ltsAttrs // {
// ltsAttrs
// {
taste = "linux-cachyos-lts";
pname = "cachyos-lts-lto";
configPath = ./config-nix/${arch}-linux/cachyos-lts-lto.${arch}-linux.nix;
@@ -280,7 +298,8 @@ in
# Hardened LTO
cachyos-hardened-lto = mkCachyKernel (
ltoKernelAttrs
// hardenedAttrs // {
// hardenedAttrs
// {
taste = "linux-cachyos-hardened";
pname = "cachyos-hardened-lto";
configPath = ./config-nix/${arch}-linux/cachyos-hardened-lto.${arch}-linux.nix;
@@ -290,7 +309,8 @@ in
# RC LTO
cachyos-rc-lto = mkCachyKernel (
ltoKernelAttrs
// rcAttrs // {
// rcAttrs
// {
taste = "linux-cachyos-rc";
pname = "cachyos-rc-lto";
configPath = ./config-nix/${arch}-linux/cachyos-rc-lto.${arch}-linux.nix;
@@ -300,7 +320,8 @@ in
# RC LTO Zen Version 4
cachyos-rc-lto-znver4 = mkCachyKernel (
ltoKernelAttrs
// rcAttrs // {
// rcAttrs
// {
taste = "linux-cachyos-rc";
pname = "cachyos-rc-lto-znver4";
configPath = ./config-nix/${arch}-linux/cachyos-rc-lto-znver4.${arch}-linux.nix;
@@ -308,11 +329,15 @@ in
);
# Server LTO
cachyos-server-lto = mkCachyKernel (ltoKernelAttrs // serverAttrs // {
cachyos-server-lto = mkCachyKernel (
ltoKernelAttrs
// serverAttrs
// {
taste = "linux-cachyos-server";
pname = "cachyos-server-lto";
configPath = ./config-nix/${arch}-linux/cachyos-server-lto.${arch}-linux.nix;
});
}
);
# Server LTO Zen Version 4
cachyos-server-lto-znver4 = mkCachyKernel (
@@ -324,10 +349,13 @@ in
);
# Deckify LTO
cachyos-deckify-lto = mkCachyKernel (ltoKernelAttrs // {
cachyos-deckify-lto = mkCachyKernel (
ltoKernelAttrs
// {
pname = "linux-cachyos-deckify-lto";
configPath = ./config-nix/${arch}-linux/cachyos-deckify-lto.${arch}-linux.nix;
});
}
);
# ######################################################
# Cachy ZFZ #

View File

@@ -344,7 +344,10 @@ stdenv.mkDerivation (finalAttrs: {
meta = ogKernelConfigfile.meta // {
# at the time of this writing, they don't have config files for aarch64
platforms = [ "x86_64-linux" "aarch64-linux" ];
platforms = [
"x86_64-linux"
"aarch64-linux"
];
};
passthru = {

View File

@@ -9,7 +9,6 @@
udev,
systemd,
withVoutDrm ? true,
stdenv ? null,
}:
let

View File

@@ -14,9 +14,9 @@ let
tag = "stable_20250916";
hash = "sha256-HG8Oc04V2t54l0SOn4gKmNJWQUrZfjWusgKcWvx74H0==";
# NOTE: raspberrypifw & raspberryPiWirelessFirmware should be updated with this
# modDirVersion = "6.18.1";
# tag = "unstable_20251226";
# hash = "sha256-VYrXqwK9P2nWkm3DhOU8qaXzWv5L0DUoJ2MBRF6PoEE=";
# modDirVersion = "6.18.1";
# tag = "unstable_20251226";
# hash = "sha256-VYrXqwK9P2nWkm3DhOU8qaXzWv5L0DUoJ2MBRF6PoEE=";
in
lib.overrideDerivation
(buildLinux (
@@ -70,7 +70,7 @@ lib.overrideDerivation
}
// (args.argsOverride or { })
))
(oldAttrs: {
(_oldAttrs: {
postConfigure = ''
# The v7 defconfig has this set to '-v7' which screws up our modDirVersion.
sed -i $buildRoot/.config -e 's/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=""/'

View File

@@ -8,7 +8,7 @@ stdenvNoCC.mkDerivation rec {
pname = "uefi-rpi4";
version = "1.50";
src= fetchzip {
src = fetchzip {
url = "https://github.com/pftf/RPi4/releases/download/v${version}/RPi4_UEFI_Firmware_v${version}.zip";
stripRoot = false;
hash = "sha256-g8046/Ox0hZgvU6u3ZfC6HMqoTME0Y7NsZD6NvUsp7w=";

View File

@@ -1,37 +1,55 @@
{
lib,
stdenvNoCC,
fetchzip,
fetchurl,
}:
stdenvNoCC.mkDerivation rec {
pname = "uefi-rpi5";
version = "0.3";
version = "test1";
src= fetchzip {
url = "https://github.com/worproject/rpi5-uefi/releases/download/v${version}/RPi5_UEFI_Release_v${version}.zip";
stripRoot = false;
hash = "sha256-bjEvq7KlEFANnFVL0LyexXEeoXj7rHGnwQpq09PhIb0=";
src = fetchurl {
url = "https://github.com/NumberOneGit/rpi5-uefi/releases/download/${version}/RPI_EFI.fd";
hash = "sha256-GIgru10KCol9PXcdgR2d1BHf2In07OQ2P1kru7GUupY=";
};
sourceRoot = ".";
dontUnpack = true;
dontBuild = true;
# Firmware blobs do not need fixing and should not be modified
dontFixup = true;
installPhase = ''
runHook preInstall
mkdir -p "$out/firmware"
mkdir -p "$out"
cp -rv "${src}" "$out/firmware"
cp -rv "$src" "$out"
cat > "$out/config.txt" <<'EOF'
armstub=RPI_EFI.fd
device_tree_address=0x3e0000
device_tree_end=0x400000
# Force 32 bpp framebuffer allocation.
framebuffer_depth=32
# Disable compensation for displays with overscan.
disable_overscan=1
# Force maximum USB power regardless of the power supply.
usb_max_current_enable=1
# Force maximum CPU speed.
force_turbo=1
EOF
runHook postInstall
'';
meta = with lib; {
description = "RPI5 UEFI firmware";
homepage = "https://github.com/pftf/RPi4";
homepage = "https://github.com/NumberOneGit/rpi5-uefi";
platforms = platforms.linux;
maintainers = with maintainers; [ ];
};

View File

@@ -1,33 +1,18 @@
{
stdenv,
lib,
bc,
bison,
dtc,
fetchFromGitHub,
fetchpatch,
fetchurl,
flex,
gnutls,
installShellFiles,
libuuid,
meson-tools,
ncurses,
openssl,
rkbin,
swig,
which,
python3,
perl,
armTrustedFirmwareAllwinner,
armTrustedFirmwareAllwinnerH6,
armTrustedFirmwareAllwinnerH616,
armTrustedFirmwareRK3328,
armTrustedFirmwareRK3399,
armTrustedFirmwareRK3568,
armTrustedFirmwareRK3588,
armTrustedFirmwareS905,
opensbi,
buildPackages,
callPackages,
darwin,
@@ -57,7 +42,6 @@ let
pythonScriptsToInstall ? { },
installDir ? "$out",
defconfig,
extraConfig ? "",
extraPatches ? [ ],
extraMakeFlags ? [ ],
extraMeta ? { },

View File

@@ -1,4 +1,6 @@
{ pkgs ? import <nixpkgs> {} }:
{
pkgs ? import <nixpkgs> { },
}:
pkgs.writeShellApplication {
name = "test-image";

View File

@@ -4,9 +4,6 @@
namespace,
...
}:
let
# kernelBundle = pkgs.linuxAndFirmware.latest;
in
{
boot = {
# loader.raspberry-pi = {

View File

@@ -1,38 +1,43 @@
{ pkgs, lib, namespace, ... }:
let
# kernelBundle = pkgs.linuxAndFirmware.latest;
in
{
pkgs,
lib,
namespace,
...
}:
{
boot = {
# loader.raspberry-pi = {
# bootloader = "kernel";
# firmwarePackage = pkgs.raspberrypifw;
# };
kernelPackages = pkgs.${namespace}.linuxPackages_rpi5;
kernelPackages = pkgs.linuxPackages_latest;
supportedFilesystems = lib.mkForce [ ];
};
${namespace}.hardware.raspberry-pi.config = {
# extra-config = {
# armstub = "RPI_EFI.fd";
# };
all = {
# [all] conditional filter, https://www.raspberrypi.com/documentation/computers/config_txt.html#conditional-filters
# # [all] conditional filter, https://www.raspberrypi.com/documentation/computers/config_txt.html#conditional-filters
options = {
# https://www.raspberrypi.com/documentation/computers/config_txt.html#enable_uart
# in conjunction with `console=serial0,115200` in kernel command line (`cmdline.txt`)
# creates a serial console, accessible using GPIOs 14 and 15 (pins
# 8 and 10 on the 40-pin header)
enable_uart = {
enable = true;
value = true;
};
# https://www.raspberrypi.com/documentation/computers/config_txt.html#uart_2ndstage
# enable debug logging to the UART, also automatically enables
# UART logging in `start.elf`
uart_2ndstage = {
enable = true;
value = true;
};
};
# options = {
# # https://www.raspberrypi.com/documentation/computers/config_txt.html#enable_uart
# # in conjunction with `console=serial0,115200` in kernel command line (`cmdline.txt`)
# # creates a serial console, accessible using GPIOs 14 and 15 (pins
# # 8 and 10 on the 40-pin header)
# enable_uart = {
# enable = true;
# value = true;
# };
# # https://www.raspberrypi.com/documentation/computers/config_txt.html#uart_2ndstage
# # enable debug logging to the UART, also automatically enables
# # UART logging in `start.elf`
# uart_2ndstage = {
# enable = true;
# value = true;
# };
# };
# Base DTB parameters
# https://github.com/raspberrypi/linux/blob/a1d3defcca200077e1e382fe049ca613d16efd2b/arch/arm/boot/dts/overlays/README#L132
@@ -52,6 +57,24 @@ in
};
# extra-config = ''
# armstub=RPI_EFI.fd
# device_tree_address=0x1f0000
# device_tree_end=0x210000
# # Force 32 bpp framebuffer allocation.
# framebuffer_depth=32
# # Disable compensation for displays with overscan.
# disable_overscan=1
# # Force maximum USB power regardless of the power supply.
# usb_max_current_enable=1
# # Force maximum CPU speed.
# force_turbo=1
# '';
};
};
}

View File

@@ -3,7 +3,6 @@
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
{
pkgs,
namespace,
...
}:
@@ -45,16 +44,20 @@
hardware = {
disko = {
enable = true;
enableFirmware = true;
firmware = {
enableFirmware = false;
firmwareDisk = "/dev/mmcblk0";
};
};
raspberry-pi = {
enable = true;
variant = "5";
pwm.enable = true;
disable-wifi.enable = true;
modesetting.enable = true;
i2c.enable = true;
apply-overlays-dtmerge.enable = true;
bootType = "kernel";
pwm.enable = false;
disable-wifi.enable = false;
modesetting.enable = false;
i2c.enable = false;
apply-overlays-dtmerge.enable = false;
};
};

View File

@@ -1,4 +1,9 @@
{ config, pkgs, namespace, ... }:
{
config,
pkgs,
namespace,
...
}:
let
kernel = pkgs.${namespace}.linuxPackages_cachyos-lto-znver4;
pkgsVersion = pkgs; # .unstable;

View File

@@ -77,20 +77,20 @@
# capabilities = "cap_net_admin+p";
# };
# specialisation = {
# specialisation = {
# "cosmic" = {
# enable = false;
# configuration = {
# ${namespace} = {
# desktop = {
# cosmic.enable = lib.mkForce true;
# hyprland = {
# enable = lib.mkForce false;
# };
# enable = false;
# configuration = {
# ${namespace} = {
# desktop = {
# cosmic.enable = lib.mkForce true;
# hyprland = {
# enable = lib.mkForce false;
# };
# gnome.enable = lib.mkForce false;
# };
# };
# };
# };
# };
# };
# };
# };
# };
}