bruh
This commit is contained in:
@@ -12,6 +12,110 @@ let
|
||||
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
|
||||
# sometimes referred to as "boot code"
|
||||
raspberryPiFirmware = ({ pkgs
|
||||
, firmware
|
||||
, configTxt
|
||||
}: pkgs.replaceVarsWith {
|
||||
src = ./generational/install-firmware.sh;
|
||||
isExecutable = true;
|
||||
|
||||
replacements = {
|
||||
inherit (pkgs) bash;
|
||||
path = pkgs.lib.makeBinPath [
|
||||
pkgs.coreutils
|
||||
];
|
||||
|
||||
inherit firmware configTxt;
|
||||
};
|
||||
});
|
||||
|
||||
# Builders used to write during system activation
|
||||
firmwareBuilder = import ./firmware-builder.nix {
|
||||
inherit pkgs;
|
||||
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}
|
||||
'';
|
||||
};
|
||||
firmware = pkgs.${namespace}.raspberrypifw;
|
||||
};
|
||||
ubootBuilder = import ./uboot-builder.nix {
|
||||
inherit pkgs;
|
||||
ubootPackage = pkgs.${namespace}.uboot-pi5;
|
||||
firmwareBuilder = firmwarePopulateCmd;
|
||||
extlinuxConfBuilder = config.boot.loader.generic-extlinux-compatible.populateCmd;
|
||||
};
|
||||
|
||||
# Builders exposed via populateCmd, which run on the build architecture
|
||||
populateFirmwareBuilder = import ./firmware-builder.nix {
|
||||
pkgs = pkgs.buildPackages;
|
||||
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}
|
||||
'';
|
||||
};
|
||||
firmware = pkgs.${namespace}.raspberrypifw;
|
||||
};
|
||||
|
||||
populateUbootBuilder = import ./uboot-builder.nix {
|
||||
inherit ubootBinName;
|
||||
pkgs = pkgs.buildPackages;
|
||||
ubootPackage = pkgs.${namespace}.uboot-pi5;
|
||||
firmwareBuilder = firmwarePopulateCmd;
|
||||
extlinuxConfBuilder = config.boot.loader.generic-extlinux-compatible.populateCmd;
|
||||
};
|
||||
|
||||
firmwarePopulateCmd = "${populateFirmwareBuilder} ${firmwareBuilderArgs}";
|
||||
firmwareBuilderArgs = lib.optionalString (!true) " -r";
|
||||
|
||||
# these will receive the top-level path as an argument when invoked as
|
||||
# system.build.installBootloader
|
||||
builder = {
|
||||
# system.build.installBootLoader
|
||||
uboot = "${ubootBuilder} -f /boot/firmware -b /boot -c";
|
||||
};
|
||||
|
||||
# firmware: caller must provide `-c <nixos configuration>` and `-f <firmware target path>`
|
||||
# boot: caller must provide `-c <nixos configuration>` and `-b <boot-dir>`
|
||||
populateCmds = {
|
||||
uboot = {
|
||||
firmware = "${populateUbootBuilder}";
|
||||
boot = "${populateUbootBuilder}";
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options.${namespace}.hardware.raspberry-pi = {
|
||||
@@ -38,6 +142,7 @@ in
|
||||
imports = [
|
||||
./audio.nix
|
||||
./bluetooth.nix
|
||||
./config.nix
|
||||
./i2c.nix
|
||||
./leds.nix
|
||||
./modesetting.nix
|
||||
@@ -60,7 +165,10 @@ in
|
||||
"reset-raspberrypi" # required for vl805 firmware to load
|
||||
]);
|
||||
loader = {
|
||||
generic-extlinux-compatible.enable = lib.mkDefault true;
|
||||
generic-extlinux-compatible = {
|
||||
enable = lib.mkDefault true;
|
||||
useGenerationDeviceTree = false;
|
||||
};
|
||||
grub.enable = lib.mkForce false;
|
||||
};
|
||||
};
|
||||
@@ -150,12 +258,21 @@ in
|
||||
i2c.enable = lib.mkDefault true;
|
||||
};
|
||||
|
||||
# Pi specific system tags
|
||||
system.nixos.tags = [
|
||||
"raspberry-pi-${cfg.variant}"
|
||||
# config.boot.loader.raspberry-pi.bootloader
|
||||
config.boot.kernelPackages.kernel.version
|
||||
];
|
||||
system = {
|
||||
build.installBootLoader = lib.mkOverride 60 (builder."uboot");
|
||||
boot = {
|
||||
loader = {
|
||||
id = lib.mkOverride 60 ("raspberrypi-uboot");
|
||||
kernelFile = pkgs.stdenv.hostPlatform.linux-kernel.target;
|
||||
};
|
||||
};
|
||||
# Pi specific system tags
|
||||
nixos.tags = [
|
||||
"raspberry-pi-${cfg.variant}"
|
||||
# config.boot.loader.raspberry-pi.bootloader
|
||||
config.boot.kernelPackages.kernel.version
|
||||
];
|
||||
};
|
||||
|
||||
# Common programs
|
||||
programs.kdeconnect.enable = lib.mkDefault false;
|
||||
@@ -191,11 +308,6 @@ in
|
||||
};
|
||||
|
||||
nixpkgs.overlays = [ ] ++ (if cfg.variant == "5" then [
|
||||
(final: prev: {
|
||||
ubootRaspberryPi5 = prev.uboot.ubootRaspberryPi4_64Bit.override {
|
||||
defconfig = "rpi_5_defconfig";
|
||||
};
|
||||
})
|
||||
(final: prev: {
|
||||
# https://github.com/nvmd/nixos-raspberrypi/issues/64
|
||||
# credit for the initial version of this snippet goes to @micahcc
|
||||
|
||||
Reference in New Issue
Block a user