nixos/grub: added configuration option for entry options

Changed files
+31 -3
nixos
modules
system
boot
+26
nixos/modules/system/boot/loader/grub/grub.nix
···
{ 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}";
···
default = null;
description = ''
Background color to be used for GRUB to fill the areas the image isn't filling.
+
+
<note><para>
+
This options has no effect for GRUB 1.
+
</para></note>
+
'';
+
};
+
+
entryOptions = mkOption {
+
default = "--class nixos --unrestricted";
+
type = types.nullOr types.str;
+
description = ''
+
Options applied to the primary NixOS menu entry.
+
+
<note><para>
+
This options has no effect for GRUB 1.
+
</para></note>
+
'';
+
};
+
+
subEntryOptions = mkOption {
+
default = "--class nixos";
+
type = types.nullOr types.str;
+
description = ''
+
Options applied to the secondary NixOS submenu entry.
<note><para>
This options has no effect for GRUB 1.
+5 -3
nixos/modules/system/boot/loader/grub/install-grub.pl
···
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";
···
# Add default entries.
$conf .= "$extraEntries\n" if $extraEntriesBeforeNixOS;
-
addEntry("NixOS - Default", $defaultConfig, "--unrestricted");
+
addEntry("NixOS - Default", $defaultConfig, $entryOptions);
$conf .= "$extraEntries\n" unless $extraEntriesBeforeNixOS;
···
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; }
···
-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;