I searched on the internet for how to configure GRUB in the nix config but I found nothing except that you can use already packaged themes in grub.
I think that just editing the grub.cfg is not an option as NixOS will probably overwrite it on the next rebuild.
I’d like to change the order of the default entries or remove them, add custom entries, set a background, disable the timeout, and so on…
Do I have to write my own theme for that or is there a simple way to just have my own grub config file where NixOS can then insert the image paths?
Thank you
Hello so I would recommend to look at the grub options here:
https://search.nixos.org/options?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=grub
For themes this is how I have done it for my grub:
boot = {# Bootloader
loader = {
efi.canTouchEfiVariables = true;
grub ={
enable = true;
device = "nodev";
efiSupport = true;
useOSProber = true;
theme = "${
(pkgs.fetchFromGitHub {
owner = "semimqmo";
repo = "sekiro_grub_theme";
rev = "1affe05f7257b72b69404cfc0a60e88aa19f54a6";
hash = "sha256-wTr5S/17uwQXkWwElqBKIV1J3QUP6W2Qx2Nw0SaM7Qk=";
})
}/Sekiro";
};
timeout = 10;
};
};
If you have more questions feel free to ask
Options you wanted:
to use an image as a background: boot.loader.grub.splashImage
to add custom entries:boot.loader.grub.extraEntries
to change the timeout: boot.loader.timeout
If the default entries you want to remove are NixOS generations, take a look at Garbage Collection , where you can remove certain generations and remove them from the boot menu.
Is there a way to rearrange the pre-configured entries?
boot.loader.grub.extraEntriesBeforeNixOS
If you want your Entries before the Default
If you want that your extra Entries at the end there was something here:
NixOS:master
← NazakatUmrani:GrubOption
opened 12:23PM - 06 Jun 24 UTC
This option allows the user to specify a list of extra entries to be added to th… e end of the grub menu.
## Description of changes
I added this new option as boot.loader.grub.extraEntriesAtEnd, This option adds entries at the end of grub, The normal extraEntries option adds entries in the middle of NixOS and NixOS-Generations entry.
I wanted to add shutdown and reboot entries and end, but that old option was never designed to do that, so I created this new option which runs after OS Prober, and after OS Prober adds those entries then from this option entries are taken.
## Things done
I added an option with its description.
I added that option in the Perl file, after the line where OS Prober entries are loaded.
- Built on platform(s)
- [x] x86_64-linux
- [ ] aarch64-linux
- [ ] x86_64-darwin
- [ ] aarch64-darwin
- For non-Linux: Is sandboxing enabled in `nix.conf`? (See [Nix manual](https://nixos.org/manual/nix/stable/command-ref/conf-file.html))
- [ ] `sandbox = relaxed`
- [ ] `sandbox = true`
- [ ] Tested, as applicable:
- [NixOS test(s)](https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests) (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
- and/or [package tests](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#package-tests)
- or, for functions and "core" functionality, tests in [lib/tests](https://github.com/NixOS/nixpkgs/blob/master/lib/tests) or [pkgs/test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/test)
- made sure NixOS tests are [linked](https://nixos.org/manual/nixpkgs/unstable/#ssec-nixos-tests-linking) to the relevant packages
- [ ] Tested compilation of all packages that depend on this change using `nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"`. Note: all changes have to be committed, also see [nixpkgs-review usage](https://github.com/Mic92/nixpkgs-review#usage)
- [ ] Tested basic functionality of all binary files (usually in `./result/bin/`)
- [24.11 Release Notes](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2411.section.md) (or backporting [23.11](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2311.section.md) and [24.05](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2405.section.md) Release notes)
- [ ] (Package updates) Added a release notes entry if the change is major or breaking
- [ ] (Module updates) Added a release notes entry if the change is significant
- [ ] (Module addition) Added a release notes entry if adding a new NixOS module
- [x] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
## My Message
I have never worked with Perl, but I am a student studying software engineering, and I used GitHub Copilot, so it may or may not contain bugs, please check it, I want this option as I am frustrated with the old option and it's arrangement, so please add it.
But for me this won’t work (the last comment is from me).
Other than that there is not really much you can do considering the rearrangement of the pre configured entries.
Only when you put all the Entries (exept the default) in the extraEntry Option. The order in there is kept and will be displayed in GRUB.