2009-06-11 09:51:27 +00:00
|
|
|
# This module contains the basic configuration for building a NixOS
|
|
|
|
# installation CD.
|
2009-06-05 15:10:15 +00:00
|
|
|
|
2009-11-10 21:42:38 +00:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
2009-06-05 15:10:15 +00:00
|
|
|
|
2009-06-08 22:45:45 +00:00
|
|
|
let
|
|
|
|
|
|
|
|
# We need a copy of the Nix expressions for Nixpkgs and NixOS on the
|
2012-04-23 00:41:37 +00:00
|
|
|
# CD. These are installed into the "nixos" channel of the root
|
|
|
|
# user, as expected by nixos-rebuild/nixos-install.
|
|
|
|
channelSources = pkgs.runCommand "nixos-${config.system.nixosVersion}"
|
|
|
|
{ expr = builtins.readFile ../../../lib/channel-expr.nix; }
|
2009-06-08 22:45:45 +00:00
|
|
|
''
|
2012-04-23 00:41:37 +00:00
|
|
|
mkdir -p $out/nixos
|
|
|
|
cp -prd ${cleanSource ../../..} $out/nixos/nixos
|
|
|
|
cp -prd ${cleanSource <nixpkgs>} $out/nixos/nixpkgs
|
|
|
|
chmod -R u+w $out/nixos/nixos
|
|
|
|
echo -n ${config.system.nixosVersion} > $out/nixos/nixos/.version
|
|
|
|
echo -n "" > $out/nixos/nixos/.version-suffix
|
|
|
|
echo "$expr" > $out/nixos/default.nix
|
2009-06-08 22:45:45 +00:00
|
|
|
'';
|
|
|
|
|
2009-11-10 21:42:38 +00:00
|
|
|
includeSources = true;
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-06-08 22:45:45 +00:00
|
|
|
in
|
|
|
|
|
2009-06-05 15:10:15 +00:00
|
|
|
{
|
2009-06-09 13:14:43 +00:00
|
|
|
require =
|
2012-04-10 21:18:48 +00:00
|
|
|
[ ./memtest.nix
|
|
|
|
./iso-image.nix
|
2010-09-25 09:32:43 +00:00
|
|
|
|
|
|
|
# Profiles of this basic installation CD.
|
2011-11-08 15:58:59 +00:00
|
|
|
../../profiles/all-hardware.nix
|
2010-09-25 09:32:27 +00:00
|
|
|
../../profiles/base.nix
|
2010-09-25 09:32:43 +00:00
|
|
|
../../profiles/installation-device.nix
|
2009-06-09 13:14:43 +00:00
|
|
|
];
|
2009-06-05 15:10:15 +00:00
|
|
|
|
2009-06-09 15:23:03 +00:00
|
|
|
# ISO naming.
|
2011-04-20 10:48:52 +00:00
|
|
|
isoImage.isoName = "${config.isoImage.isoBaseName}-${config.system.nixosVersion}-${pkgs.stdenv.system}.iso";
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2012-04-10 21:08:10 +00:00
|
|
|
isoImage.volumeID = "NIXOS_CD_${config.system.nixosVersion}";
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2012-04-10 22:17:37 +00:00
|
|
|
installer.nixosURL = "http://nixos.org/releases/nixos/nixos-${config.system.nixosVersion}";
|
|
|
|
|
2009-06-05 17:19:30 +00:00
|
|
|
boot.postBootCommands =
|
|
|
|
''
|
2009-06-10 12:34:58 +00:00
|
|
|
# Provide the NixOS/Nixpkgs sources in /etc/nixos. This is required
|
|
|
|
# for nixos-install.
|
2009-11-10 21:42:38 +00:00
|
|
|
${optionalString includeSources ''
|
|
|
|
echo "unpacking the NixOS/Nixpkgs sources..."
|
2012-04-23 00:41:37 +00:00
|
|
|
mkdir -p /nix/var/nix/profiles/per-user/root
|
|
|
|
${config.environment.nix}/bin/nix-env -p /nix/var/nix/profiles/per-user/root/channels -i ${channelSources} --quiet
|
|
|
|
mkdir -m 0700 -p /root/.nix-defexpr
|
|
|
|
ln -s /nix/var/nix/profiles/per-user/root/channels /root/.nix-defexpr/channels
|
2009-11-10 21:42:38 +00:00
|
|
|
''}
|
2011-03-16 15:17:54 +00:00
|
|
|
|
|
|
|
# Make the installer more likely to succeed in low memory
|
|
|
|
# environments. The kernel's overcommit heustistics bite us
|
|
|
|
# fairly often, preventing processes such as nix-worker or
|
|
|
|
# download-using-manifests.pl from forking even if there is
|
|
|
|
# plenty of free memory.
|
|
|
|
echo 1 > /proc/sys/vm/overcommit_memory
|
2009-06-05 17:19:30 +00:00
|
|
|
'';
|
2009-06-08 22:45:45 +00:00
|
|
|
|
2009-06-09 13:27:50 +00:00
|
|
|
# To speed up installation a little bit, include the complete stdenv
|
|
|
|
# in the Nix store on the CD.
|
2010-01-06 20:51:10 +00:00
|
|
|
isoImage.storeContents = [ pkgs.stdenv pkgs.klibc pkgs.klibcShrunk ];
|
2009-06-05 15:10:15 +00:00
|
|
|
}
|