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

@@ -1,4 +1,10 @@
{ config, lib, pkgs, namespace, ... }: {
config,
lib,
pkgs,
namespace,
...
}:
let let
cfg = config.${namespace}.hardware.raspberry-pi.audio; cfg = config.${namespace}.hardware.raspberry-pi.audio;
variant = config.${namespace}.hardware.raspberry-pi.variant; variant = config.${namespace}.hardware.raspberry-pi.variant;
@@ -11,11 +17,15 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
hardware.deviceTree = { hardware.deviceTree = {
overlays = overlays =
[ ] ++ (if (variant == "5") then [ ]
++ (
if (variant == "5") then
[ [
{ {
name = "pisound-pi5-overlay"; 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 else
@@ -24,7 +34,8 @@ in
name = "pisound-overlay"; name = "pisound-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/pisound-overlay.dts"; 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 let
cfg = config.${namespace}.hardware.raspberry-pi.disable-bluetooth; cfg = config.${namespace}.hardware.raspberry-pi.disable-bluetooth;
variant = config.${namespace}.hardware.raspberry-pi.variant; variant = config.${namespace}.hardware.raspberry-pi.variant;
@@ -11,20 +17,27 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
hardware.deviceTree = { hardware.deviceTree = {
overlays = overlays =
[ ] ++ (if (variant == "5") then [ ]
++ (
if (variant == "5") then
[ [
{ {
name = "disable-bt-pi5-overlay"; 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 else
[ [
{ {
name = "disable-bt-overlay"; 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 # with modifications
# https://raw.githubusercontent.com/nvmd/raspberry-pi-nix/refs/heads/master/rpi/config.nix # https://raw.githubusercontent.com/nvmd/raspberry-pi-nix/refs/heads/master/rpi/config.nix
{ lib, config, pkgs, namespace, ... }: {
lib,
config,
namespace,
...
}:
let let
cfg = config.${namespace}.hardware.raspberry-pi; cfg = config.${namespace}.hardware.raspberry-pi;
render-raspberrypi-config = let render-raspberrypi-config =
let
render-kvs = kvs: let render-kvs =
render-kv = k: v: kvs:
if isNull v.value then k let
else "${k}=${toString v.value}"; render-kv = k: v: if isNull v.value then k else "${k}=${toString v.value}";
in lib.attrsets.mapAttrsToList render-kv in
(lib.filterAttrs (k: v: v.enable) kvs); lib.attrsets.mapAttrsToList render-kv (lib.filterAttrs (_k: v: v.enable) kvs);
render-dt-param = x: "dtparam=" + x; render-dt-param = x: "dtparam=" + x;
render-dt-params = params: render-dt-params = params: lib.strings.concatMapStringsSep "\n" render-dt-param (render-kvs params);
lib.strings.concatMapStringsSep "\n" render-dt-param (render-kvs params);
render-dt-overlay = { overlay, params }: render-dt-overlay =
lib.concatStringsSep "\n" (lib.filter (x: x != "") [ { overlay, params }:
lib.concatStringsSep "\n" (
lib.filter (x: x != "") [
("dtoverlay=" + overlay) ("dtoverlay=" + overlay)
(render-dt-params params) (render-dt-params params)
"dtoverlay=" "dtoverlay="
]); ]
);
render-options = opts: render-options = opts: lib.strings.concatStringsSep "\n" (render-kvs opts);
lib.strings.concatStringsSep "\n" (render-kvs opts);
render-base-dt-params = render-dt-params; render-base-dt-params = render-dt-params;
render-dt-overlays = overlays: render-dt-overlays =
lib.strings.concatMapStringsSep "\n" render-dt-overlay overlays:
(lib.attrsets.mapAttrsToList lib.strings.concatMapStringsSep "\n" render-dt-overlay (
(overlay: params: { lib.attrsets.mapAttrsToList (overlay: params: {
inherit overlay; inherit overlay;
inherit (params) params; inherit (params) params;
}) }) (lib.filterAttrs (_k: v: v.enable) overlays)
(lib.filterAttrs (k: v: v.enable) overlays)); );
render-config-section = conditionalFilter: render-config-section =
{ options, base-dt-params, dt-overlays }: conditionalFilter:
let all-config = lib.concatStringsSep "\n" (lib.filter (x: x != "") [ {
options,
base-dt-params,
dt-overlays,
}:
let
all-config = lib.concatStringsSep "\n" (
lib.filter (x: x != "") [
(render-options options) (render-options options)
(render-base-dt-params base-dt-params) (render-base-dt-params base-dt-params)
(render-dt-overlays dt-overlays) (render-dt-overlays dt-overlays)
]); ]
in '' );
in
''
[${conditionalFilter}] [${conditionalFilter}]
${all-config} ${all-config}
''; '';
in conf: lib.strings.concatStringsSep "\n" in
((lib.attrsets.mapAttrsToList render-config-section conf) conf:
++ [ cfg.extra-config ]); lib.strings.concatStringsSep "\n" (
in { (lib.attrsets.mapAttrsToList render-config-section conf) ++ [ cfg.extra-config ]
);
in
{
options.${namespace}.hardware.raspberry-pi = { options.${namespace}.hardware.raspberry-pi = {
config = let config =
let
rpi-config-param = { rpi-config-param = {
options = { options = {
enable = lib.mkEnableOption "attr"; enable = lib.mkEnableOption "attr";
value = lib.mkOption { 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 = { options = {
enable = lib.mkEnableOption "attr"; enable = lib.mkEnableOption "attr";
value = lib.mkOption { value = lib.mkOption {
type = with lib.types; nullOr (oneOf [ int str bool ]); type =
with lib.types;
nullOr (oneOf [
int
str
bool
]);
default = null; default = null;
}; };
}; };
@@ -96,7 +128,8 @@ in {
<https://www.raspberrypi.com/documentation/computers/config_txt.html#common-hardware-configuration-options> <https://www.raspberrypi.com/documentation/computers/config_txt.html#common-hardware-configuration-options>
''; '';
example = { example = {
arm_boost = { # arm_boost=1 arm_boost = {
# arm_boost=1
enable = true; enable = true;
value = true; value = true;
}; };
@@ -111,11 +144,13 @@ in {
<https://www.raspberrypi.com/documentation/computers/configuration.html#part3.2> <https://www.raspberrypi.com/documentation/computers/configuration.html#part3.2>
''; '';
example = { example = {
i2c = { # dtparam=i2c=on i2c = {
# dtparam=i2c=on
enable = true; enable = true;
value = "on"; value = "on";
}; };
ant2 = { # dtparam=ant2 ant2 = {
# dtparam=ant2
enable = true; enable = true;
}; };
}; };
@@ -134,7 +169,8 @@ in {
<https://www.raspberrypi.com/documentation/computers/configuration.html#part3.1> <https://www.raspberrypi.com/documentation/computers/configuration.html#part3.1>
''; '';
example = { example = {
vc4-kms-v3d = { # dtoverlay=vc4-kms-v3d,cma-256 vc4-kms-v3d = {
# dtoverlay=vc4-kms-v3d,cma-256
enable = true; enable = true;
params = { params = {
cma-256 = { cma-256 = {
@@ -143,14 +179,16 @@ in {
}; };
}; };
}; };
disable-bt = { # dtoverlay=disable-bt disable-bt = {
# dtoverlay=disable-bt
enable = true; enable = true;
}; };
}; };
}; };
}; };
}; };
in lib.mkOption { in
lib.mkOption {
type = with lib.types; attrsOf (submodule raspberry-pi-config-options); type = with lib.types; attrsOf (submodule raspberry-pi-config-options);
description = '' description = ''
Configures `config.txt` file for Raspberry Pi devices. 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 # installs raspberry's firmware independent of the nixos generations
# sometimes referred to as "boot code" # sometimes referred to as "boot code"
raspberryPiFirmware = ({ pkgs raspberryPiFirmware = ({ pkgs
@@ -50,9 +32,45 @@ let
}; };
}); });
# Builders used to write during system activation kernelbootGenBuilder = ({ pkgs
firmwareBuilder = import ./firmware-builder.nix { , 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 pkgs;
inherit (cfg) nixosGenerationsDir;
firmwareInstaller = "${raspberryPiFirmware {
inherit pkgs;
firmware = pkgs.${namespace}.raspberrypifw;
configTxt = pkgs.writeTextFile { configTxt = pkgs.writeTextFile {
name = "config.txt"; name = "config.txt";
text = '' text = ''
@@ -64,19 +82,73 @@ let
${config.${namespace}.hardware.raspberry-pi.config-generated} ${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 { ubootBuilder = import ./uboot-builder.nix {
inherit pkgs; 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; firmwareBuilder = firmwarePopulateCmd;
extlinuxConfBuilder = config.boot.loader.generic-extlinux-compatible.populateCmd; extlinuxConfBuilder = config.boot.loader.generic-extlinux-compatible.populateCmd;
}; };
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;
firmwareBuilder = firmwarePopulateCmd;
};
uefiBuilder = import ./uefi-builder.nix { uefiBuilder = import ./uefi-builder.nix {
inherit pkgs; inherit pkgs;
uefiPackage = (if (cfg.variant == "5") then pkgs.${namespace}.uefi-rpi5 else pkgs.${namespace}.uefi-rpi4); uefiPackage = (
if (cfg.variant == "5") then pkgs.${namespace}.uefi-rpi5 else pkgs.${namespace}.uefi-rpi4
);
firmwareBuilder = firmwarePopulateCmd; firmwareBuilder = firmwarePopulateCmd;
}; };
@@ -97,12 +169,9 @@ let
firmware = pkgs.${namespace}.raspberrypifw; firmware = pkgs.${namespace}.raspberrypifw;
}; };
populateUbootBuilder = import ./uboot-builder.nix { populateKernelbootBuilder = import ./kernelboot-builder.nix {
inherit ubootBinName;
pkgs = pkgs.buildPackages; pkgs = pkgs.buildPackages;
ubootPackage = (if (cfg.variant == "5") then pkgs.${namespace}.uboot-pi5 else pkgs.${namespace}.uboot-pi4);
firmwareBuilder = firmwarePopulateCmd; firmwareBuilder = firmwarePopulateCmd;
extlinuxConfBuilder = config.boot.loader.generic-extlinux-compatible.populateCmd;
}; };
firmwarePopulateCmd = "${populateFirmwareBuilder} ${firmwareBuilderArgs}"; firmwarePopulateCmd = "${populateFirmwareBuilder} ${firmwareBuilderArgs}";
@@ -114,6 +183,12 @@ let
# system.build.installBootLoader # system.build.installBootLoader
uboot = "${ubootBuilder} -f /boot/firmware -b /boot -c"; uboot = "${ubootBuilder} -f /boot/firmware -b /boot -c";
uefi = "${uefiBuilder} -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>` # firmware: caller must provide `-c <nixos configuration>` and `-f <firmware target path>`
@@ -123,6 +198,14 @@ let
firmware = "${populateUbootBuilder}"; firmware = "${populateUbootBuilder}";
boot = "${populateUbootBuilder}"; boot = "${populateUbootBuilder}";
}; };
kernel = let cmd = builtins.concatStringsSep " " [
"${mkBootloader pkgs.buildPackages}"
"-g ${toString cfg.configurationLimit}"
];
in {
firmware = "${cmd}";
boot = "${cmd}";
};
}; };
in in
{ {
@@ -141,6 +224,7 @@ in
type = lib.types.enum [ type = lib.types.enum [
"uefi" "uefi"
"uboot" "uboot"
"kernel"
]; ];
default = "uefi"; default = "uefi";
}; };
@@ -172,23 +256,31 @@ in
initrd.availableKernelModules = [ initrd.availableKernelModules = [
"usbhid" "usbhid"
"usb-storage" "usb-storage"
] ++ (if (cfg.variant == "5") then [ ]
++ (
if (cfg.variant == "5") then
[
"nvme" "nvme"
] else ]
else
[ [
"vc4" "vc4"
"pcie-brcmstb" # required for the pcie bus to work "pcie-brcmstb" # required for the pcie bus to work
"reset-raspberrypi" # required for vl805 firmware to load "reset-raspberrypi" # required for vl805 firmware to load
]); ]
);
loader = { loader = {
# kernelFile = pkgs.stdenv.hostPlatform.linux-kernel.target;
generic-extlinux-compatible = { generic-extlinux-compatible = {
enable = lib.mkDefault (if cfg.bootType == "uefi" then false else true); enable = lib.mkDefault (if cfg.bootType == "uefi" then false else true);
useGenerationDeviceTree = lib.mkOverride 60 (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.enable = (if cfg.bootType == "uefi" then true else false);
systemd-boot.extraInstallCommands = let systemd-boot.extraInstallCommands =
bootloaderInstaller = (if cfg.bootType == "uefi" then (builder."uefi") else (builder."uboot")); # todo let
in '' bootloaderInstaller = (builder."${cfg.bootType}");
in
''
${bootloaderInstaller} -f /boot/firmware -b /boot -c ${bootloaderInstaller} -f /boot/firmware -b /boot -c
''; '';
grub.enable = lib.mkForce false; 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 # Common hardware settings
hardware = { hardware = {
deviceTree = { deviceTree = {
filter = lib.mkDefault (if (cfg.variant == "5") then "bcm2712-rpi-*.dtb" else "bcm2711-rpi-*.dtb"); 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"; name = "rpi4-cpu-revision";
dtsText = '' dtsText = ''
@@ -267,13 +386,15 @@ in
# }; # };
# ''; # '';
# } # }
] else ]
else
[ [
{ # {
name = "bcm2712d0-overlay"; # name = "bcm2712d0-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/bcm2712d0-overlay.dts"; # dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/bcm2712d0-overlay.dts";
} # }
]); ]
);
}; };
firmware = [ pkgs.${namespace}.raspberryPiWirelessFirmware ]; firmware = [ pkgs.${namespace}.raspberryPiWirelessFirmware ];
graphics.enable32Bit = lib.mkForce false; graphics.enable32Bit = lib.mkForce false;
@@ -316,10 +437,12 @@ in
udev.packages = [ udev.packages = [
pkgs.${namespace}.udev-rules pkgs.${namespace}.udev-rules
]; ];
xserver.extraConfig = let xserver.extraConfig =
let
identifier = "rp1"; identifier = "rp1";
driver = "rp1-vec|rp1-dsi|rp1-dpi"; driver = "rp1-vec|rp1-dsi|rp1-dpi";
in '' in
''
Section "OutputClass" Section "OutputClass"
Identifier "${identifier}" Identifier "${identifier}"
MatchDriver "${driver}" MatchDriver "${driver}"
@@ -329,20 +452,29 @@ in
''; '';
}; };
nixpkgs.overlays = [ ] ++ (if cfg.variant == "5" then [ nixpkgs.overlays =
(final: prev: { [ ]
++ (
if cfg.variant == "5" then
[
(_final: prev: {
# https://github.com/nvmd/nixos-raspberrypi/issues/64 # https://github.com/nvmd/nixos-raspberrypi/issues/64
# credit for the initial version of this snippet goes to @micahcc # credit for the initial version of this snippet goes to @micahcc
jemalloc = prev.jemalloc.overrideAttrs (old: { jemalloc = prev.jemalloc.overrideAttrs (old: {
# --with-lg-page=(log2 page_size) # --with-lg-page=(log2 page_size)
# RPi5 (bcm2712): since our page size is 16384 (2**14), we need 14 # RPi5 (bcm2712): since our page size is 16384 (2**14), we need 14
configureFlags = let configureFlags =
let
pageSizeFlag = "--with-lg-page"; 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" ]; ++ [ "${pageSizeFlag}=14" ];
}); });
}) })
] else [ ]) ]
else
[ ]
)
++ (if cfg.apply-overlays-dtmerge.enable then [ dt_ao_overlay ] else [ ]); ++ (if cfg.apply-overlays-dtmerge.enable then [ dt_ao_overlay ] else [ ]);
}; };
} }

View File

@@ -1,6 +1,7 @@
{ pkgs {
, configTxt pkgs,
, firmware ? pkgs.raspberrypifw configTxt,
firmware ? pkgs.raspberrypifw,
}: }:
pkgs.replaceVarsWith { 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 let
cfg = config.${namespace}.hardware.raspberry-pi.i2c; cfg = config.${namespace}.hardware.raspberry-pi.i2c;
variant = config.${namespace}.hardware.raspberry-pi.variant; variant = config.${namespace}.hardware.raspberry-pi.variant;
@@ -10,23 +16,32 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
hardware.deviceTree = { hardware.deviceTree = {
overlays = (if (variant == "5") then overlays = (
if (variant == "5") then
[ [
{ {
name = "i2c0-pi5-overlay"; 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"; 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"; 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"; 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 else
@@ -55,7 +70,8 @@ in
name = "i2c6-overlay"; name = "i2c6-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c6-overlay.dts"; 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 let
cfg = config.${namespace}.hardware.raspberry-pi.leds; cfg = config.${namespace}.hardware.raspberry-pi.leds;

View File

@@ -1,4 +1,10 @@
{ config, lib, pkgs, namespace, ... }: {
config,
lib,
pkgs,
namespace,
...
}:
let let
cfg = config.${namespace}.hardware.raspberry-pi.modesetting; cfg = config.${namespace}.hardware.raspberry-pi.modesetting;
variant = config.${namespace}.hardware.raspberry-pi.variant; variant = config.${namespace}.hardware.raspberry-pi.variant;
@@ -11,25 +17,27 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
hardware.deviceTree = { hardware.deviceTree = {
overlays = overlays =
[ [ ]
{ ++ (
name = "vc4-fkms-v3d-pi4-overlay"; if (variant == "5") then
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/vc4-fkms-v3d-pi4-overlay.dts";
}
] ++ (if (variant == "5") then
[ [
{ {
name = "vc4-kms-v3d-pi5-overlay"; 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 else
[ [
{ {
name = "vc4-kms-v3d-pi4-overlay"; name = "vc4-fkms-v3d-pi4-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/vc4-kms-v3d-pi4-overlay.dts"; 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 let
cfg = config.${namespace}.hardware.raspberry-pi.pwm; cfg = config.${namespace}.hardware.raspberry-pi.pwm;
variant = config.${namespace}.hardware.raspberry-pi.variant; variant = config.${namespace}.hardware.raspberry-pi.variant;
@@ -15,9 +21,10 @@ in
name = "enable-pwm"; name = "enable-pwm";
filter = (if (variant == "5") then "*pi5*" else "*rpi-4-b*"); filter = (if (variant == "5") then "*pi5*" else "*rpi-4-b*");
dtsFile = ( dtsFile = (
if (variant == "5") if (variant == "5") then
then "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/pwm-pio-overlay.dts" "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/pwm-pio-overlay.dts"
else "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/pwm1-overlay.dts" else
"${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/pwm1-overlay.dts"
); );
} }
]; ];

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,13 +1,9 @@
{ {
config, config,
lib, lib,
pkgs,
namespace, namespace,
... ...
}: }:
let
gpuTargets = [ "gfx1102" ]; # todo update when support is added gfx1150
in
{ {
programs.ccache = { programs.ccache = {
enable = true; enable = true;
@@ -61,37 +57,81 @@ in
(_self: super: { (_self: super: {
${namespace} = ${namespace} =
let let
clangCcacheStdenv = super.overrideCC super.llvmPackages.stdenv (super.ccacheWrapper.override { clangCcacheStdenv = super.overrideCC super.llvmPackages.stdenv (
super.ccacheWrapper.override {
cc = super.llvmPackages.stdenv.cc; cc = super.llvmPackages.stdenv.cc;
extraConfig = '' extraConfig = ''
export CCACHE_SLOPPINESS=include_file_ctime,time_macros export CCACHE_SLOPPINESS=include_file_ctime,time_macros
export CCACHE_DIR=/var/cache/ccache export CCACHE_DIR=/var/cache/ccache
''; '';
}); }
);
in in
super.${namespace} // { 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; }); 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; }; libraspberrypi = super.${namespace}.libraspberrypi.override { stdenv = super.ccacheStdenv; };
raspberrypi-utils = super.${namespace}.raspberrypi-utils.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 = super.${namespace}.linuxPackages_cachyos.override {
linuxPackages_cachyos-lto = super.${namespace}.linuxPackages_cachyos-lto.override { stdenv = clangCcacheStdenv; }; stdenv = super.ccacheStdenv;
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-lto = super.${namespace}.linuxPackages_cachyos-lto.override {
linuxPackages_cachyos-lts-lto = super.${namespace}.linuxPackages_cachyos-lts-lto.override { stdenv = clangCcacheStdenv; }; 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-lto-full = super.${namespace}.linuxPackages_cachyos-lto-full.override {
linuxPackages_cachyos-server-lto = super.${namespace}.linuxPackages_cachyos-server-lto.override { stdenv = clangCcacheStdenv; }; 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-lts = super.${namespace}.linuxPackages_cachyos-lts.override {
linuxPackages_cachyos-rc-lto = super.${namespace}.linuxPackages_cachyos-rc-lto.override { stdenv = clangCcacheStdenv; }; stdenv = super.ccacheStdenv;
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-lts-lto = super.${namespace}.linuxPackages_cachyos-lts-lto.override {
linuxPackages_cachyos-hardened-lto = super.${namespace}.linuxPackages_cachyos-hardened-lto.override { stdenv = clangCcacheStdenv; }; 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-lto-znver4 = super.${namespace}.linuxPackages_cachyos-lto-znver4.override {
linuxPackages_cachyos-deckify-lto = super.${namespace}.linuxPackages_cachyos-deckify-lto.override { stdenv = clangCcacheStdenv; }; 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;
};
}; };
}) })

View File

@@ -9,10 +9,17 @@ with lib;
let let
inherit (lib.${namespace}) mkOpt mkBoolOpt; inherit (lib.${namespace}) mkOpt mkBoolOpt;
cfg = config.${namespace}.user // { cfg = config.${namespace}.user // {
hashedPasswordFile = (if (config.${namespace}.user.hashedPassword == null && hashedPasswordFile = (
config.${namespace}.user.hashedPasswordFile == null && if
config.${namespace}.user.password == null) then (
defaultPasswordFile else null 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: final: prev:
let let

View File

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

View File

@@ -344,7 +344,10 @@ stdenv.mkDerivation (finalAttrs: {
meta = ogKernelConfigfile.meta // { meta = ogKernelConfigfile.meta // {
# at the time of this writing, they don't have config files for aarch64 # 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 = { passthru = {

View File

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

View File

@@ -70,7 +70,7 @@ lib.overrideDerivation
} }
// (args.argsOverride or { }) // (args.argsOverride or { })
)) ))
(oldAttrs: { (_oldAttrs: {
postConfigure = '' postConfigure = ''
# The v7 defconfig has this set to '-v7' which screws up our modDirVersion. # The v7 defconfig has this set to '-v7' which screws up our modDirVersion.
sed -i $buildRoot/.config -e 's/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=""/' sed -i $buildRoot/.config -e 's/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=""/'

View File

@@ -1,37 +1,55 @@
{ {
lib, lib,
stdenvNoCC, stdenvNoCC,
fetchzip, fetchurl,
}: }:
stdenvNoCC.mkDerivation rec { stdenvNoCC.mkDerivation rec {
pname = "uefi-rpi5"; pname = "uefi-rpi5";
version = "0.3"; version = "test1";
src= fetchzip { src = fetchurl {
url = "https://github.com/worproject/rpi5-uefi/releases/download/v${version}/RPi5_UEFI_Release_v${version}.zip"; url = "https://github.com/NumberOneGit/rpi5-uefi/releases/download/${version}/RPI_EFI.fd";
stripRoot = false; hash = "sha256-GIgru10KCol9PXcdgR2d1BHf2In07OQ2P1kru7GUupY=";
hash = "sha256-bjEvq7KlEFANnFVL0LyexXEeoXj7rHGnwQpq09PhIb0=";
}; };
sourceRoot = "."; sourceRoot = ".";
dontUnpack = true;
dontBuild = true; dontBuild = true;
# Firmware blobs do not need fixing and should not be modified # Firmware blobs do not need fixing and should not be modified
dontFixup = true; dontFixup = true;
installPhase = '' installPhase = ''
runHook preInstall 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 runHook postInstall
''; '';
meta = with lib; { meta = with lib; {
description = "RPI5 UEFI firmware"; description = "RPI5 UEFI firmware";
homepage = "https://github.com/pftf/RPi4"; homepage = "https://github.com/NumberOneGit/rpi5-uefi";
platforms = platforms.linux; platforms = platforms.linux;
maintainers = with maintainers; [ ]; maintainers = with maintainers; [ ];
}; };

View File

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

View File

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

View File

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

View File

@@ -1,38 +1,43 @@
{ pkgs, lib, namespace, ... }: {
let pkgs,
# kernelBundle = pkgs.linuxAndFirmware.latest; lib,
in namespace,
...
}:
{ {
boot = { boot = {
# loader.raspberry-pi = { # loader.raspberry-pi = {
# bootloader = "kernel"; # bootloader = "kernel";
# firmwarePackage = pkgs.raspberrypifw; # firmwarePackage = pkgs.raspberrypifw;
# }; # };
kernelPackages = pkgs.${namespace}.linuxPackages_rpi5; kernelPackages = pkgs.linuxPackages_latest;
supportedFilesystems = lib.mkForce [ ]; supportedFilesystems = lib.mkForce [ ];
}; };
${namespace}.hardware.raspberry-pi.config = { ${namespace}.hardware.raspberry-pi.config = {
# extra-config = {
# armstub = "RPI_EFI.fd";
# };
all = { 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 = { # options = {
# https://www.raspberrypi.com/documentation/computers/config_txt.html#enable_uart # # https://www.raspberrypi.com/documentation/computers/config_txt.html#enable_uart
# in conjunction with `console=serial0,115200` in kernel command line (`cmdline.txt`) # # in conjunction with `console=serial0,115200` in kernel command line (`cmdline.txt`)
# creates a serial console, accessible using GPIOs 14 and 15 (pins # # creates a serial console, accessible using GPIOs 14 and 15 (pins
# 8 and 10 on the 40-pin header) # # 8 and 10 on the 40-pin header)
enable_uart = { # enable_uart = {
enable = true; # enable = true;
value = true; # value = true;
}; # };
# https://www.raspberrypi.com/documentation/computers/config_txt.html#uart_2ndstage # # https://www.raspberrypi.com/documentation/computers/config_txt.html#uart_2ndstage
# enable debug logging to the UART, also automatically enables # # enable debug logging to the UART, also automatically enables
# UART logging in `start.elf` # # UART logging in `start.elf`
uart_2ndstage = { # uart_2ndstage = {
enable = true; # enable = true;
value = true; # value = true;
}; # };
}; # };
# Base DTB parameters # Base DTB parameters
# https://github.com/raspberrypi/linux/blob/a1d3defcca200077e1e382fe049ca613d16efd2b/arch/arm/boot/dts/overlays/README#L132 # 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`). # https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
{ {
pkgs,
namespace, namespace,
... ...
}: }:
@@ -45,16 +44,20 @@
hardware = { hardware = {
disko = { disko = {
enable = true; enable = true;
enableFirmware = true; firmware = {
enableFirmware = false;
firmwareDisk = "/dev/mmcblk0";
};
}; };
raspberry-pi = { raspberry-pi = {
enable = true; enable = true;
variant = "5"; variant = "5";
pwm.enable = true; bootType = "kernel";
disable-wifi.enable = true; pwm.enable = false;
modesetting.enable = true; disable-wifi.enable = false;
i2c.enable = true; modesetting.enable = false;
apply-overlays-dtmerge.enable = true; i2c.enable = false;
apply-overlays-dtmerge.enable = false;
}; };
}; };

View File

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