Omit GRUB if boot.loader.grub.device is set to "nodev"
If we only need to generate a GRUB boot menu, we don't need GRUB itself. This cuts 38 MiB from EC2 system closures (in particular because it gets rid of the need for the 32-bit Glibc).
This commit is contained in:
parent
2b63b67aa4
commit
d210f30fa7
|
@ -6,7 +6,14 @@ let
|
||||||
|
|
||||||
cfg = config.boot.loader.grub;
|
cfg = config.boot.loader.grub;
|
||||||
|
|
||||||
grub = if cfg.version == 1 then pkgs.grub else pkgs.grub2;
|
realGrub = if cfg.version == 1 then pkgs.grub else pkgs.grub2;
|
||||||
|
|
||||||
|
grub =
|
||||||
|
# Don't include GRUB if we're only generating a GRUB menu (e.g.,
|
||||||
|
# in EC2 instances).
|
||||||
|
if cfg.devices == ["nodev"]
|
||||||
|
then null
|
||||||
|
else realGrub;
|
||||||
|
|
||||||
f = x: if x == null then "" else "" + x;
|
f = x: if x == null then "" else "" + x;
|
||||||
|
|
||||||
|
@ -14,8 +21,8 @@ let
|
||||||
{ splashImage = f config.boot.loader.grub.splashImage;
|
{ splashImage = f config.boot.loader.grub.splashImage;
|
||||||
grub = f grub;
|
grub = f grub;
|
||||||
shell = "${pkgs.stdenv.shell}";
|
shell = "${pkgs.stdenv.shell}";
|
||||||
fullVersion = (builtins.parseDrvName config.system.build.grub.name).version;
|
fullVersion = (builtins.parseDrvName realGrub.name).version;
|
||||||
inherit (config.boot.loader.grub)
|
inherit (cfg)
|
||||||
version extraConfig extraPerEntryConfig extraEntries
|
version extraConfig extraPerEntryConfig extraEntries
|
||||||
extraEntriesBeforeNixOS extraPrepareConfig configurationLimit copyKernels timeout
|
extraEntriesBeforeNixOS extraPrepareConfig configurationLimit copyKernels timeout
|
||||||
default devices;
|
default devices;
|
||||||
|
@ -141,7 +148,7 @@ in
|
||||||
|
|
||||||
splashImage = mkOption {
|
splashImage = mkOption {
|
||||||
default =
|
default =
|
||||||
if config.boot.loader.grub.version == 1
|
if cfg.version == 1
|
||||||
then pkgs.fetchurl {
|
then pkgs.fetchurl {
|
||||||
url = http://www.gnome-look.org/CONTENT/content-files/36909-soft-tux.xpm.gz;
|
url = http://www.gnome-look.org/CONTENT/content-files/36909-soft-tux.xpm.gz;
|
||||||
sha256 = "14kqdx2lfqvh40h6fjjzqgff1mwk74dmbjvmqphi6azzra7z8d59";
|
sha256 = "14kqdx2lfqvh40h6fjjzqgff1mwk74dmbjvmqphi6azzra7z8d59";
|
||||||
|
@ -196,7 +203,7 @@ in
|
||||||
|
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = mkIf config.boot.loader.grub.enable {
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
boot.loader.grub.devices = optional (cfg.device != "") cfg.device;
|
boot.loader.grub.devices = optional (cfg.device != "") cfg.device;
|
||||||
|
|
||||||
|
@ -212,7 +219,7 @@ in
|
||||||
# set at once.
|
# set at once.
|
||||||
system.boot.loader.id = "grub";
|
system.boot.loader.id = "grub";
|
||||||
|
|
||||||
environment.systemPackages = mkIf config.boot.loader.grub.enable [ grub ];
|
environment.systemPackages = [ grub ];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue