2010-02-15 23:27:51 +00:00
|
|
|
# This module contains the basic configuration for building a NixOS
|
|
|
|
# installation CD.
|
|
|
|
|
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
pkgs2storeContents = l : map (x: { object = x; symlink = "none"; }) l;
|
|
|
|
|
2011-08-14 22:01:58 +00:00
|
|
|
# For PXE kernel loading
|
|
|
|
pxeconfig = pkgs.writeText "pxeconfig-default" ''
|
|
|
|
default menu.c32
|
|
|
|
prompt 0
|
|
|
|
|
|
|
|
label bootlocal
|
|
|
|
menu default
|
|
|
|
localboot 0
|
|
|
|
timeout 80
|
|
|
|
TOTALTIMEOUT 9000
|
|
|
|
|
|
|
|
label nixos
|
2011-08-15 14:37:00 +00:00
|
|
|
MENU LABEL ^NixOS using nfsroot
|
2011-08-14 22:01:58 +00:00
|
|
|
KERNEL bzImage
|
2011-08-15 14:37:00 +00:00
|
|
|
append ip=dhcp nfsroot=/home/pcroot systemConfig=${config.system.build.toplevel} init=${config.system.build.toplevel}/init
|
|
|
|
|
|
|
|
# I don't know how to make this boot with nfsroot (using the initrd)
|
|
|
|
label nixos_initrd
|
|
|
|
MENU LABEL NixOS booting the poor ^initrd.
|
|
|
|
KERNEL bzImage
|
|
|
|
append initrd=initrd ip=dhcp nfsroot=/home/pcroot systemConfig=${config.system.build.toplevel} init=${config.system.build.toplevel}/init
|
2011-08-14 22:01:58 +00:00
|
|
|
|
|
|
|
label memtest
|
|
|
|
MENU LABEL ^Memtest86+
|
2011-08-15 14:37:00 +00:00
|
|
|
KERNEL memtest
|
|
|
|
'';
|
|
|
|
|
|
|
|
dhcpdExampleConfig = pkgs.writeText "dhcpd.conf-example" ''
|
|
|
|
# Example configuration for booting PXE.
|
|
|
|
allow booting;
|
|
|
|
allow bootp;
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2011-08-15 14:37:00 +00:00
|
|
|
# Adapt this to your network configuration.
|
|
|
|
option domain-name "local";
|
|
|
|
option subnet-mask 255.255.255.0;
|
|
|
|
option broadcast-address 192.168.1.255;
|
|
|
|
option domain-name-servers 192.168.1.1;
|
|
|
|
option routers 192.168.1.1;
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2011-08-15 14:37:00 +00:00
|
|
|
# PXE-specific configuration directives...
|
|
|
|
# Some BIOS don't accept slashes for paths inside the tftp servers,
|
|
|
|
# and will report Access Violation if they see slashes.
|
|
|
|
filename "pxelinux.0";
|
|
|
|
# For the TFTP and NFS root server. Set the IP of your server.
|
|
|
|
next-server 192.168.1.34;
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2011-08-15 14:37:00 +00:00
|
|
|
subnet 192.168.1.0 netmask 255.255.255.0 {
|
|
|
|
range 192.168.1.50 192.168.1.55;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
|
|
|
readme = pkgs.writeText "readme.txt" ''
|
|
|
|
Let all the files in the system tarball sit in a directory served by NFS (the NFS root)
|
|
|
|
like this in exportfs:
|
|
|
|
/home/pcroot 192.168.1.0/24(rw,no_root_squash,no_all_squash)
|
|
|
|
|
|
|
|
Run "exportfs -a" after editing /etc/exportfs, for the nfs server to be aware of the
|
|
|
|
changes.
|
|
|
|
|
|
|
|
Use a tftp server serving the root of boot/ (from the system tarball).
|
|
|
|
|
|
|
|
In order to have PXE boot, use the boot/dhcpd.conf-example file for your dhcpd server,
|
|
|
|
as it will point your PXE clients to pxelinux.0 from the tftp server. Adapt the
|
|
|
|
configuration to your network.
|
|
|
|
|
|
|
|
Adapt the pxelinux configuration (boot/pxelinux.cfg/default) to set the path to your
|
|
|
|
nfrroot. If you use ip=dhcp in the kernel, the nfs server ip will be taken from
|
|
|
|
dhcp and so you don't have to specify it.
|
|
|
|
|
|
|
|
The linux in bzImage includes network drivers for some usual cards.
|
|
|
|
|
|
|
|
|
|
|
|
QEMU Testing
|
|
|
|
---------------
|
|
|
|
|
|
|
|
You can test qemu pxe boot without having a DHCP server adapted, but having nfsroot,
|
|
|
|
like this:
|
2011-09-14 18:20:50 +00:00
|
|
|
qemu-system-x86_64 -tftp /home/pcroot/boot -net nic -net user,bootfile=pxelinux.0 -boot n
|
2011-08-15 14:37:00 +00:00
|
|
|
|
|
|
|
I don't know how to use NFS through the qemu '-net user' though.
|
|
|
|
|
|
|
|
|
|
|
|
QEMU Testing with NFS root and bridged network
|
|
|
|
-------------------------------------------------
|
|
|
|
|
|
|
|
This allows testing with qemu as any other host in your LAN.
|
|
|
|
|
|
|
|
Testing with the real dhcpd server requires setting up a bridge and having a tap device.
|
|
|
|
tunctl -t tap0
|
|
|
|
brctl addbr br0
|
|
|
|
brctl addif br0 eth0
|
|
|
|
brctl addif tap0 eth0
|
|
|
|
ifconfig eth0 0.0.0.0 up
|
|
|
|
ifconfig tap0 0.0.0.0 up
|
|
|
|
ifconfig br0 up # With your ip configuration
|
|
|
|
|
|
|
|
Then you can run qemu:
|
|
|
|
qemu-system-x86_64 -boot n -net tap,ifname=tap0,script=no -net nic,model=e1000
|
2011-08-14 22:01:58 +00:00
|
|
|
'';
|
|
|
|
|
2010-02-15 23:27:51 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2011-11-08 15:58:59 +00:00
|
|
|
require =
|
|
|
|
[ ./system-tarball.nix
|
|
|
|
|
|
|
|
# Profiles of this basic installation.
|
|
|
|
../../profiles/all-hardware.nix
|
|
|
|
../../profiles/base.nix
|
|
|
|
../../profiles/installation-device.nix
|
|
|
|
];
|
2010-02-15 23:27:51 +00:00
|
|
|
|
|
|
|
# To speed up further installation of packages, include the complete stdenv
|
|
|
|
# in the Nix store of the tarball.
|
|
|
|
tarball.storeContents = pkgs2storeContents [ pkgs.stdenv pkgs.klibc pkgs.klibcShrunk ];
|
|
|
|
|
2010-09-08 16:53:36 +00:00
|
|
|
tarball.contents =
|
2010-09-17 17:25:46 +00:00
|
|
|
[ { source = config.boot.kernelPackages.kernel + "/" + config.system.boot.loader.kernelFile;
|
2010-09-16 19:24:52 +00:00
|
|
|
target = "/boot/" + config.system.boot.loader.kernelFile;
|
2010-09-08 16:53:36 +00:00
|
|
|
}
|
2011-08-14 22:01:58 +00:00
|
|
|
{ source = "${pkgs.syslinux}/share/syslinux/pxelinux.0";
|
|
|
|
target = "/boot/pxelinux.0";
|
|
|
|
}
|
|
|
|
{ source = "${pkgs.syslinux}/share/syslinux/menu.c32";
|
|
|
|
target = "/boot/menu.c32";
|
|
|
|
}
|
|
|
|
{ source = pxeconfig;
|
|
|
|
target = "/boot/pxelinux.cfg/default";
|
|
|
|
}
|
2011-08-15 14:37:00 +00:00
|
|
|
{ source = readme;
|
|
|
|
target = "/readme.txt";
|
|
|
|
}
|
|
|
|
{ source = dhcpdExampleConfig;
|
|
|
|
target = "/boot/dhcpd.conf-example";
|
|
|
|
}
|
2011-08-14 22:01:58 +00:00
|
|
|
{ source = "${pkgs.memtest86}/memtest.bin";
|
2011-08-15 14:37:00 +00:00
|
|
|
# We can't leave '.bin', because pxelinux interprets this specially,
|
|
|
|
# and it would not load the image fine.
|
|
|
|
# http://forum.canardpc.com/threads/46464-0104-when-launched-via-pxe
|
|
|
|
target = "/boot/memtest";
|
2011-08-14 22:01:58 +00:00
|
|
|
}
|
2010-09-08 16:53:36 +00:00
|
|
|
];
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2010-02-15 23:27:51 +00:00
|
|
|
# Allow sshd to be started manually through "start sshd". It should
|
|
|
|
# not be started by default on the installation CD because the
|
|
|
|
# default root password is empty.
|
2010-03-11 17:02:53 +00:00
|
|
|
services.openssh.enable = true;
|
2010-10-31 19:34:39 +00:00
|
|
|
jobs.openssh.startOn = pkgs.lib.mkOverrideTemplate 50 {} "";
|
2011-08-14 22:01:58 +00:00
|
|
|
|
|
|
|
boot.kernelPackages = pkgs.linuxPackages_2_6_39;
|
|
|
|
nixpkgs.config = {
|
|
|
|
packageOverrides = p: rec {
|
|
|
|
linux_2_6_39 = p.linux_2_6_39.override {
|
|
|
|
extraConfig = ''
|
|
|
|
# Enable drivers in kernel for most NICs.
|
|
|
|
E1000 y
|
|
|
|
# E1000E y
|
|
|
|
# ATH5K y
|
|
|
|
8139TOO y
|
|
|
|
NE2K_PCI y
|
|
|
|
ATL1 y
|
|
|
|
ATL1E y
|
|
|
|
ATL1C y
|
|
|
|
|
|
|
|
# Enable nfs root boot
|
|
|
|
IP_PNP y
|
|
|
|
IP_PNP_DHCP y
|
|
|
|
NFS_FS y
|
|
|
|
ROOT_NFS y
|
|
|
|
|
|
|
|
# Enable devtmpfs
|
|
|
|
DEVTMPFS y
|
|
|
|
DEVTMPFS_MOUNT y
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2010-02-15 23:27:51 +00:00
|
|
|
}
|