summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-02 12:29:07 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-02 12:33:06 +0200
commitc13041c65cdf9c188aa3ef4ee9f0f7d5e7603dc4 (patch)
treeb2ab6c59bfdf0d083822a6b493f73711259cbebc /modules
parent1c58fbe4a9850f03f58afcff12823931b4db881d (diff)
downloadnixlib-c13041c65cdf9c188aa3ef4ee9f0f7d5e7603dc4.tar
nixlib-c13041c65cdf9c188aa3ef4ee9f0f7d5e7603dc4.tar.gz
nixlib-c13041c65cdf9c188aa3ef4ee9f0f7d5e7603dc4.tar.bz2
nixlib-c13041c65cdf9c188aa3ef4ee9f0f7d5e7603dc4.tar.lz
nixlib-c13041c65cdf9c188aa3ef4ee9f0f7d5e7603dc4.tar.xz
nixlib-c13041c65cdf9c188aa3ef4ee9f0f7d5e7603dc4.tar.zst
nixlib-c13041c65cdf9c188aa3ef4ee9f0f7d5e7603dc4.zip
Unify the two Memtest modules
This means we now have Memtest86+ on the installation CD.
Diffstat (limited to 'modules')
-rw-r--r--modules/installer/cd-dvd/installation-cd-base.nix6
-rw-r--r--modules/installer/cd-dvd/iso-image.nix18
-rw-r--r--modules/installer/cd-dvd/memtest.nix24
-rw-r--r--modules/system/boot/loader/grub/grub.nix18
-rw-r--r--modules/system/boot/loader/grub/memtest.nix41
5 files changed, 55 insertions, 52 deletions
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 <filename>/boot</filename>.
+          Each attribute name denotes the destination file name in
+          <filename>/boot</filename>, 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";
+
   };
 }