mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-18 07:29:23 +03:00

the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
105 lines
2.9 KiB
Nix
105 lines
2.9 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.boot.loader.raspberryPi;
|
|
|
|
builderUboot = import ./uboot-builder.nix { inherit pkgs configTxt; inherit (cfg) version; };
|
|
builderGeneric = import ./raspberrypi-builder.nix { inherit pkgs configTxt; };
|
|
|
|
builder =
|
|
if cfg.uboot.enable then
|
|
"${builderUboot} -g ${toString cfg.uboot.configurationLimit} -t ${timeoutStr} -c"
|
|
else
|
|
"${builderGeneric} -c";
|
|
|
|
blCfg = config.boot.loader;
|
|
timeoutStr = if blCfg.timeout == null then "-1" else toString blCfg.timeout;
|
|
|
|
isAarch64 = pkgs.stdenv.hostPlatform.isAarch64;
|
|
optional = pkgs.lib.optionalString;
|
|
|
|
configTxt =
|
|
pkgs.writeText "config.txt" (''
|
|
# U-Boot used to need this to work, regardless of whether UART is actually used or not.
|
|
# TODO: check when/if this can be removed.
|
|
enable_uart=1
|
|
|
|
# Prevent the firmware from smashing the framebuffer setup done by the mainline kernel
|
|
# when attempting to show low-voltage or overtemperature warnings.
|
|
avoid_warnings=1
|
|
'' + optional isAarch64 ''
|
|
# Boot in 64-bit mode.
|
|
arm_64bit=1
|
|
'' + (if cfg.uboot.enable then ''
|
|
kernel=u-boot-rpi.bin
|
|
'' else ''
|
|
kernel=kernel.img
|
|
initramfs initrd followkernel
|
|
'') + optional (cfg.firmwareConfig != null) cfg.firmwareConfig);
|
|
|
|
in
|
|
|
|
{
|
|
options = {
|
|
|
|
boot.loader.raspberryPi = {
|
|
enable = mkOption {
|
|
default = false;
|
|
type = types.bool;
|
|
description = lib.mdDoc ''
|
|
Whether to create files with the system generations in
|
|
`/boot`.
|
|
`/boot/old` will hold files from old generations.
|
|
'';
|
|
};
|
|
|
|
version = mkOption {
|
|
default = 2;
|
|
type = types.enum [ 0 1 2 3 4 ];
|
|
description = "";
|
|
};
|
|
|
|
uboot = {
|
|
enable = mkOption {
|
|
default = false;
|
|
type = types.bool;
|
|
description = lib.mdDoc ''
|
|
Enable using uboot as bootmanager for the raspberry pi.
|
|
'';
|
|
};
|
|
|
|
configurationLimit = mkOption {
|
|
default = 20;
|
|
example = 10;
|
|
type = types.int;
|
|
description = lib.mdDoc ''
|
|
Maximum number of configurations in the boot menu.
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
firmwareConfig = mkOption {
|
|
default = null;
|
|
type = types.nullOr types.lines;
|
|
description = lib.mdDoc ''
|
|
Extra options that will be appended to `/boot/config.txt` file.
|
|
For possible values, see: https://www.raspberrypi.com/documentation/computers/config_txt.html
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
assertions = singleton {
|
|
assertion = !pkgs.stdenv.hostPlatform.isAarch64 || cfg.version >= 3;
|
|
message = "Only Raspberry Pi >= 3 supports aarch64.";
|
|
};
|
|
|
|
system.build.installBootLoader = builder;
|
|
system.boot.loader.id = "raspberrypi";
|
|
system.boot.loader.kernelFile = pkgs.stdenv.hostPlatform.linux-kernel.target;
|
|
};
|
|
}
|