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 = { services = {
nextcloud-client.enable = false;#lib.mkDefault hasDestopEnvironment; nextcloud-client.enable = false; # lib.mkDefault hasDestopEnvironment;
pass-secret-service = lib.mkDefault enabled; pass-secret-service = lib.mkDefault enabled;
kdeconnect = { kdeconnect = {
enable = lib.mkDefault hasDestopEnvironment; enable = lib.mkDefault hasDestopEnvironment;

View File

@@ -64,4 +64,4 @@ with lib;
done''; done'';
} }
) )

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;
@@ -10,21 +16,26 @@ 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"; [
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/pisound-pi5-overlay.dts"; {
} name = "pisound-pi5-overlay";
] dtsFile = "${
else pkgs.${namespace}.raspberrypi-overlays
[ }/dtbs/raspberrypi-overlays/pisound-pi5-overlay.dts";
{ }
name = "pisound-overlay"; ]
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/pisound-overlay.dts"; else
} [
]); {
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 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;
@@ -10,21 +16,28 @@ 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"; [
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/disable-bt-pi5-overlay.dts"; {
} name = "disable-bt-pi5-overlay";
] dtsFile = "${
else pkgs.${namespace}.raspberrypi-overlays
[ }/dtbs/raspberrypi-overlays/disable-bt-pi5-overlay.dts";
{ }
name = "disable-bt-overlay"; ]
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/disable-bt-overlay.dts"; else
} [
]); {
name = "disable-bt-overlay";
dtsFile = "${
pkgs.${namespace}.raspberrypi-overlays
}/dtbs/raspberrypi-overlays/disable-bt-overlay.dts";
}
]
);
}; };
}; };
} }

View File

@@ -4,161 +4,199 @@
# 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 }:
("dtoverlay=" + overlay) lib.concatStringsSep "\n" (
(render-dt-params params) lib.filter (x: x != "") [
"dtoverlay=" ("dtoverlay=" + overlay)
]); (render-dt-params params)
"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 != "") [ {
(render-options options) options,
(render-base-dt-params base-dt-params) base-dt-params,
(render-dt-overlays dt-overlays) dt-overlays,
]); }:
in '' let
[${conditionalFilter}] all-config = lib.concatStringsSep "\n" (
${all-config} lib.filter (x: x != "") [
''; (render-options options)
in conf: lib.strings.concatStringsSep "\n" (render-base-dt-params base-dt-params)
((lib.attrsets.mapAttrsToList render-config-section conf) (render-dt-overlays dt-overlays)
++ [ cfg.extra-config ]); ]
in { );
in
''
[${conditionalFilter}]
${all-config}
'';
in
conf:
lib.strings.concatStringsSep "\n" (
(lib.attrsets.mapAttrsToList render-config-section conf) ++ [ cfg.extra-config ]
);
in
{
options.${namespace}.hardware.raspberry-pi = { options.${namespace}.hardware.raspberry-pi = {
config = let config =
rpi-config-param = { let
options = { rpi-config-param = {
enable = lib.mkEnableOption "attr"; options = {
value = lib.mkOption { enable = lib.mkEnableOption "attr";
type = with lib.types; oneOf [ int str bool ]; value = lib.mkOption {
}; type =
}; with lib.types;
}; oneOf [
dt-param = { int
options = { str
enable = lib.mkEnableOption "attr"; bool
value = lib.mkOption { ];
type = with lib.types; nullOr (oneOf [ int str bool ]);
default = null;
};
};
};
dt-overlay = {
options = {
enable = lib.mkEnableOption "overlay";
params = lib.mkOption {
type = with lib.types; attrsOf (submodule dt-param);
default = {};
};
};
};
raspberry-pi-config-options = {
options = {
options = lib.mkOption {
type = with lib.types; attrsOf (submodule rpi-config-param);
default = { };
description = ''
Common hardware configuration options, translates to
`<option>=<value>` in the `config.txt`.
<https://www.raspberrypi.com/documentation/computers/config_txt.html#common-hardware-configuration-options>
'';
example = {
arm_boost = { # arm_boost=1
enable = true;
value = true;
};
}; };
}; };
base-dt-params = lib.mkOption { };
type = with lib.types; attrsOf (submodule dt-param); dt-param = {
default = { }; options = {
description = '' enable = lib.mkEnableOption "attr";
Parameters to pass to the base DTB, translates to value = lib.mkOption {
`dtparam=<param>=<value>` in the `config.txt`. type =
<https://www.raspberrypi.com/documentation/computers/configuration.html#part3.2> with lib.types;
''; nullOr (oneOf [
example = { int
i2c = { # dtparam=i2c=on str
enable = true; bool
value = "on"; ]);
}; default = null;
ant2 = { # dtparam=ant2
enable = true;
};
}; };
}; };
dt-overlays = lib.mkOption { };
type = with lib.types; attrsOf (submodule dt-overlay); dt-overlay = {
default = { }; options = {
description = '' enable = lib.mkEnableOption "overlay";
DTB overlays to enable and configure with parameters, translates to params = lib.mkOption {
``` type = with lib.types; attrsOf (submodule dt-param);
dtoverlay=<overlay> default = { };
dtparam=<param>=<value> };
dtoverlay= };
```, which is an equivalent to a more popular format of };
`dtoverlay=<overlay>,<param>=<value>`. raspberry-pi-config-options = {
<https://www.raspberrypi.com/documentation/computers/configuration.html#part3.1> options = {
''; options = lib.mkOption {
example = { type = with lib.types; attrsOf (submodule rpi-config-param);
vc4-kms-v3d = { # dtoverlay=vc4-kms-v3d,cma-256 default = { };
enable = true; description = ''
params = { Common hardware configuration options, translates to
cma-256 = { `<option>=<value>` in the `config.txt`.
enable = true; <https://www.raspberrypi.com/documentation/computers/config_txt.html#common-hardware-configuration-options>
# value = ""; '';
}; example = {
arm_boost = {
# arm_boost=1
enable = true;
value = true;
}; };
}; };
disable-bt = { # dtoverlay=disable-bt };
enable = true; base-dt-params = lib.mkOption {
type = with lib.types; attrsOf (submodule dt-param);
default = { };
description = ''
Parameters to pass to the base DTB, translates to
`dtparam=<param>=<value>` in the `config.txt`.
<https://www.raspberrypi.com/documentation/computers/configuration.html#part3.2>
'';
example = {
i2c = {
# dtparam=i2c=on
enable = true;
value = "on";
};
ant2 = {
# dtparam=ant2
enable = true;
};
};
};
dt-overlays = lib.mkOption {
type = with lib.types; attrsOf (submodule dt-overlay);
default = { };
description = ''
DTB overlays to enable and configure with parameters, translates to
```
dtoverlay=<overlay>
dtparam=<param>=<value>
dtoverlay=
```, which is an equivalent to a more popular format of
`dtoverlay=<overlay>,<param>=<value>`.
<https://www.raspberrypi.com/documentation/computers/configuration.html#part3.1>
'';
example = {
vc4-kms-v3d = {
# dtoverlay=vc4-kms-v3d,cma-256
enable = true;
params = {
cma-256 = {
enable = true;
# value = "";
};
};
};
disable-bt = {
# dtoverlay=disable-bt
enable = true;
};
}; };
}; };
}; };
}; };
in
lib.mkOption {
type = with lib.types; attrsOf (submodule raspberry-pi-config-options);
description = ''
Configures `config.txt` file for Raspberry Pi devices.
The file is located on a firmware partition, usually mounted at
`/boot/firmware`.
<https://www.raspberrypi.com/documentation/computers/config_txt.html>
'';
}; };
in lib.mkOption {
type = with lib.types; attrsOf (submodule raspberry-pi-config-options);
description = ''
Configures `config.txt` file for Raspberry Pi devices.
The file is located on a firmware partition, usually mounted at
`/boot/firmware`.
<https://www.raspberrypi.com/documentation/computers/config_txt.html>
'';
};
extra-config = lib.mkOption { extra-config = lib.mkOption {
type = lib.types.lines; type = lib.types.lines;
@@ -181,4 +219,4 @@ in {
config = { config = {
${namespace}.hardware.raspberry-pi.config-generated = render-raspberrypi-config cfg.config; ${namespace}.hardware.raspberry-pi.config-generated = render-raspberrypi-config cfg.config;
}; };
} }

View File

@@ -12,24 +12,6 @@ let
applyOverlays = _final.callPackage ./apply-overlays-dtmerge.nix { }; applyOverlays = _final.callPackage ./apply-overlays-dtmerge.nix { };
}; };
}; };
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"
@@ -50,38 +32,128 @@ let
}; };
}); });
# Builders used to write during system activation kernelbootGenBuilder = ({ pkgs
firmwareBuilder = import ./firmware-builder.nix { , deviceTreeInstaller
inherit pkgs; }: pkgs.replaceVarsWith {
configTxt = pkgs.writeTextFile { src = ./generational/kernelboot-gen-builder.sh;
name = "config.txt"; isExecutable = true;
text = ''
# Do not edit! replacements = {
# This configuration file is generated from NixOS configuration inherit (pkgs) bash;
# options `hardware.raspberry-pi.config`. path = pkgs.lib.makeBinPath [
# Any manual changes will be overwritten on the next configuration pkgs.coreutils
# switch. ];
${config.${namespace}.hardware.raspberry-pi.config-generated}
''; installDeviceTree = deviceTreeInstaller;
}; };
firmware = pkgs.${namespace}.raspberrypifw; });
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 = ''
# Do not edit!
# This configuration file is generated from NixOS configuration
# options `hardware.raspberry-pi.config`.
# Any manual changes will be overwritten on the next configuration
# switch.
${config.${namespace}.hardware.raspberry-pi.config-generated}
'';
};
}}";
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;
}; };
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; 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; firmwareBuilder = firmwarePopulateCmd;
}; };
# Builders exposed via populateCmd, which run on the build architecture # Builders exposed via populateCmd, which run on the build architecture
populateFirmwareBuilder = import ./firmware-builder.nix { populateFirmwareBuilder = import ./firmware-builder.nix {
pkgs = pkgs.buildPackages; pkgs = pkgs.buildPackages;
configTxt = pkgs.writeTextFile { configTxt = pkgs.writeTextFile {
name = "config.txt"; name = "config.txt";
@@ -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,8 +183,14 @@ 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>`
# boot: caller must provide `-c <nixos configuration>` and `-b <boot-dir>` # boot: caller must provide `-c <nixos configuration>` and `-b <boot-dir>`
populateCmds = { populateCmds = {
@@ -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,10 +224,11 @@ in
type = lib.types.enum [ type = lib.types.enum [
"uefi" "uefi"
"uboot" "uboot"
"kernel"
]; ];
default = "uefi"; default = "uefi";
}; };
apply-overlays-dtmerge = { apply-overlays-dtmerge = {
enable = lib.mkEnableOption "" // { enable = lib.mkEnableOption "" // {
description = '' description = ''
@@ -172,25 +256,33 @@ in
initrd.availableKernelModules = [ initrd.availableKernelModules = [
"usbhid" "usbhid"
"usb-storage" "usb-storage"
] ++ (if (cfg.variant == "5") then [ ]
"nvme" ++ (
] else if (cfg.variant == "5") then
[ [
"vc4" "nvme"
"pcie-brcmstb" # required for the pcie bus to work ]
"reset-raspberrypi" # required for vl805 firmware to load else
]); [
"vc4"
"pcie-brcmstb" # required for the pcie bus to work
"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}");
${bootloaderInstaller} -f /boot/firmware -b /boot -c in
''; ''
${bootloaderInstaller} -f /boot/firmware -b /boot -c
'';
grub.enable = lib.mkForce false; grub.enable = lib.mkForce false;
}; };
}; };
@@ -224,56 +316,85 @@ 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"; [
dtsText = '' {
/dts-v1/; name = "rpi4-cpu-revision";
/plugin/; dtsText = ''
/dts-v1/;
/plugin/;
/ { / {
compatible = "brcm,bcm2711"; compatible = "brcm,bcm2711";
fragment@0 { fragment@0 {
target-path = "/"; target-path = "/";
__overlay__ { __overlay__ {
system { system {
linux,revision = <0x00d03114>; linux,revision = <0x00d03114>;
};
};
}; };
}; };
}; '';
}; }
''; # {
} # name = "enable-xhci";
# { # dtsText = ''
# name = "enable-xhci"; # /dts-v1/;
# dtsText = '' # /plugin/;
# /dts-v1/;
# /plugin/;
# / { # / {
# compatible = "brcm,bcm2711"; # compatible = "brcm,bcm2711";
# fragment@0 { # fragment@0 {
# //target-path = "/scb/xhci@7e9c0000"; # //target-path = "/scb/xhci@7e9c0000";
# target = <&xhci>; # target = <&xhci>;
# __overlay__ { # __overlay__ {
# status = "okay"; # status = "okay";
# }; # };
# }; # };
# }; # };
# ''; # '';
# } # }
] 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 ]; firmware = [ pkgs.${namespace}.raspberryPiWirelessFirmware ];
graphics.enable32Bit = lib.mkForce false; graphics.enable32Bit = lib.mkForce false;
@@ -281,7 +402,7 @@ in
}; };
system = { system = {
#build.installBootLoader = lib.mkOverride 60 (if cfg.bootType == "uefi" then (builder."uefi") else (builder."uboot")); # todo #build.installBootLoader = lib.mkOverride 60 (if cfg.bootType == "uefi" then (builder."uefi") else (builder."uboot")); # todo
#boot = { #boot = {
# loader = { # loader = {
# id = lib.mkOverride 60 (if cfg.bootType == "uefi" then "raspberrypi-uefi" else "raspberrypi-uboot"); # todo # id = lib.mkOverride 60 (if cfg.bootType == "uefi" then "raspberrypi-uefi" else "raspberrypi-uboot"); # todo
@@ -303,12 +424,12 @@ in
users = { users = {
users.root.shell = pkgs.zsh; users.root.shell = pkgs.zsh;
extraGroups = { extraGroups = {
gpio = {}; gpio = { };
i2c = {}; i2c = { };
input = {}; input = { };
plugdev = {}; plugdev = { };
spi = {}; spi = { };
video = {}; video = { };
}; };
}; };
@@ -316,33 +437,44 @@ in
udev.packages = [ udev.packages = [
pkgs.${namespace}.udev-rules pkgs.${namespace}.udev-rules
]; ];
xserver.extraConfig = let xserver.extraConfig =
identifier = "rp1"; let
driver = "rp1-vec|rp1-dsi|rp1-dpi"; identifier = "rp1";
in '' driver = "rp1-vec|rp1-dsi|rp1-dpi";
Section "OutputClass" in
Identifier "${identifier}" ''
MatchDriver "${driver}" Section "OutputClass"
Driver "modesetting" Identifier "${identifier}"
Option "PrimaryGPU" "true" MatchDriver "${driver}"
EndSection Driver "modesetting"
''; Option "PrimaryGPU" "true"
EndSection
'';
}; };
nixpkgs.overlays = [ ] ++ (if cfg.variant == "5" then [ nixpkgs.overlays =
(final: prev: { [ ]
# https://github.com/nvmd/nixos-raspberrypi/issues/64 ++ (
# credit for the initial version of this snippet goes to @micahcc if cfg.variant == "5" then
jemalloc = prev.jemalloc.overrideAttrs (old: { [
# --with-lg-page=(log2 page_size) (_final: prev: {
# RPi5 (bcm2712): since our page size is 16384 (2**14), we need 14 # https://github.com/nvmd/nixos-raspberrypi/issues/64
configureFlags = let # credit for the initial version of this snippet goes to @micahcc
pageSizeFlag = "--with-lg-page"; jemalloc = prev.jemalloc.overrideAttrs (old: {
in (prev.lib.filter (flag: prev.lib.hasPrefix pageSizeFlag flag == false) old.configureFlags) # --with-lg-page=(log2 page_size)
++ [ "${pageSizeFlag}=14" ]; # RPi5 (bcm2712): since our page size is 16384 (2**14), we need 14
}); configureFlags =
}) let
] else [ ]) pageSizeFlag = "--with-lg-page";
++ (if cfg.apply-overlays-dtmerge.enable then [ dt_ao_overlay ] else [ ]); in
(prev.lib.filter (flag: prev.lib.hasPrefix pageSizeFlag flag == false) old.configureFlags)
++ [ "${pageSizeFlag}=14" ];
});
})
]
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 {
@@ -15,4 +16,4 @@ pkgs.replaceVarsWith {
inherit firmware configTxt; inherit firmware configTxt;
}; };
} }

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,52 +16,62 @@ 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"; {
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c0-pi5-overlay.dts"; name = "i2c0-pi5-overlay";
} dtsFile = "${
{ pkgs.${namespace}.raspberrypi-overlays
name = "i2c1-pi5-overlay"; }/dtbs/raspberrypi-overlays/i2c0-pi5-overlay.dts";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c1-pi5-overlay.dts"; }
} {
{ name = "i2c1-pi5-overlay";
name = "i2c2-pi5-overlay"; dtsFile = "${
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c2-pi5-overlay.dts"; pkgs.${namespace}.raspberrypi-overlays
} }/dtbs/raspberrypi-overlays/i2c1-pi5-overlay.dts";
{ }
name = "i2c3-pi5-overlay"; {
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c3-pi5-overlay.dts"; name = "i2c2-pi5-overlay";
} dtsFile = "${
] pkgs.${namespace}.raspberrypi-overlays
else }/dtbs/raspberrypi-overlays/i2c2-pi5-overlay.dts";
[ }
{ {
name = "i2c0-overlay"; name = "i2c3-pi5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c0-overlay.dts"; dtsFile = "${
} pkgs.${namespace}.raspberrypi-overlays
{ }/dtbs/raspberrypi-overlays/i2c3-pi5-overlay.dts";
name = "i2c1-overlay"; }
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c1-overlay.dts"; ]
} else
{ [
name = "i2c3-overlay"; {
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c3-overlay.dts"; name = "i2c0-overlay";
} dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c0-overlay.dts";
{ }
name = "i2c4-overlay"; {
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c4-overlay.dts"; name = "i2c1-overlay";
} dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c1-overlay.dts";
{ }
name = "i2c5-overlay"; {
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c5-overlay.dts"; name = "i2c3-overlay";
} dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c3-overlay.dts";
{ }
name = "i2c6-overlay"; {
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c6-overlay.dts"; name = "i2c4-overlay";
} dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c4-overlay.dts";
]); }
{
name = "i2c5-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/i2c5-overlay.dts";
}
{
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 let
cfg = config.${namespace}.hardware.raspberry-pi.leds; cfg = config.${namespace}.hardware.raspberry-pi.leds;
@@ -129,4 +134,4 @@ in
}; };
}) })
]; ];
} }

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;
@@ -10,26 +16,28 @@ 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";
[ dtsFile = "${
{ pkgs.${namespace}.raspberrypi-overlays
name = "vc4-kms-v3d-pi5-overlay"; }/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-fkms-v3d-pi4-overlay";
name = "vc4-kms-v3d-pi4-overlay"; dtsFile = "${
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/vc4-kms-v3d-pi4-overlay.dts"; 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,12 +21,13 @@ 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 {
@@ -20,4 +21,4 @@ pkgs.replaceVarsWith {
inherit extlinuxConfBuilder; inherit extlinuxConfBuilder;
inherit firmwareBuilder; inherit firmwareBuilder;
}; };
} }

View File

@@ -1,6 +1,7 @@
{ pkgs {
, uefiPackage pkgs,
, firmwareBuilder uefiPackage,
firmwareBuilder,
}: }:
pkgs.replaceVarsWith { pkgs.replaceVarsWith {
@@ -16,4 +17,4 @@ pkgs.replaceVarsWith {
uefi = uefiPackage; uefi = uefiPackage;
inherit firmwareBuilder; inherit firmwareBuilder;
}; };
} }

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;
@@ -10,25 +16,32 @@ 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"; [
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/disable-wifi-pi5-overlay.dts"; {
} name = "disable-wifi-pi5-overlay";
] dtsFile = "${
else pkgs.${namespace}.raspberrypi-overlays
[ }/dtbs/raspberrypi-overlays/disable-wifi-pi5-overlay.dts";
{ }
name = "disable-wifi-overlay"; ]
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/disable-wifi-overlay.dts"; else
} [
{ {
name = "wifimac-overlay"; name = "disable-wifi-overlay";
dtsFile = "${pkgs.${namespace}.raspberrypi-overlays}/dtbs/raspberrypi-overlays/wifimac-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, 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;
@@ -59,42 +55,86 @@ in
nixpkgs.overlays = [ nixpkgs.overlays = [
(_self: super: { (_self: super: {
${namespace} = ${namespace} =
let let
clangCcacheStdenv = super.overrideCC super.llvmPackages.stdenv (super.ccacheWrapper.override { clangCcacheStdenv = super.overrideCC super.llvmPackages.stdenv (
cc = super.llvmPackages.stdenv.cc; super.ccacheWrapper.override {
extraConfig = '' cc = super.llvmPackages.stdenv.cc;
export CCACHE_SLOPPINESS=include_file_ctime,time_macros extraConfig = ''
export CCACHE_DIR=/var/cache/ccache export CCACHE_SLOPPINESS=include_file_ctime,time_macros
''; 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;
};
};
}) })
(_self: super: { (_self: super: {
"raspberrypi-utils" = super.${namespace}."raspberrypi-utils"; "raspberrypi-utils" = super.${namespace}."raspberrypi-utils";
"raspberrypi-udev-rules" = super.${namespace}."udev-rules"; "raspberrypi-udev-rules" = super.${namespace}."udev-rules";
@@ -173,7 +213,7 @@ in
qt3d = super.kdePackages.qt3d.override { qt3d = super.kdePackages.qt3d.override {
qtbase = super.kdePackages.qtbase.override { stdenv = super.ccacheStdenv; }; 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: { # (_self: super: {

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 (
taste = "linux-cachyos-lts"; gccKernelAttrs
pname = "cachyos-lts"; // ltsAttrs
configPath = ./config-nix/${arch}-linux/cachyos-lts.${arch}-linux.nix; // {
}); taste = "linux-cachyos-lts";
pname = "cachyos-lts";
configPath = ./config-nix/${arch}-linux/cachyos-lts.${arch}-linux.nix;
}
);
# GCC RC # GCC RC
cachyos-rc = mkCachyKernel (gccKernelAttrs // rcAttrs // { cachyos-rc = mkCachyKernel (
taste = "linux-cachyos-rc"; gccKernelAttrs
pname = "cachyos-rc"; // rcAttrs
configPath = ./config-nix/${arch}-linux/cachyos-rc.${arch}-linux.nix; // {
}); taste = "linux-cachyos-rc";
pname = "cachyos-rc";
configPath = ./config-nix/${arch}-linux/cachyos-rc.${arch}-linux.nix;
}
);
# Server GCC # Server GCC
cachyos-server = mkCachyKernel (gccKernelAttrs // serverAttrs // { cachyos-server = mkCachyKernel (
taste = "linux-cachyos-server"; gccKernelAttrs
pname = "cachyos-server"; // serverAttrs
configPath = ./config-nix/${arch}-linux/cachyos-server.${arch}-linux.nix; // {
}); taste = "linux-cachyos-server";
pname = "cachyos-server";
configPath = ./config-nix/${arch}-linux/cachyos-server.${arch}-linux.nix;
}
);
# Hardened GCC # Hardened GCC
cachyos-hardened = mkCachyKernel (gccKernelAttrs // hardenedAttrs // { cachyos-hardened = mkCachyKernel (
taste = "linux-cachyos-hardened"; gccKernelAttrs
pname = "cachyos-hardened"; // hardenedAttrs
configPath = ./config-nix/${arch}-linux/cachyos-hardened.${arch}-linux.nix; // {
}); taste = "linux-cachyos-hardened";
pname = "cachyos-hardened";
configPath = ./config-nix/${arch}-linux/cachyos-hardened.${arch}-linux.nix;
}
);
# Deckify GCC # Deckify GCC
cachyos-deckify = mkCachyKernel (gccKernelAttrs // { cachyos-deckify = mkCachyKernel (
taste = "linux-cachyos-deckify"; gccKernelAttrs
pname = "cachyos-deckify"; // {
configPath = ./config-nix/${arch}-linux/cachyos-deckify.${arch}-linux.nix; taste = "linux-cachyos-deckify";
}); pname = "cachyos-deckify";
configPath = ./config-nix/${arch}-linux/cachyos-deckify.${arch}-linux.nix;
}
);
# ###################################################### # ######################################################
# LTO Kernels # # LTO Kernels #
@@ -253,24 +267,28 @@ in
cachyos-lto = mkCachyKernel ltoKernelAttrs; cachyos-lto = mkCachyKernel ltoKernelAttrs;
# LTO Full # LTO Full
cachyos-lto-full = mkCachyKernel (ltoKernelAttrs // { cachyos-lto-full = mkCachyKernel (
configPath = ./config-nix/cachyos-lto.x86_64-linux.nix; ltoKernelAttrs
useLTO = "full"; // {
}); configPath = ./config-nix/cachyos-lto.x86_64-linux.nix;
useLTO = "full";
}
);
# LTO Zen Version 4 # LTO Zen Version 4
cachyos-lto-znver4 = mkCachyKernel ( cachyos-lto-znver4 = mkCachyKernel (
ltoKernelAttrs ltoKernelAttrs
// { // {
pname = "cachyos-lto-znver4"; pname = "cachyos-lto-znver4";
configPath = ./config-nix/${arch}-linux/cachyos-znver4.${arch}-linux.nix; configPath = ./config-nix/${arch}-linux/cachyos-znver4.${arch}-linux.nix;
} }
); );
# 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 (
taste = "linux-cachyos-server"; ltoKernelAttrs
pname = "cachyos-server-lto"; // serverAttrs
configPath = ./config-nix/${arch}-linux/cachyos-server-lto.${arch}-linux.nix; // {
}); taste = "linux-cachyos-server";
pname = "cachyos-server-lto";
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 (
pname = "linux-cachyos-deckify-lto"; ltoKernelAttrs
configPath = ./config-nix/${arch}-linux/cachyos-deckify-lto.${arch}-linux.nix; // {
}); pname = "linux-cachyos-deckify-lto";
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

@@ -14,9 +14,9 @@ let
tag = "stable_20250916"; tag = "stable_20250916";
hash = "sha256-HG8Oc04V2t54l0SOn4gKmNJWQUrZfjWusgKcWvx74H0=="; hash = "sha256-HG8Oc04V2t54l0SOn4gKmNJWQUrZfjWusgKcWvx74H0==";
# NOTE: raspberrypifw & raspberryPiWirelessFirmware should be updated with this # NOTE: raspberrypifw & raspberryPiWirelessFirmware should be updated with this
# modDirVersion = "6.18.1"; # modDirVersion = "6.18.1";
# tag = "unstable_20251226"; # tag = "unstable_20251226";
# hash = "sha256-VYrXqwK9P2nWkm3DhOU8qaXzWv5L0DUoJ2MBRF6PoEE="; # hash = "sha256-VYrXqwK9P2nWkm3DhOU8qaXzWv5L0DUoJ2MBRF6PoEE=";
in in
lib.overrideDerivation lib.overrideDerivation
(buildLinux ( (buildLinux (
@@ -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

@@ -60,4 +60,4 @@ stdenvNoCC.mkDerivation {
platforms = platforms.linux; platforms = platforms.linux;
maintainers = with maintainers; [ lopsided98 ]; maintainers = with maintainers; [ lopsided98 ];
}; };
} }

View File

@@ -33,4 +33,4 @@ stdenvNoCC.mkDerivation rec {
# Maybe due to https://github.com/NixOS/nix/issues/847 # Maybe due to https://github.com/NixOS/nix/issues/847
broken = stdenvNoCC.hostPlatform.isDarwin; broken = stdenvNoCC.hostPlatform.isDarwin;
}; };
} }

View File

@@ -34,4 +34,4 @@ stdenvNoCC.mkDerivation rec {
# Maybe due to https://github.com/NixOS/nix/issues/847 # Maybe due to https://github.com/NixOS/nix/issues/847
broken = stdenvNoCC.hostPlatform.isDarwin; broken = stdenvNoCC.hostPlatform.isDarwin;
}; };
} }

View File

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

View File

@@ -1,38 +1,56 @@
{ {
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 ? { },
@@ -272,4 +256,4 @@ in
extraMeta.platforms = [ "aarch64-linux" ]; extraMeta.platforms = [ "aarch64-linux" ];
filesToInstall = [ "u-boot.bin" ]; filesToInstall = [ "u-boot.bin" ];
}; };
} }

View File

@@ -157,4 +157,4 @@ rec {
]; ];
}; };
} }

View File

@@ -1,4 +1,6 @@
{ pkgs ? import <nixpkgs> {} }: {
pkgs ? import <nixpkgs> { },
}:
pkgs.writeShellApplication { pkgs.writeShellApplication {
name = "test-image"; name = "test-image";
@@ -64,4 +66,4 @@ pkgs.writeShellApplication {
"''\${pflash_vars[@]}" \ "''\${pflash_vars[@]}" \
-drive "if=virtio,format=raw,file=$tmpFile" -drive "if=virtio,format=raw,file=$tmpFile"
''; '';
} }

View File

@@ -4,16 +4,13 @@
namespace, namespace,
... ...
}: }:
let
# kernelBundle = pkgs.linuxAndFirmware.latest;
in
{ {
boot = { boot = {
# loader.raspberry-pi = { # loader.raspberry-pi = {
# firmwarePackage = kernelBundle.raspberrypifw; # firmwarePackage = kernelBundle.raspberrypifw;
# variant = "4"; # variant = "4";
# }; # };
# kernelPackages = kernelBundle.linuxPackages_rpi4; # kernelPackages = kernelBundle.linuxPackages_rpi4;
# kernelPackages = pkgs.${namespace}.linuxPackages_cachyos-lto; # kernelPackages = pkgs.${namespace}.linuxPackages_cachyos-lto;
kernelPackages = pkgs.linuxPackages_latest; kernelPackages = pkgs.linuxPackages_latest;
supportedFilesystems = lib.mkForce [ ]; supportedFilesystems = lib.mkForce [ ];

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;

View File

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