2010-02-16 00:27:51 +01:00
|
|
|
# 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.tarball.
|
|
|
|
|
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
options = {
|
|
|
|
tarball.contents = mkOption {
|
|
|
|
example =
|
|
|
|
[ { source = pkgs.memtest86 + "/memtest.bin";
|
|
|
|
target = "boot/memtest.bin";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
description = ''
|
|
|
|
This option lists files to be copied to fixed locations in the
|
|
|
|
generated ISO image.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
tarball.storeContents = mkOption {
|
|
|
|
example = [pkgs.stdenv];
|
|
|
|
description = ''
|
|
|
|
This option lists additional derivations to be included in the
|
|
|
|
Nix store in the generated ISO image.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
versionFile = pkgs.writeText "nixos-version" config.system.nixosVersion;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
require = options;
|
|
|
|
|
|
|
|
# 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.
|
2011-08-15 00:01:58 +02:00
|
|
|
fileSystems = [ ];
|
2010-02-16 00:27:51 +01:00
|
|
|
|
|
|
|
# boot.initrd.availableKernelModules = [ "mvsdio" "mmc_block" "reiserfs" "ext3" "ext4" ];
|
|
|
|
|
|
|
|
# boot.initrd.kernelModules = [ "rtc_mv" ];
|
|
|
|
|
|
|
|
# Closures to be copied to the Nix store on the CD, namely the init
|
|
|
|
# script and the top-level system configuration directory.
|
|
|
|
tarball.storeContents =
|
2010-09-14 00:10:25 +02:00
|
|
|
[ { object = config.system.build.toplevel;
|
2010-02-16 00:27:51 +01:00
|
|
|
symlink = "/var/run/current-system";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
# Individual files to be included on the CD, outside of the Nix
|
|
|
|
# store on the CD.
|
|
|
|
tarball.contents =
|
2010-09-08 18:53:36 +02:00
|
|
|
[ { source = config.system.build.initialRamdisk + "/initrd";
|
2010-02-16 00:27:51 +01:00
|
|
|
target = "/boot/initrd";
|
|
|
|
}
|
|
|
|
{ source = versionFile;
|
|
|
|
target = "/nixos-version.txt";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
# Create the tarball
|
|
|
|
system.build.tarball = import ../../../lib/make-system-tarball.nix {
|
|
|
|
inherit (pkgs) stdenv perl xz pathsFromGraph;
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2010-02-16 00:27:51 +01:00
|
|
|
inherit (config.tarball) contents storeContents;
|
|
|
|
};
|
|
|
|
|
2011-08-15 16:37:00 +02:00
|
|
|
# Otherwise it will collide with the 'ip=dhcp' kernel autoconfig.
|
|
|
|
networking.useDHCP = false;
|
|
|
|
|
2010-02-16 00:27:51 +01:00
|
|
|
boot.postBootCommands =
|
|
|
|
''
|
|
|
|
# After booting, register the contents of the Nix store on the
|
|
|
|
# CD in the Nix database in the tmpfs.
|
2011-08-15 00:01:58 +02:00
|
|
|
if [ -f /nix-path-registration ]; then
|
|
|
|
${config.environment.nix}/bin/nix-store --load-db < /nix-path-registration &&
|
2011-08-15 16:37:00 +02:00
|
|
|
rm /nix-path-registration
|
2011-08-15 00:01:58 +02:00
|
|
|
fi
|
2010-02-16 00:27:51 +01:00
|
|
|
|
|
|
|
# nixos-rebuild also requires a "system" profile and an
|
|
|
|
# /etc/NIXOS tag.
|
|
|
|
touch /etc/NIXOS
|
2011-10-30 16:19:58 +01:00
|
|
|
${config.environment.nix}/bin/nix-env -p /nix/var/nix/profiles/system --set /var/run/current-system
|
2010-02-16 00:27:51 +01:00
|
|
|
'';
|
|
|
|
}
|