3
0
Fork 0
forked from mirrors/nixpkgs

* Installation CD: include a lot of modules (SATA, PATA, Firewire,

USB, some SCSI controllers) in the initrd for mounting the CD.
* Add nix-hardware-scan to the system.
* Upstart: don't use the -v flag.
* Include the NixOS version in the ISO image filename.
* Include testdisk and ms-sys in the CD.
* Some bugfixes in the installer.

svn path=/nixos/trunk/; revision=10556
This commit is contained in:
Eelco Dolstra 2008-02-08 15:59:15 +00:00
parent 1f81bcae40
commit ce250ffb37
15 changed files with 170 additions and 93 deletions

View file

@ -60,6 +60,7 @@ done
# Load some kernel modules. # Load some kernel modules.
export MODULE_DIR=@modulesDir@/lib/modules/ export MODULE_DIR=@modulesDir@/lib/modules/
for i in @modules@; do for i in @modules@; do
echo "trying to load $i..."
modprobe $i modprobe $i
done done

View file

@ -42,7 +42,7 @@ let
in in
assert !autoDetectRootDevice -> mountPoints != []; if !autoDetectRootDevice && mountPoints == [] then abort "You must specify the fileSystems option!" else
substituteAll { substituteAll {
src = ./boot-stage-1-init.sh; src = ./boot-stage-1-init.sh;

View file

@ -119,4 +119,4 @@ fi
# HUP signal. # HUP signal.
export UPSTART_CFG_DIR=/etc/event.d export UPSTART_CFG_DIR=/etc/event.d
setPath "@upstartPath@" setPath "@upstartPath@"
exec /var/run/current-system/upstart/sbin/init -v exec /var/run/current-system/upstart/sbin/init

View file

@ -1,10 +1,14 @@
{ platform ? __currentSystem { platform ? __currentSystem
, relName ?
if builtins.pathExists ../relname
then builtins.readFile ../relname
else "nixos-${builtins.readFile ../VERSION}"
}: }:
rec { rec {
nixpkgsRel = "nixpkgs-0.12pre10072"; nixpkgsRel = "nixpkgs-0.12pre10553";
configuration = { configuration = {
@ -16,9 +20,50 @@ rec {
rootLabel = "NIXOS"; rootLabel = "NIXOS";
extraTTYs = [7 8]; # manual, rogue extraTTYs = [7 8]; # manual, rogue
extraModulePackages = [pkgs.aufs]; extraModulePackages = [pkgs.aufs];
initrd = { initrd = {
extraKernelModules = [ extraKernelModules = [
"aufs" # needed for live-CD operation # The initrd should contain any modules necessary for
# mounting the CD.
# SATA/PATA support.
"ahci"
"ata_piix"
"sata_inic162x" "sata_nv" "sata_promise" "sata_qstor"
"sata_sil" "sata_sil24" "sata_sis" "sata_svw" "sata_sx4"
"sata_uli" "sata_via" "sata_vsc"
"pata_ali" "pata_amd" "pata_artop" "pata_atiixp"
"pata_cs5520" "pata_cs5530" "pata_cs5535" "pata_efar"
"pata_hpt366" "pata_hpt37x" "pata_hpt3x2n" "pata_hpt3x3"
"pata_it8213" "pata_it821x" "pata_jmicron" "pata_marvell"
"pata_mpiix" "pata_netcell" "pata_ns87410" "pata_oldpiix"
"pata_pcmcia" "pata_pdc2027x" "pata_qdi" "pata_rz1000"
"pata_sc1200" "pata_serverworks" "pata_sil680" "pata_sis"
"pata_sl82c105" "pata_triflex" "pata_via"
# "pata_winbond" <-- causes timeouts in sd_mod
# SCSI support (incomplete).
"3w-9xxx" "3w-xxxx" "aic79xx" "aic7xxx" "arcmsr"
# USB support, especially for booting from USB CD-ROM
# drives. Also include USB keyboard support for when
# something goes wrong in stage 1.
"ehci_hcd"
"ohci_hcd"
"usbhid"
"usb_storage"
# Firewire support. Not tested.
"ohci1394" "sbp2"
# Wait for SCSI devices to appear.
"scsi_wait_scan"
# Needed for live-CD operation.
"aufs"
]; ];
}; };
}; };
@ -47,6 +92,8 @@ rec {
script script
export PATH=${pkgs.gnutar}/bin:${pkgs.bzip2}/bin:$PATH export PATH=${pkgs.gnutar}/bin:${pkgs.bzip2}/bin:$PATH
mkdir -p /mnt
${system.nix}/bin/nix-store --load-db < /nix-path-registration ${system.nix}/bin/nix-store --load-db < /nix-path-registration
mkdir -p /etc/nixos/nixos mkdir -p /etc/nixos/nixos
@ -130,6 +177,8 @@ rec {
pkgs.subversion # for nixos-checkout pkgs.subversion # for nixos-checkout
pkgs.w3m # needed for the manual anyway pkgs.w3m # needed for the manual anyway
pkgs.gdb # for debugging Nix pkgs.gdb # for debugging Nix
pkgs.testdisk # useful for repairing boot problems
pkgs.mssys # for writing Microsoft boot sectors / MBRs
]; ];
}; };
@ -177,7 +226,7 @@ rec {
# Get a recent copy of Nixpkgs. # Get a recent copy of Nixpkgs.
nixpkgsTarball = pkgs.fetchurl { nixpkgsTarball = pkgs.fetchurl {
url = configuration.installer.nixpkgsURL + "/" + nixpkgsRel + ".tar.bz2"; url = configuration.installer.nixpkgsURL + "/" + nixpkgsRel + ".tar.bz2";
md5 = "6a793b877e2a4fa79827515902e1dfd8"; md5 = "a6f1cd8486b7d588ecc7d98f5baf6a73";
}; };
@ -200,7 +249,7 @@ rec {
# the initrd produced above, and the closure of the stage 2 init. # the initrd produced above, and the closure of the stage 2 init.
rescueCD = import ../helpers/make-iso9660-image.nix { rescueCD = import ../helpers/make-iso9660-image.nix {
inherit (pkgs) stdenv perl cdrkit; inherit (pkgs) stdenv perl cdrkit;
isoName = "nixos-${platform}.iso"; isoName = "${relName}-${platform}.iso";
# Single files to be copied to fixed locations on the CD. # Single files to be copied to fixed locations on the CD.
contents = [ contents = [

View file

@ -18,14 +18,18 @@ in
initialRamdisk initialRamdisk
kernel kernel
nix nix
nixosCheckout
nixosInstall
nixosRebuild
system system
systemPath systemPath
config config
; ;
inherit (system.nixosTools)
nixosCheckout
nixosHardwareScan
nixosInstall
nixosRebuild
;
nixFallback = system.nix; nixFallback = system.nix;
manifests = system.config.installer.manifests; # exported here because nixos-rebuild uses it manifests = system.config.installer.manifests; # exported here because nixos-rebuild uses it

45
installer/default.nix Normal file
View file

@ -0,0 +1,45 @@
{pkgs, config, nix}:
let
makeProg = args: pkgs.substituteAll (args // {
dir = "bin";
isExecutable = true;
});
in
{
nixosInstall = makeProg {
name = "nixos-install";
src = ./nixos-install.sh;
inherit (pkgs) perl;
inherit nix;
nixpkgsURL = config.installer.nixpkgsURL;
pathsFromGraph = ../helpers/paths-from-graph.pl;
nixClosure = pkgs.runCommand "closure"
{exportReferencesGraph = ["refs" nix];}
"cp refs $out";
};
nixosRebuild = makeProg {
name = "nixos-rebuild";
src = ./nixos-rebuild.sh;
};
nixosCheckout = makeProg {
name = "nixos-checkout";
src = ./nixos-checkout.sh;
};
nixosHardwareScan = makeProg {
name = "nixos-hardware-scan";
src = ./nixos-hardware-scan.pl;
inherit (pkgs) perl;
};
}

View file

@ -1,8 +0,0 @@
{substituteAll}:
substituteAll {
name = "nixos-checkout";
src = ./nixos-checkout.sh;
dir = "bin";
isExecutable = true;
}

View file

@ -1,6 +1,19 @@
#! @shell@ -e #! @shell@ -e
set -x set -x
# Pull the manifests defined in the configuration (the "manifests"
# attribute). Wonderfully hacky *and* cut&pasted from nixos-installer.sh!!!
if test -z "$NIXOS"; then NIXOS=/etc/nixos/nixos; fi
if test -z "$NIXOS_NO_PULL"; then
manifests=$(nix-instantiate --eval-only --xml --strict $NIXOS -A manifests \
| grep '<string' | sed 's^.*"\(.*\)".*^\1^g')
mkdir -p /nix/var/nix/channel-cache
for i in $manifests; do
NIX_DOWNLOAD_CACHE=/nix/var/nix/channel-cache nix-pull $i || true
done
fi
# Obtain Subversion. # Obtain Subversion.
if test -z "$(type -tp svn)"; then if test -z "$(type -tp svn)"; then
#nix-channel --add http://nix.cs.uu.nl/dist/nix/channels-v3/nixpkgs-unstable #nix-channel --add http://nix.cs.uu.nl/dist/nix/channels-v3/nixpkgs-unstable

View file

@ -1,4 +1,4 @@
#! @perl@ -w #! @perl@/bin/perl -w
use File::Spec; use File::Spec;
use File::Basename; use File::Basename;
@ -8,6 +8,12 @@ my @kernelModules = ();
my @initrdKernelModules = (); my @initrdKernelModules = ();
sub debug {
return unless defined $ENV{"DEBUG"};
print STDERR @_;
}
# Read a file, returning undef if the file cannot be opened. # Read a file, returning undef if the file cannot be opened.
sub readFile { sub readFile {
my $filename = shift; my $filename = shift;
@ -66,9 +72,9 @@ sub pciCheck {
chomp $module; chomp $module;
} }
print STDERR "$path: $vendor $device $class"; debug "$path: $vendor $device $class";
print STDERR " $module" if defined $module; debug " $module" if defined $module;
print STDERR "\n"; debug "\n";
if (defined $module) { if (defined $module) {
# See the bottom of http://pciids.sourceforge.net/pci.ids for # See the bottom of http://pciids.sourceforge.net/pci.ids for
@ -144,9 +150,9 @@ sub usbCheck {
chomp $module; chomp $module;
} }
print STDERR "$path: $class $subclass $protocol"; debug "$path: $class $subclass $protocol";
print STDERR " $module" if defined $module; debug " $module" if defined $module;
print STDERR "\n"; debug "\n";
if (defined $module) { if (defined $module) {
if (# Mass-storage controller. Definitely important. if (# Mass-storage controller. Definitely important.
@ -195,9 +201,9 @@ my $initrdKernelModules = toNixExpr(removeDups @initrdKernelModules);
my $kernelModules = toNixExpr(removeDups @kernelModules); my $kernelModules = toNixExpr(removeDups @kernelModules);
## This is a generated file. Do not modify!
## Make changes to /etc/nixos/configuration.nix instead.
print <<EOF ; print <<EOF ;
# This is a generated file. Do not modify!
# Make changes to /etc/nixos/configuration.nix instead.
{ {
boot = { boot = {
initrd = { initrd = {

View file

@ -1,19 +0,0 @@
{ perl, runCommand, substituteAll, nix
, # URL of the Nixpkgs distribution that the installer will pull.
# Leave empty for a pure source distribution.
nixpkgsURL ? ""
}:
substituteAll {
name = "nixos-install";
src = ./nixos-install.sh;
dir = "bin";
isExecutable = true;
inherit nix nixpkgsURL perl;
pathsFromGraph = ../helpers/paths-from-graph.pl;
nixClosure = runCommand "closure"
{exportReferencesGraph = ["refs" nix];}
"cp refs $out";
}

View file

@ -56,13 +56,13 @@ mount --bind /proc $mountPoint/proc
mount --bind /sys $mountPoint/sys mount --bind /sys $mountPoint/sys
cleanup() { cleanup() {
# !!! don't umount any we didn't mount ourselves # !!! don't umount anything we didn't mount ourselves
for i in $(grep -F "$mountPoint" /proc/mounts \ for i in $(grep -F "$mountPoint" /proc/mounts \
| @perl@/bin/perl -e 'while (<>) { /^\S+\s+(\S+)\s+/; print "$1\n"; }' \ | @perl@/bin/perl -e 'while (<>) { /^\S+\s+(\S+)\s+/; print "$1\n"; }' \
| sort -r); | sort -r);
do do
if test "$i" != "$mountPoint"; then if test "$i" != "$mountPoint" -a "$i" != / -a -e "$i"; then
umount $i umount $i || true
fi fi
done done
} }
@ -149,6 +149,8 @@ chroot $mountPoint @nix@/bin/nix-env \
# Make a backup of the old NixOS/Nixpkgs sources. # Make a backup of the old NixOS/Nixpkgs sources.
echo "copying NixOS/Nixpkgs sources to /etc/nixos...." echo "copying NixOS/Nixpkgs sources to /etc/nixos...."
backupTimestamp=$(date "+%Y%m%d%H%M%S")
targetNixos=$mountPoint/etc/nixos/nixos targetNixos=$mountPoint/etc/nixos/nixos
if test -e $targetNixos; then if test -e $targetNixos; then
mv $targetNixos $targetNixos.backup-$backupTimestamp mv $targetNixos $targetNixos.backup-$backupTimestamp

View file

@ -1,8 +0,0 @@
{substituteAll}:
substituteAll {
name = "nixos-rebuild";
src = ./nixos-rebuild.sh;
dir = "bin";
isExecutable = true;
}

View file

@ -26,7 +26,7 @@ for i in $(cd $staticEtc && find * -type l); do
if test -e "$staticEtc/$i.mode"; then if test -e "$staticEtc/$i.mode"; then
# Create a regular file in /etc. # Create a regular file in /etc.
cp $staticEtc/$i /etc/$i cp $staticEtc/$i /etc/$i
chown root.root /etc/$i chown 0.0 /etc/$i
chmod "$(cat "$staticEtc/$i.mode")" /etc/$i chmod "$(cat "$staticEtc/$i.mode")" /etc/$i
else else
# Create a symlink in /etc. # Create a symlink in /etc.

View file

@ -125,7 +125,7 @@
extraModulePackages = mkOption { extraModulePackages = mkOption {
default = []; default = [];
example = [pkgs.aufs pkgs.nvidiaDriver]; example = [pkgs.aufs pkgs.nvidiaDrivers];
description = '' description = ''
A list of additional packages supplying kernel modules. A list of additional packages supplying kernel modules.
''; '';
@ -146,6 +146,12 @@
kernelModules = mkOption { kernelModules = mkOption {
default = [ default = [
# Note: most of these (especially the SATA/PATA modules)
# shouldn't be included by default since nixos-hardware-scan
# detects them, but I'm keeping them for now for backwards
# compatibility.
# Some SATA/PATA stuff.
"ahci" "ahci"
"sata_nv" "sata_nv"
"sata_via" "sata_via"
@ -153,11 +159,14 @@
"sata_uli" "sata_uli"
"ata_piix" "ata_piix"
"pata_marvell" "pata_marvell"
# Standard SCSI stuff.
"sd_mod" "sd_mod"
"sr_mod" "sr_mod"
"ide-cd" # Standard IDE stuff.
"ide-disk" "ide_cd"
"ide-generic" "ide_disk"
"ide_generic"
# Filesystems.
"ext3" "ext3"
# Support USB keyboards, in case the boot fails and we only have # Support USB keyboards, in case the boot fails and we only have
# a USB keyboard. # a USB keyboard.

View file

@ -119,19 +119,9 @@ rec {
}; };
# The installer. # NixOS installation/updating tools.
nixosInstall = import ../installer/nixos-install.nix { nixosTools = import ../installer {
inherit (pkgs) perl runCommand substituteAll; inherit pkgs config nix;
inherit nix;
nixpkgsURL = config.installer.nixpkgsURL;
};
nixosRebuild = import ../installer/nixos-rebuild.nix {
inherit (pkgs) substituteAll;
};
nixosCheckout = import ../installer/nixos-checkout.nix {
inherit (pkgs) substituteAll;
}; };
@ -208,20 +198,18 @@ rec {
# The packages you want in the boot environment. # The packages you want in the boot environment.
systemPathList = (if config.environment.cleanStart then systemPathList = [
[
# Better leave them here - they are small, needed, # Better leave them here - they are small, needed,
# and hard to refer from anywhere outside. # and hard to refer from anywhere outside.
modprobe modprobe # must take precedence over module_init_tools
nix nix
nixosInstall nixosTools.nixosInstall
nixosRebuild nixosTools.nixosRebuild
nixosCheckout nixosTools.nixosCheckout
nixosTools.nixosHardwareScan
setuidWrapper setuidWrapper
] ]
else ++ pkgs.lib.optionals (!config.environment.cleanStart) [
[
modprobe # must take precedence over module_init_tools
pkgs.bashInteractive # bash with ncurses support pkgs.bashInteractive # bash with ncurses support
pkgs.bzip2 pkgs.bzip2
pkgs.coreutils pkgs.coreutils
@ -263,17 +251,12 @@ rec {
pkgs.usbutils pkgs.usbutils
pkgs.utillinux pkgs.utillinux
pkgs.wirelesstools pkgs.wirelesstools
nix ]
nixosInstall ++ pkgs.lib.optional config.security.sudo.enable pkgs.sudo
nixosRebuild ++ pkgs.lib.optional config.networking.defaultMailServer.directDelivery pkgs.ssmtp
nixosCheckout
setuidWrapper
])
++ pkgs.lib.optional (config.security.sudo.enable) pkgs.sudo
++ pkgs.lib.optional (config.networking.defaultMailServer.directDelivery) pkgs.ssmtp
++ pkgs.lib.concatLists (map (job: job.extraPath) upstartJobs.jobs) ++ pkgs.lib.concatLists (map (job: job.extraPath) upstartJobs.jobs)
++ (config.environment.extraPackages) pkgs ++ config.environment.extraPackages pkgs
++ pkgs.lib.optional (config.fonts.enableFontDir) fontDir; ++ pkgs.lib.optional config.fonts.enableFontDir fontDir;
# We don't want to put all of `startPath' and `path' in $PATH, since # We don't want to put all of `startPath' and `path' in $PATH, since