Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions nixos/modules/installer/cd-dvd/iso-image.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ let
image,
params,
initrd,
devicetree,
}:
''
menuentry '${name}' --class ${class} {
Expand All @@ -25,6 +26,11 @@ let

linux ${image} \''${isoboot} ${params}
initrd ${initrd}
''
+ lib.optionalString (devicetree != null) ''
devicetree ${devicetree}
''
+ ''
}
'';

Expand All @@ -48,6 +54,11 @@ let
image = "/boot/${cfg.boot.kernelPackages.kernel + "/" + cfg.system.boot.loader.kernelFile}";
initrd = "/boot/${cfg.system.build.initialRamdisk + "/" + cfg.system.boot.loader.initrdFile}";
class = "installer";
devicetree =
if cfg.boot.loader.efi.installDeviceTree then
"/boot/${cfg.hardware.deviceTree.package}/${cfg.hardware.deviceTree.name}"
else
null;
};
in
''
Expand Down Expand Up @@ -491,7 +502,7 @@ let
''
mkdir ./contents && cd ./contents
mkdir -p ./EFI/BOOT
cp -rp "${efiDir}"/EFI/BOOT/{grub.cfg,*.EFI,*.efi} ./EFI/BOOT
cp -rp "${efiDir}"/EFI/BOOT/{grub.cfg,*.EFI,*.efi,*.dtb} ./EFI/BOOT

# Rewrite dates for everything in the FS
find . -exec touch --date=2000-01-01 {} +
Expand Down Expand Up @@ -950,7 +961,7 @@ in
let
cfgFiles =
cfg:
lib.optionals cfg.isoImage.showConfiguration ([
lib.optionals cfg.isoImage.showConfiguration [
{
source = cfg.boot.kernelPackages.kernel + "/" + cfg.system.boot.loader.kernelFile;
target = "/boot/" + cfg.boot.kernelPackages.kernel + "/" + cfg.system.boot.loader.kernelFile;
Expand All @@ -959,7 +970,13 @@ in
source = cfg.system.build.initialRamdisk + "/" + cfg.system.boot.loader.initrdFile;
target = "/boot/" + cfg.system.build.initialRamdisk + "/" + cfg.system.boot.loader.initrdFile;
}
])
]
++ lib.optionals cfg.boot.loader.efi.installDeviceTree [
{
source = "${cfg.hardware.deviceTree.package}/${cfg.hardware.deviceTree.name}";
target = "/boot/${cfg.hardware.deviceTree.package}/${cfg.hardware.deviceTree.name}";
}
]
++ lib.concatLists (
lib.mapAttrsToList (_: { configuration, ... }: cfgFiles configuration) cfg.specialisation
);
Expand Down
11 changes: 10 additions & 1 deletion nixos/modules/system/boot/loader/efi.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, ... }:
{ config, lib, ... }:
{
options.boot.loader.efi = {

Expand All @@ -13,5 +13,14 @@
type = lib.types.str;
description = "Where the EFI System Partition is mounted.";
};

installDeviceTree = lib.mkOption {
default = with config.hardware.deviceTree; enable && name != null;
defaultText = ''with config.hardware.deviceTree; enable && name != null'';
description = ''
Install the devicetree blob specified by `config.hardware.deviceTree.name`
to the ESP and instruct the bootloader to pass this DTB to linux.
'';
};
};
}
27 changes: 16 additions & 11 deletions nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,20 @@ in
]
(config: lib.strings.removeSuffix ".conf" config.boot.loader.systemd-boot.netbootxyz.entryFilename)
)
(mkRenamedOptionModule
[
"boot"
"loader"
"systemd-boot"
"installDeviceTree"
]
[
"boot"
"loader"
"efi"
"installDeviceTree"
]
)
];

options.boot.loader.systemd-boot = {
Expand Down Expand Up @@ -244,15 +258,6 @@ in
'';
};

installDeviceTree = mkOption {
default = with config.hardware.deviceTree; enable && name != null;
defaultText = ''with config.hardware.deviceTree; enable && name != null'';
description = ''
Install the devicetree blob specified by `config.hardware.deviceTree.name`
to the ESP and instruct systemd-boot to pass this DTB to linux.
'';
};

extraInstallCommands = mkOption {
default = "";
example = ''
Expand Down Expand Up @@ -537,7 +542,7 @@ in
}
{
assertion =
cfg.installDeviceTree
efi.installDeviceTree
-> config.hardware.deviceTree.enable
-> config.hardware.deviceTree.name != null;
message = "Cannot install devicetree without 'config.hardware.deviceTree.enable' enabled and 'config.hardware.deviceTree.name' set";
Expand Down Expand Up @@ -626,7 +631,7 @@ in

boot.bootspec.extensions."org.nixos.systemd-boot" = {
inherit (config.boot.loader.systemd-boot) sortKey;
devicetree = lib.mkIf cfg.installDeviceTree "${config.hardware.deviceTree.package}/${config.hardware.deviceTree.name}";
devicetree = lib.mkIf efi.installDeviceTree "${config.hardware.deviceTree.package}/${config.hardware.deviceTree.name}";
};

system = {
Expand Down
2 changes: 1 addition & 1 deletion nixos/tests/systemd-boot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ in
# (we would then be able to use `dumpdtb`). Thus, the following config
# will not boot, but it does allow us to assert that the boot entry has
# the correct contents.
boot.loader.systemd-boot.installDeviceTree = pkgs.stdenv.hostPlatform.isAarch64;
boot.loader.efi.installDeviceTree = pkgs.stdenv.hostPlatform.isAarch64;
hardware.deviceTree.name = "dummy.dtb";
hardware.deviceTree.package = lib.mkForce (
pkgs.runCommand "dummy-devicetree-package" { } ''
Expand Down
Loading