feat: add Windows EFI files to systemd-boot

This commit is contained in:
hhhh hgfh 2026-10-05 00:37:52 +03:00
parent 49612f1f30
commit 9e6e1bf7ac

View file

@ -1,4 +1,4 @@
{ ... }: { pkgs, ... }:
{ {
imports = [ imports = [
@ -12,6 +12,21 @@
networking.hostName = "nixos"; networking.hostName = "nixos";
# Windows uses a separate ESP on the NVMe drive. systemd-boot discovers
# Windows automatically when its EFI files are present on our ESP.
boot.loader.systemd-boot.extraInstallCommands = ''
(
set -eu
windows_esp=$(${pkgs.coreutils}/bin/mktemp -d)
trap '${pkgs.coreutils}/bin/rmdir "$windows_esp"' EXIT
${pkgs.util-linux}/bin/mount -t vfat -o ro \
/dev/disk/by-partuuid/ce1c99b8-19d9-4d46-9001-82aaf5235bc3 "$windows_esp"
trap '${pkgs.util-linux}/bin/umount "$windows_esp"; ${pkgs.coreutils}/bin/rmdir "$windows_esp"' EXIT
test -f "$windows_esp/EFI/Microsoft/Boot/bootmgfw.efi"
${pkgs.coreutils}/bin/cp -r "$windows_esp/EFI/Microsoft" /boot/EFI/
)
'';
# Keep this at the version used during the initial installation. # Keep this at the version used during the initial installation.
system.stateVersion = "26.05"; system.stateVersion = "26.05";
} }