Creating a NixOS live CD: Difference between revisions
imported>Privacy1st m update broken link |
imported>Milahu add section: Building faster |
||
| Line 11: | Line 11: | ||
# This module defines a small NixOS installation CD. It does not | # This module defines a small NixOS installation CD. It does not | ||
# contain any graphical stuff. | # contain any graphical stuff. | ||
{config, pkgs, ...}: | { config, pkgs, ... }: | ||
{ | { | ||
imports = [ | imports = [ | ||
| Line 36: | Line 36: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Testing the image === | |||
To inspect the contents of the ISO image: | |||
<syntaxhighlight lang="console"> | |||
$ mkdir mnt | |||
$ sudo mount -o loop result/iso/nixos-*.iso mnt | |||
$ ls mnt | |||
boot EFI isolinux nix-store.squashfs version.txt | |||
$ umount mnt | |||
</syntaxhighlight> | |||
To boot the ISO image in an emulator: | |||
<syntaxhighlight lang="console"> | |||
$ nix-shell -p qemu | |||
$ qemu-system-x86_64 -cdrom result/iso/nixos-*.iso | |||
</syntaxhighlight> | |||
===SSH=== | ===SSH=== | ||
| Line 72: | Line 90: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Building faster === | |||
The build process is slow because of compression. | |||
Here are some timings for <code>nix-build</code>: | |||
{| class="wikitable" style="margin:auto" | |||
|+ Compression results | |||
|- | |||
! squashfsCompression !! Time !! Size | |||
|- | |||
| <code>lz4</code> || 100s || 59% | |||
|- | |||
| <code>gzip -Xcompression-level 1</code> || 105s || 52% | |||
|- | |||
| <code>gzip</code> || 210s || 49% | |||
|- | |||
| <code>xz -Xdict-size 100%</code> (default) || 450s || 43% | |||
|} | |||
See also: [https://gist.github.com/baryluk/70a99b5f26df4671378dd05afef97fce mksquashfs benchmarks] | |||
If you don't care about file size, you can use a faster compression | |||
by adding this to your <code>iso.nix</code>: | |||
<syntaxhighlight lang="nix"> | |||
{ | |||
isoImage.squashfsCompression = "gzip -Xcompression-level 1"; | |||
} | |||
</syntaxhighlight> | |||
==See also== | ==See also== | ||