Dont automatically change loader.conf for systemd-boot

I want to have Windows 11 as my default option for systemd-boot, eg. have the file /boot/efi/loader/loader.conf be:

timeout 5
default Windows 11
console-mode keep

and not

timeout 5
default nixos-generation-197.conf
console-mode keep

How can I do this?

Doesn’t look like NixOS supports this. You can take a look at nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix and nixos/modules/system/boot/loader/systemd-boot/ if you want to try your hand at adding support for this to NixOS.

I ended up doing this:

  boot.loader.systemd-boot = {
    enable = true;
    extraInstallCommands = ''
      echo "title Windows" > /boot/efi/loader/entries/windows.conf
      echo "efi /EFI/Microsoft/Boot/bootmgfw.efi" >> /boot/efi/loader/entries/windows.conf

      echo "timeout 5" > /boot/efi/loader/loader.conf
      echo "default windows.conf" >> /boot/efi/loader/loader.conf
      echo "console-mode keep" >> /boot/efi/loader/loader.conf