diff --git a/nixos/modules/system/boot/loader/grub/grub.nix b/nixos/modules/system/boot/loader/grub/grub.nix index 8db271f87135..1f915d1f419c 100644 --- a/nixos/modules/system/boot/loader/grub/grub.nix +++ b/nixos/modules/system/boot/loader/grub/grub.nix @@ -44,6 +44,8 @@ let { splashImage = f cfg.splashImage; splashMode = f cfg.splashMode; backgroundColor = f cfg.backgroundColor; + entryOptions = f cfg.entryOptions; + subEntryOptions = f cfg.subEntryOptions; grub = f grub; grubTarget = f (grub.grubTarget or ""); shell = "${pkgs.runtimeShell}"; @@ -448,6 +450,30 @@ in ''; }; + entryOptions = mkOption { + default = "--class nixos --unrestricted"; + type = types.nullOr types.str; + description = '' + Options applied to the primary NixOS menu entry. + + + This options has no effect for GRUB 1. + + ''; + }; + + subEntryOptions = mkOption { + default = "--class nixos"; + type = types.nullOr types.str; + description = '' + Options applied to the secondary NixOS submenu entry. + + + This options has no effect for GRUB 1. + + ''; + }; + theme = mkOption { type = types.nullOr types.path; example = literalExpression "pkgs.nixos-grub2-theme"; diff --git a/nixos/modules/system/boot/loader/grub/install-grub.pl b/nixos/modules/system/boot/loader/grub/install-grub.pl index 0c93b288fc65..d5f019423b64 100644 --- a/nixos/modules/system/boot/loader/grub/install-grub.pl +++ b/nixos/modules/system/boot/loader/grub/install-grub.pl @@ -64,6 +64,8 @@ my $extraEntries = get("extraEntries"); my $extraEntriesBeforeNixOS = get("extraEntriesBeforeNixOS") eq "true"; my $splashImage = get("splashImage"); my $splashMode = get("splashMode"); +my $entryOptions = get("entryOptions"); +my $subEntryOptions = get("subEntryOptions"); my $backgroundColor = get("backgroundColor"); my $configurationLimit = int(get("configurationLimit")); my $copyKernels = get("copyKernels") eq "true"; @@ -509,7 +511,7 @@ sub addEntry { # Add default entries. $conf .= "$extraEntries\n" if $extraEntriesBeforeNixOS; -addEntry("NixOS - Default", $defaultConfig, "--unrestricted"); +addEntry("NixOS - Default", $defaultConfig, $entryOptions); $conf .= "$extraEntries\n" unless $extraEntriesBeforeNixOS; @@ -546,7 +548,7 @@ sub addProfile { my ($profile, $description) = @_; # Add entries for all generations of this profile. - $conf .= "submenu \"$description\" {\n" if $grubVersion == 2; + $conf .= "submenu \"$description\" --class submenu {\n" if $grubVersion == 2; sub nrFromGen { my ($x) = @_; $x =~ /\/\w+-(\d+)-link/; return $1; } @@ -566,7 +568,7 @@ sub addProfile { -e "$link/nixos-version" ? readFile("$link/nixos-version") : basename((glob(dirname(Cwd::abs_path("$link/kernel")) . "/lib/modules/*"))[0]); - addEntry("NixOS - Configuration " . nrFromGen($link) . " ($date - $version)", $link); + addEntry("NixOS - Configuration " . nrFromGen($link) . " ($date - $version)", $link, $subEntryOptions); } $conf .= "}\n" if $grubVersion == 2;