diff --git a/modules/installer/cd-dvd/installation-cd-base.nix b/modules/installer/cd-dvd/installation-cd-base.nix
index 31f803bac328..999871ab074f 100644
--- a/modules/installer/cd-dvd/installation-cd-base.nix
+++ b/modules/installer/cd-dvd/installation-cd-base.nix
@@ -7,8 +7,7 @@ with pkgs.lib;
{
imports =
- [ ./memtest.nix
- ./channel.nix
+ [ ./channel.nix
./iso-image.nix
# Profiles of this basic installation CD.
@@ -32,4 +31,7 @@ with pkgs.lib;
# To speed up installation a little bit, include the complete stdenv
# in the Nix store on the CD.
isoImage.storeContents = [ pkgs.stdenv pkgs.busybox ];
+
+ # Add Memtest86+ to the CD.
+ boot.loader.grub.memtest86 = true;
}
diff --git a/modules/installer/cd-dvd/iso-image.nix b/modules/installer/cd-dvd/iso-image.nix
index fdc8e6a6f9fc..9e4352e48bb4 100644
--- a/modules/installer/cd-dvd/iso-image.nix
+++ b/modules/installer/cd-dvd/iso-image.nix
@@ -194,7 +194,7 @@ in
boot.initrd.kernelModules = [ "loop" ];
- boot.kernelModules = pkgs.stdenv.lib.optional config.isoImage.makeEfiBootable "efivars";
+ boot.kernelModules = optional config.isoImage.makeEfiBootable "efivars";
# In stage 1, mount a tmpfs on top of / (the ISO image) and
# /nix/store (the squashfs image) to make this a live CD.
@@ -235,7 +235,11 @@ in
[ { source = grubImage;
target = "/boot/grub/grub_eltorito";
}
- { source = pkgs.writeText "grub.cfg" grubCfg;
+ { source = pkgs.substituteAll {
+ name = "grub.cfg";
+ src = pkgs.writeText "grub.cfg-in" grubCfg;
+ bootRoot = "/boot";
+ };
target = "/boot/grub/grub.cfg";
}
{ source = config.boot.kernelPackages.kernel + "/bzImage";
@@ -254,19 +258,19 @@ in
target = "/nix-store.squashfs";
}
{ # Quick hack: need a mount point for the store.
- source = pkgs.runCommand "empty" {} "ensureDir $out";
+ source = pkgs.runCommand "empty" {} "mkdir -p $out";
target = "/nix/store";
}
- ] ++ pkgs.stdenv.lib.optionals config.isoImage.makeEfiBootable [
+ ] ++ optionals config.isoImage.makeEfiBootable [
{ source = efiImg;
target = "/boot/efi.img";
}
- ];
+ ] ++ mapAttrsToList (n: v: { source = v; target = "/boot/${n}"; }) config.boot.loader.grub.extraFiles;
# The Grub menu.
boot.loader.grub.extraEntries =
''
- menuentry "NixOS Installer / Rescue" {
+ menuentry "NixOS ${config.system.nixosVersion} Installer" {
linux /boot/bzImage init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}
initrd /boot/initrd
}
@@ -287,7 +291,7 @@ in
bootable = true;
bootImage = "/boot/grub/grub_eltorito";
- } // pkgs.stdenv.lib.optionalAttrs config.isoImage.makeEfiBootable {
+ } // optionalAttrs config.isoImage.makeEfiBootable {
efiBootable = true;
efiBootImage = "boot/efi.img";
});
diff --git a/modules/installer/cd-dvd/memtest.nix b/modules/installer/cd-dvd/memtest.nix
deleted file mode 100644
index 52b3d8af7c1d..000000000000
--- a/modules/installer/cd-dvd/memtest.nix
+++ /dev/null
@@ -1,24 +0,0 @@
-# This module adds Memtest86 to the Grub boot menu on the CD.
-
-{config, pkgs, ...}:
-
-let
-
- memtestPath = "/boot/memtest.bin";
-
-in
-
-{
- boot.loader.grub.extraEntries =
- ''
- menuentry "Memtest86" {
- linux16 ${memtestPath}
- }
- '';
-
- isoImage.contents =
- [ { source = pkgs.memtest86 + "/memtest.bin";
- target = memtestPath;
- }
- ];
-}
diff --git a/modules/system/boot/loader/grub/grub.nix b/modules/system/boot/loader/grub/grub.nix
index 4208465d5908..85845cd2cd9f 100644
--- a/modules/system/boot/loader/grub/grub.nix
+++ b/modules/system/boot/loader/grub/grub.nix
@@ -150,6 +150,19 @@ in
'';
};
+ extraFiles = mkOption {
+ default = {};
+ example = literalExample ''
+ { "memtest.bin" = "${pkgs.memtest86plus}/memtest.bin"; }
+ '';
+ description = ''
+ A set of files to be copied to /boot.
+ Each attribute name denotes the destination file name in
+ /boot, while the corresponding
+ attribute value specifies the source file.
+ '';
+ };
+
splashImage = mkOption {
default =
if cfg.version == 1
@@ -225,6 +238,11 @@ in
environment.systemPackages = [ grub ];
+ boot.loader.grub.extraPrepareConfig =
+ concatStrings (mapAttrsToList (n: v: ''
+ ${pkgs.coreutils}/bin/cp -pf "${v}" "/boot/${n}"
+ '') config.boot.loader.grub.extraFiles);
+
};
}
diff --git a/modules/system/boot/loader/grub/memtest.nix b/modules/system/boot/loader/grub/memtest.nix
index 50c904e1be75..006d777b1201 100644
--- a/modules/system/boot/loader/grub/memtest.nix
+++ b/modules/system/boot/loader/grub/memtest.nix
@@ -1,39 +1,42 @@
-# This module allows getting memtest86 in grub menus.
+# This module adds Memtest86+ to the GRUB boot menu.
-{config, pkgs, ...}:
+{ config, pkgs, ... }:
with pkgs.lib;
+
let
- isEnabled = config.boot.loader.grub.memtest86;
memtest86 = pkgs.memtest86plus;
in
+
{
options = {
+
boot.loader.grub.memtest86 = mkOption {
default = false;
type = types.bool;
description = ''
Make Memtest86+, a memory testing program, available from the
- GRUB menu.
+ GRUB boot menu.
'';
};
};
- config.boot.loader.grub = mkIf isEnabled {
- extraEntries = if config.boot.loader.grub.version == 2 then
- ''
- menuentry "${memtest86.name}" {
- linux16 @bootRoot@/memtest.bin
- }
- ''
+ config = mkIf config.boot.loader.grub.memtest86 {
+
+ boot.loader.grub.extraEntries =
+ if config.boot.loader.grub.version == 2 then
+ ''
+ menuentry "Memtest86+" {
+ linux16 @bootRoot@/memtest.bin
+ }
+ ''
else
- ''
- menuentry "${memtest86.name}"
- linux16 @bootRoot@/memtest.bin
- '';
- extraPrepareConfig =
- ''
- ${pkgs.coreutils}/bin/cp ${memtest86}/memtest.bin /boot/memtest.bin;
- '';
+ ''
+ menuentry "Memtest86+"
+ linux16 @bootRoot@/memtest.bin
+ '';
+
+ boot.loader.grub.extraFiles."memtest.bin" = "${memtest86}/memtest.bin";
+
};
}