[Nix-dev] Regarding extra GRUB options in Configuration.nix

Kirill Elagin kirelagin at gmail.com
Tue May 27 19:29:35 CEST 2014


Well, it looks like I should start with basics of grub.

Grub has a configuration file, `grub.cfg`. There is no such thing as
“hidden timeout” in terms of grub's configuration file.

Also they ship scripts that generate this configuration from another
configuration, supposedly, a more user-friendly one.
That's actually what you edit in `/etc/default/grub`. By the way, the
scripts that source this file and generate `grub.cfg`
are in `/etc/grub.d/` so you can check them out if you are interested. The
relevant part is `make_timeout` function in `00_header`.
I should note that I never trusted those generating scripts, because they
produce tons of useless code and I prefer to write
`grub.cfg` myself (kinda old-school, yeah!).

Now, NixOS, obviously doesn't use those scripts and generates `grub.cfg`
for you. So, the thing is, there is no way
to configure “hidden timeout” which is not cool, and I'll definitely put
this on my list of my future contributions to NixOS.
But for now you can simulate this by putting something like:

boot.loader.grub.extraConfig = ''
    if sleep --interruptible 5 ; then
        set timeout=10
    fi
'';

(Not tested, just guessing.)
(Where 5 is GRUB_HIDDEN_TIMEOUT and 10 is GRUB_TIMEOUT.)

This way you'll get the same behaviour as grub's upstream generator scripts
give you.

Personally I normally use this in my `grub.cfg` instead:

if keystatus --shift ; then
    set timeout=-1
else
    set timeout=0
fi

This will normally boot immediately without displaying the menu or waiting
for something, _unless_ you are holding
shift when booting. If you are holding shift, it will display the menu
without timeout.



--
Кирилл Елагин


On Tue, May 27, 2014 at 11:53 AM, Roger Qiu <roger.qiu at polycademy.com>wrote:

>  Hello,
>
> In a configuration.nix, where would you be able to set GRUB options such
> as:
>
> GRUB_HIDDEN_TIMEOUT=0
> GRUB_HIDDEN_TIMEOUT_QUIET=true
>
> The normal boot.loader.grub does not seem to have these functions?
>
> Thanks,
> Roger
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20140527/18cc80fb/attachment.html 


More information about the nix-dev mailing list