Skip to content

scalvotux/nixos-builder-guestfish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nixos-guestfish-builder

Why?

This was born as an experiment to see if I could bootstrap a full NixOS system basically from nothing with a static build of nix and hey, you can! So I've automated it with guestfish. As how it's configured, this will install a BIOS-bootable virtio installation of NixOS for QEMU into the provided disk image.

Ok, so how does one use this thing?

This thing is pretty much an experiment, so use it at your own risk!

You need:

  • guestfish (of course): use the package provided by your distro or use the example Dockerfile for more isolation!

WARNING: guestfish will try to use KVM acceleration for its VM or it will fallback to tcg and it will be pretty slow. If you use the container be sure to share the /dev/kvm device to the container with the correct privileges. Also, the container uses an unprivileged user.

  • a static build of Nix: you can get it from the NixOS CI system here. Download it, rename it to 'nix_static' and place it into this folder (check the SHA256 of the binary for bonus security points).
  • the disk image: create a QCOW2 disk image called "nixos.qcow2" in this folder.
  • the desired system configuration for the image: place it under the etc/nixos folder of this repo. By default it looks for a nixosConfiguration called "nixos" to build.

An example of a system configuration is already in the etc/nixos folder to start experimenting.

Ok, everything is in place. Now what?

Well, now you can look at the beginning of the guestfish.script file: there are some tunable parameters (for example, logging, num of vcpus, memory, ...) you can set.

Ok, ok, I've tuned it. Now?

Now just run:

guestfish -f guestfish.script

and wait it for complete. At the end, the disk nixos.qcow2 will contain the NixOS system ready to use, with your configuration!

About

Build a NixOS image with guestfish

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors