From 9e6e1bf7ac02fcd50cdad9559057c3c1deb67625 Mon Sep 17 00:00:00 2001 From: hhhh hgfh Date: Mon, 5 Oct 2026 00:37:52 +0300 Subject: [PATCH] feat: add Windows EFI files to systemd-boot --- nixos/hosts/nixos/default.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/nixos/hosts/nixos/default.nix b/nixos/hosts/nixos/default.nix index d1db620..018380c 100644 --- a/nixos/hosts/nixos/default.nix +++ b/nixos/hosts/nixos/default.nix @@ -1,4 +1,4 @@ -{ ... }: +{ pkgs, ... }: { imports = [ @@ -12,6 +12,21 @@ 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. system.stateVersion = "26.05"; }