summary refs log tree commit diff
path: root/modules/installer/cd-dvd/iso-image.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2009-06-05 13:35:27 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2009-06-05 13:35:27 +0000
commite4e408293edbcc523470b4cbd7e3dd502c7b9ddb (patch)
tree03d46730da20529b9c1b4d3999cec922232abaf9 /modules/installer/cd-dvd/iso-image.nix
parenta4fa62aaf00055caceed3e46aa11111850e0f4fc (diff)
downloadnixpkgs-e4e408293edbcc523470b4cbd7e3dd502c7b9ddb.tar
nixpkgs-e4e408293edbcc523470b4cbd7e3dd502c7b9ddb.tar.gz
nixpkgs-e4e408293edbcc523470b4cbd7e3dd502c7b9ddb.tar.bz2
nixpkgs-e4e408293edbcc523470b4cbd7e3dd502c7b9ddb.tar.lz
nixpkgs-e4e408293edbcc523470b4cbd7e3dd502c7b9ddb.tar.xz
nixpkgs-e4e408293edbcc523470b4cbd7e3dd502c7b9ddb.tar.zst
nixpkgs-e4e408293edbcc523470b4cbd7e3dd502c7b9ddb.zip
* Modularise the building of the installation CD/DVD. The module
  iso-image.nix contains the minimal stuff necessary to build a
  bootable ISO image containing the given configuration.  The idea is
  that this can be customised by providing additional modules, e.g. to
  add extra packages to the image.

  The ISO image is exported in the configuration attribute
  system.build.isoImage.  So it can be built as follows:

  $ nix-build lib/eval-config.nix \
      --arg configuration 'import ./modules/installer/cd-dvd/iso-image.nix' \
      -A config.system.build.isoImage


svn path=/nixos/branches/modular-nixos/; revision=15871
Diffstat (limited to 'modules/installer/cd-dvd/iso-image.nix')
-rw-r--r--modules/installer/cd-dvd/iso-image.nix88
1 files changed, 88 insertions, 0 deletions
diff --git a/modules/installer/cd-dvd/iso-image.nix b/modules/installer/cd-dvd/iso-image.nix
new file mode 100644
index 00000000000..64f788993fe
--- /dev/null
+++ b/modules/installer/cd-dvd/iso-image.nix
@@ -0,0 +1,88 @@
+# This module creates a bootable ISO image containing the given NixOS
+# configuration.  The derivation for the ISO image will be placed in
+# config.system.build.isoImage.
+
+{config, pkgs, ...}:
+
+let
+ 
+  cdLabel = "NIXOS_INSTALLATION_CD";
+
+  # The configuration file for Grub.
+  grubCfg = 
+    ''
+      default 0
+      timeout 10
+      splashimage /boot/background.xpm.gz
+
+      title Boot from hard disk
+        root (hd0)
+        chainloader +1
+    
+      title NixOS Installer / Rescue
+        kernel /boot/vmlinuz init=/init ${toString config.boot.kernelParams}
+        initrd /boot/initrd
+    '';
+  
+in
+
+{
+  # In stage 1 of the boot, mount the CD/DVD as the root FS by label
+  # so that we don't need to know its device.
+  fileSystems =
+    [ { mountPoint = "/";
+        label = cdLabel;
+      }
+    ];
+
+  # We need AUFS in the initrd to make the CD appear writable.
+  boot.extraModulePackages = [config.boot.kernelPackages.aufs];
+  boot.initrd.extraKernelModules = ["aufs"];
+
+  # Tell stage 1 of the boot to mount a tmpfs on top of the CD using
+  # AUFS.  !!! It would be nicer to make the stage 1 init pluggable
+  # and move that bit of code here.
+  boot.isLiveCD = true;
+
+  # Create the ISO image.
+  system.build.isoImage = import ../../../lib/make-iso9660-image.nix {
+    inherit (pkgs) stdenv perl cdrkit pathsFromGraph;
+    #isoName = "${relName}-${platform}.iso";
+
+    bootable = true;
+    bootImage = "boot/grub/stage2_eltorito";
+
+    #compressImage = ...;
+
+    volumeID = cdLabel;
+
+    # Single files to be copied to fixed locations on the CD.
+    contents =
+      [ { source = "${pkgs.grub}/lib/grub/${if pkgs.stdenv.system == "i686-linux" then "i386-pc" else "x86_64-unknown"}/stage2_eltorito";
+          target = "boot/grub/stage2_eltorito";
+        }
+        { source = pkgs.writeText "menu.lst" grubCfg;
+          target = "boot/grub/menu.lst";
+        }
+        { source = config.boot.kernelPackages.kernel + "/vmlinuz";
+          target = "boot/vmlinuz";
+        }
+        { source = config.system.build.initialRamdisk + "/initrd";
+          target = "boot/initrd";
+        }
+        { source = config.boot.grubSplashImage;
+          target = "boot/background.xpm.gz";
+        }
+      ];
+
+    # Closures to be copied to the Nix store on the CD.
+    storeContents =
+      [ { object = config.system.build.bootStage2;
+          symlink = "/init";
+        }
+        { object = config.system.build.system;
+          symlink = "/system";
+        }
+      ];
+  };
+}