DevelopmentThis 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:
kernelThe kernel.initialRamdiskThe initial ramdisk (initrd) for this configuration.bootStage1The stage 1 (initrd) init script.bootStage2The stage 2 init script.etcThe statically computed parts of /etc.upstartJobsAn 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 installerBuilding, 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-installTesting the initrdA 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