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
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