From 813a3fd019265d6dde1ee23738d8c7b9a974564d Mon Sep 17 00:00:00 2001 From: "Lennart J. Kurzweg (Nx2)" Date: Sun, 7 Jul 2024 22:47:49 +0200 Subject: [PATCH] boot with windows entry --- system-modules/boot.nix | 54 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/system-modules/boot.nix b/system-modules/boot.nix index 35333e0..ed5c1d2 100755 --- a/system-modules/boot.nix +++ b/system-modules/boot.nix @@ -1,4 +1,4 @@ -{ config, pkgs, host, inputs, ... }: +{ config, pkgs, lib, host, inputs, ... }: let grub-theme-ascii-diana = (pkgs.fetchFromGitea { domain = "git.nx2.site"; @@ -17,14 +17,64 @@ in environment.systemPackages = with pkgs; [ sbctl ]; boot = { - lanzaboote = { + lanzaboote = + let + windows-efi-shell-fs-alias = "HD0a65535a2"; + in + { enable = true; pkiBundle = "/etc/secureboot"; + package = lib.mkForce (pkgs.writeShellApplication { + name = "lzbt"; + runtimeInputs = [ + inputs.lanzaboote.packages.x86_64-linux.tool + pkgs.coreutils + pkgs.sbctl + ]; + # https://forum.endeavouros.com/t/tutorial-add-a-systemd-boot-loader-menu-entry-for-a-windows-installation-using-a-separate-esp-partition/37431 + text = /*bash*/ '' + # execute normal lanazboote functionality + lzbt "$@" + + # Create windows.nsh file + ESP='${config.boot.loader.efi.efiSysMountPoint}' + echo "${windows-efi-shell-fs-alias}:EFI\Microsoft\Boot\Bootmgfw.efi" > "$ESP/windows.nsh" + + # cp efi-shell boot file + # systemd-boot will automatically add an entry for it + cp -f '${pkgs.edk2-uefi-shell.efi}' "$ESP/shellx64.efi" + # should exist already + mkdir -p "$ESP/loader/entries" + # sign shell file + sbctl sign -s "$ESP/shellx64.efi" + # Create windows.conf boot entry + cat << EOF > "$ESP/loader/entries/windows.conf" + title Windows-Hack + efi /shellx64.efi + options -nointerrupt -noconsolein -noconsoleout windows.nsh + EOF + ''; + }); }; loader.systemd-boot = { enable = false; # let lanzaboote install systemd-boot consoleMode = "max"; configurationLimit = 10; + # extraEntries = { + # "Windo7s-11.conf" = '' + # Windows eleven + # search --file --no-floppy --set=root /EFI/Microsoft/Boot/bootmgfw.efi + # chainloader (''${root})/EFI/Microsoft/Boot/bootmgfw.efi + # ''; + # "Firmware.conf" = '' + # Firmware + # fwsetup + # ''; + # "Shutdown.conf" = '' + # title Shutdown + # halt + # ''; + # }; }; # kernelPackages = pkgs.linuxPackages_latest; extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ];