The NixOS wiki is outdated and is being shut down. If you wish to add or improve NixOS documentation, please grab a ticket from the Move the wiki! milestone.

Creating a NixOS live CD

From Nix Wiki
(Redirected from Creating a Nix OS live CD)
Jump to: navigation, search


creating a modified NIXOS live CD out of a working nixos installation gives you the benefits:

  • verify what is included
  • no need to download it
  • it is easy to add your own programs to the image

how to build a live image

we will use the NIXPKGS variable, which points to the nixpkgs/nixos checkouts, see Create and debug nix packages

run command as follow (for 64 bit):

nix-build -A iso_graphical.x86_64-linux $NIXPKGS/nixos/release.nix

for 32 bit:

nix-build -A iso_graphical.i686-linux $NIXPKGS/nixos/release.nix

once the building process is over, you should see multiple nix distributions built (for multiple archs). See contents to find iso image path:

$ cat /nix/store/2y4bivmrzg4d2dgby2b7prvfj7445088-nixos-iso-0.1pre1234/nix-support/hydra-build-products 
file iso /nix/store/94rrfklbk2hcqhkr4627vsrlprlyva50-iso9660-image/iso/nixos-minimal-0.1pre1234-i686-linux-test.iso

and copy the image to your USB drive (or use unetbootin).

Note: Each built .iso image requires a lot of disk space, therefore, do not forget to remove images you do not need anymore:
$ cd /nix/store; find . -name *.iso
find . -name *.iso  5,71s user 11,69s system 14% cpu 1:58,92 total

Now let's remove one of them:

nix-store --delete ./jfd0i1cmjy2gi0829dhxqhpzkhc20wq7-iso9660-image
finding garbage collector roots...
deleting ‘/nix/store/0f8x9if7ip66d3mm250i5qk2acm60g61-nixos-iso-15.05pre56789.gfedcba’
deleting ‘/nix/store/jfd0i1cmjy2gi0829dhxqhpzkhc20wq7-iso9660-image’
deleting ‘/nix/store/trash’
deleting unused links...
note: currently hard linking saves -0.00 MiB
2 store paths deleted, 952.82 MiB freed

adding additional software to the image

the basic script /etc/nixos/nixos/release.nix contains several entry points for custom images. as we are using -A iso_minimal have a look at: iso_minimal which will redirect us to:

  • ./modules/installer/cd-dvd/installation-cd-minimal.nix -> /etc/nixos/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix
# This module defines a small NixOS installation CD.  It does not
# contain any graphical stuff.
{config, pkgs, ...}:
  require = [

declarativly adding password/pubkey(s)

setting a default password on the boot cdrom (so that nobody can login using the default 'unset' password:


or use this:

  users.extraUsers.root.openssh.authorizedKeys.keys = [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDkWOKwPJqTu//XC8TsS8sDFVvrhluf5vyKaANxe9A5MJNAoSffOLogYA+igqvaWDZiHLZ7zaSL4IR30zw2Nr9UvMsHePBQLdUTsJxCxFI4ClidxiFN5bLhxhjz2Dyw0GaePLLN38TSSkI2Web2U8j6iJhx+u3RwxjnuztTXrgZsWvBh/1Z++XeGfCi4zCzGHtBIoY3bGtO9YqFSZVq+uePLQFdnNCeIFOgKu70yfEV+WpUAJDMF51MTCc574sDPLZB3lpE2YVggpVXXrJ0lm/ANtZ0UPeBPaZf7sW5vNrMAuW7btbywIzIj0tWmJw1kSZliyqS+E0XYICUvENrZpjt joachim@lenovo-t530" ];
Note: use ssh-keygen -b 4096 to create a key-pair and add the as shown above

one the client do this:

   $ ssh -i ~/.ssh/id_rsa

to later access the booted live image on a machine.

software installation inside the 'once' deployed and booted image

in case you have booted from your image you can add software as described here:

Without NixOS you need to supply the source instead of /etc/nixos/nixos.


  • See also section "Building your own NixOS CD" of the NixOS manual.