mirror of
https://github.com/nix-community/raspberry-pi-nix.git
synced 2025-11-08 19:46:03 +01:00
config txt rendering
This commit is contained in:
parent
5756b051fa
commit
9ebf2ff9c2
4 changed files with 113 additions and 7 deletions
|
|
@ -74,7 +74,7 @@ in {
|
|||
fw = rpi-firmware-stable-src;
|
||||
wireless-fw = import ./raspberrypi-wireless-firmware.nix {
|
||||
bluez-firmware = rpi-bluez-firmware-src;
|
||||
firmware-nonfree-src = rpi-firmware-nonfree-src;
|
||||
firmware-nonfree = rpi-firmware-nonfree-src;
|
||||
};
|
||||
}] // {
|
||||
latest = final.rpi-kernels."${latest}";
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
{ bluez-firmware-src, firmware-nonfree-src }:
|
||||
{ bluez-firmware, firmware-nonfree }:
|
||||
{ lib, stdenvNoCC, fetchFromGitHub }:
|
||||
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "raspberrypi-wireless-firmware";
|
||||
version = "2023-01-19";
|
||||
|
||||
srcs = [ bluez-firmware-src firmware-nonfree-src ];
|
||||
srcs = [ ];
|
||||
|
||||
sourceRoot = ".";
|
||||
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
# Firmware blobs do not need fixing and should not be modified
|
||||
dontFixup = true;
|
||||
|
|
@ -18,14 +19,13 @@ stdenvNoCC.mkDerivation {
|
|||
mkdir -p "$out/lib/firmware/brcm"
|
||||
|
||||
# Wifi firmware
|
||||
cp -rv "$NIX_BUILD_TOP/firmware-nonfree/debian/config/brcm80211/." "$out/lib/firmware/"
|
||||
cp -rv "${firmware-nonfree}/debian/config/brcm80211/." "$out/lib/firmware/"
|
||||
|
||||
# Bluetooth firmware
|
||||
cp -rv "$NIX_BUILD_TOP/bluez-firmware/broadcom/." "$out/lib/firmware/brcm"
|
||||
cp -rv "${bluez-firmware}/broadcom/." "$out/lib/firmware/brcm"
|
||||
|
||||
# CM4 symlink must be added since it's missing from upstream
|
||||
pushd $out/lib/firmware/brcm &>/dev/null
|
||||
ln -s "./brcmfmac43455-sdio.txt" "$out/lib/firmware/brcm/brcmfmac43455-sdio.raspberrypi,4-compute-module.txt"
|
||||
|
||||
# There are two options for the brcmfmac43455 binary: minimal or
|
||||
# standard. For more info see the readme at:
|
||||
|
|
|
|||
80
rpi/config.nix
Normal file
80
rpi/config.nix
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
{ lib, config, pkgs, ... }:
|
||||
let
|
||||
cfg = config;
|
||||
render-raspberrypi-config = let
|
||||
render-options = opts:
|
||||
lib.strings.concatStringsSep "\n" (render-dt-kvs opts);
|
||||
render-dt-param = x: "dtparam=" + x;
|
||||
render-dt-kv = k: v:
|
||||
if isNull v then k else let vstr = toString v; in "${k}=${vstr}";
|
||||
render-dt-kvs = x: lib.attrsets.mapAttrsToList render-dt-kv x;
|
||||
render-dt-overlay = { overlay, args }:
|
||||
"dtoverlay=" + overlay + "\n"
|
||||
+ lib.strings.concatMapStringsSep "\n" render-dt-param args + "\n"
|
||||
+ "dtoverlay=";
|
||||
render-base-dt-params = params:
|
||||
lib.strings.concatMapStringsSep "\n" render-dt-param
|
||||
(render-dt-kvs params);
|
||||
render-dt-overlays = overlays:
|
||||
lib.strings.concatMapStringsSep "\n" render-dt-overlay
|
||||
(lib.attrsets.mapAttrsToList (k: v: {
|
||||
overlay = k;
|
||||
args = render-dt-kvs v;
|
||||
}) overlays);
|
||||
render-config-section = k:
|
||||
{ options, base-dtb-params, dt-overlays }: ''
|
||||
[${k}]
|
||||
${render-options options}
|
||||
${render-base-dt-params base-dtb-params}
|
||||
${render-dt-overlays dt-overlays}
|
||||
'';
|
||||
in conf:
|
||||
lib.strings.concatStringsSep "\n"
|
||||
(lib.attrsets.mapAttrsToList render-config-section conf);
|
||||
in {
|
||||
options = {
|
||||
raspberrypi-config = let
|
||||
raspberrypi-config-options = {
|
||||
options = {
|
||||
options = lib.mkOption {
|
||||
type = with lib.types; attrsOf anything;
|
||||
default = { };
|
||||
example = {
|
||||
enable_gic = true;
|
||||
armstub = "armstub8-gic.bin";
|
||||
arm_boost = true;
|
||||
};
|
||||
};
|
||||
base-dtb-params = lib.mkOption {
|
||||
type = with lib.types; attrsOf anything;
|
||||
default = { };
|
||||
example = {
|
||||
i2c = "on";
|
||||
audio = "on";
|
||||
};
|
||||
description = "parameters to pass to the base dtb";
|
||||
};
|
||||
dt-overlays = lib.mkOption {
|
||||
type = with lib.types; attrsOf (attrsOf (nullOr str));
|
||||
default = { };
|
||||
example = { vc4-kms-v3d = { cma-256 = null; }; };
|
||||
description = "dtb overlays to apply";
|
||||
};
|
||||
};
|
||||
};
|
||||
in lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule raspberrypi-config-options);
|
||||
};
|
||||
raspberrypi-config-output = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = pkgs.writeTextFile {
|
||||
name = "config.txt";
|
||||
text = ''
|
||||
# Auto-generated by nix. Modifications will be overwritten.
|
||||
${render-raspberrypi-config cfg.raspberrypi-config}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,33 @@
|
|||
{ lib, pkgs, config, ... }:
|
||||
|
||||
{
|
||||
imports = [ ../sd-image ];
|
||||
imports = [ ../sd-image ./config.nix ];
|
||||
|
||||
raspberrypi-config = {
|
||||
pi4 = {
|
||||
options = {
|
||||
enable_gic = true;
|
||||
armstub = "armstub8-gic.bin";
|
||||
arm_boost = true;
|
||||
disable_overscan = true;
|
||||
};
|
||||
dt-overlays = { vc4-kms-v3d-pi4 = { cma-512 = null; }; };
|
||||
};
|
||||
pi02 = { dt-overlays = { vc4-kms-v3d = { cma-256 = null; }; }; };
|
||||
all = {
|
||||
options = {
|
||||
kernel = "u-boot-rpi_arm64.bin";
|
||||
enable_uart = true;
|
||||
avoid_warnings = true;
|
||||
arm_64bit = true;
|
||||
};
|
||||
base-dtb-params = {
|
||||
i2c = "on";
|
||||
audio = "on";
|
||||
krnbt = "on";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nixpkgs = { overlays = [ overlay ]; };
|
||||
boot = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue