mio-ops/hardware/odroid-hc4/uboot/hardkernel-uboot.nix

61 lines
1.8 KiB
Nix
Raw Normal View History

2022-03-07 14:26:15 +00:00
{
config,
lib,
pkgs,
...
}:
with lib; let
2021-10-20 06:22:09 +00:00
blCfg = config.boot.loader;
dtCfg = config.hardware.deviceTree;
cfg = blCfg.hardkernel-uboot;
2022-03-07 14:26:15 +00:00
timeoutStr =
if blCfg.timeout == null
then "-1"
else toString blCfg.timeout;
2021-10-20 06:22:09 +00:00
# The builder used to write during system activation
2022-03-07 14:26:15 +00:00
builder = import ./boot-ini-builder.nix {inherit pkgs;};
2021-10-20 06:22:09 +00:00
# The builder exposed in populateCmd, which runs on the build architecture
2021-11-16 04:57:23 +00:00
populateBuilder =
2022-03-07 14:26:15 +00:00
import ./boot-ini-builder.nix {pkgs = pkgs.buildPackages;};
2021-11-16 04:57:23 +00:00
in {
2021-10-20 06:22:09 +00:00
options = {
boot.loader.hardkernel-uboot = {
enable = mkOption {
default = false;
type = types.bool;
description = ''
Whether to generate an extlinux-compatible configuration file
under <literal>/boot/extlinux.conf</literal>. For instance,
U-Boot's generic distro boot support uses this file format.
See <link xlink:href="http://git.denx.de/?p=u-boot.git;a=blob;f=doc/README.distro;hb=refs/heads/master">U-boot's documentation</link>
for more information.
'';
};
populateCmd = mkOption {
type = types.str;
readOnly = true;
description = ''
Contains the builder command used to populate an image,
honoring all options except the <literal>-c &lt;path-to-default-configuration&gt;</literal>
argument.
Useful to have for sdImage.populateRootCommands
'';
};
};
};
2021-11-16 04:57:23 +00:00
config = let
2022-03-07 14:26:15 +00:00
builderArgs =
"-t ${timeoutStr}"
2021-11-16 04:57:23 +00:00
+ lib.optionalString (dtCfg.name != null) " -n ${dtCfg.name}";
2022-03-07 14:26:15 +00:00
in
mkIf cfg.enable {
system.build.installBootLoader = "${builder} ${builderArgs} -c";
system.boot.loader.id = "hardkernel-uboot";
boot.loader.hardkernel-uboot.populateCmd = "${populateBuilder} ${builderArgs}";
};
2021-10-20 06:22:09 +00:00
}