Development This chapter has some random notes on hacking on NixOS.
Building specific parts of NixOS $ nix-build /etc/nixos/nixos attr where attr is an attribute in /etc/nixos/nixos/default.nix. Attributes of interest include: kernel The kernel. initialRamdisk The initial ramdisk (initrd) for this configuration. bootStage1 The stage 1 (initrd) init script. bootStage2 The stage 2 init script. etc The statically computed parts of /etc. upstartJobs An attribute set containing the Upstart jobs. For instance, the sshd Upstart job can be built by doing nix-build /etc/nixos/nixos -A tests.upstartJobs.sshd.
Testing the installer Building, burning, and booting from an installation CD is rather tedious, so here is a quick way to see if the installer works properly: $ nix-build .../nixos/configuration/rescue-cd.nix -A system.nixosInstall $ dd if=/dev/zero of=diskimage seek=2G count=0 bs=1 $ yes | mke2fs -j diskimage $ mount -o loop diskimage /mnt $ ./result/bin/nixos-install
Testing the <literal>initrd</literal> A quick way to test whether the kernel and the initial ramdisk boot correctly is to use QEMU’s and options: $ nix-build /etc/nixos/nixos -A initialRamdisk -o initrd $ nix-build /etc/nixos/nixos -A kernel -o kernel $ qemu-system-x86_64 -kernel ./kernel/vmlinuz -initrd ./initrd/initrd -hda /dev/null