Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/grub: implements GRUB_SAVEDEFAULT feature #109302

Merged
merged 1 commit into from Aug 14, 2021

Conversation

SrTobi
Copy link
Contributor

@SrTobi SrTobi commented Jan 13, 2021

Original issue: #108206

This will make grub remember the configuration that was booted and
select it as default menu entry the next time.

I'm not sure how to test this exactly.
I tried it on my NixOS system and it worked.
But I was using grub2.
I also implemented this for grub1, but I have no idea if it works.
I followed this documentation: https://www.gnu.org/software/grub/manual/legacy/savedefault.html

Motivation for this change

This is a well known feature grub-mkconfig offers and which is currently not (or not easily) achievable within a configuration.nix.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@AndersonTorres
Copy link
Member

Try a virtual machine from scratch.

@SrTobi
Copy link
Contributor Author

SrTobi commented Jan 16, 2021

Ok, I tried it with a virtual machine and it works. Also tried it with grub legacy there, and even though I couldn't get grub legacy to boot (because nixos-rebuild would fail with multiple errors) the menu.lst that was created looked exactly as in the documentation.

@AndersonTorres
Copy link
Member

@SrTobi did you try legacy grub before that modification?

@SrTobi
Copy link
Contributor Author

SrTobi commented Jan 16, 2021

@AndersonTorres yeah, had nothing to do with the savedefault changes. I used the standard config generated by nixos-generate-config:

image

When running rebuild I get various issues depending on the previous state of the installation.

  1. When having previously used grub2, I get:
    image

  2. When deleting /boot and running rebuild I get:
    image

Partitions:
image

@Vinetos
Copy link
Member

Vinetos commented Feb 16, 2021

Any news ? I love this option !

@SrTobi
Copy link
Contributor Author

SrTobi commented Feb 17, 2021

@Mic92 @samueldr can you have a look? What is to do here?

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/570

@corngood
Copy link
Contributor

I've been using this for a while without any problems. Thanks!

@SrTobi
Copy link
Contributor Author

SrTobi commented Jul 28, 2021

@corngood what do you mean you have been using it? do you have a custom nixpkg version? or how?

@corngood
Copy link
Contributor

Yeah, I maintain a fork of master with some things merged into it, this is one of them.

@SrTobi
Copy link
Contributor Author

SrTobi commented Jul 28, 2021

ah ok, thx. was a little confused :D

Grub will remember the configuration that was booted and
select it as default menu entry the next time (NixOS#108206).
Copy link
Member

@AndersonTorres AndersonTorres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. LGTBorg.

@SrTobi
Copy link
Contributor Author

SrTobi commented Aug 14, 2021

@Mic92, @samueldr could you pls have a look as well... this is sitting for over half a year

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants