Skip to content

Instantly share code, notes, and snippets.

@lordcirth
Last active November 21, 2019 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lordcirth/e949013cadfbddb1446d590d7381ffaa to your computer and use it in GitHub Desktop.
Save lordcirth/e949013cadfbddb1446d590d7381ffaa to your computer and use it in GitHub Desktop.
NixOS image build
# Everything is as non-root user
# Install Nix:
# https://nixos.org/nix/
# (Alternatively a NixOS VM using https://nixos.org/nixos/download.html )
sudo apt install libvirt-bin
# Requires new login shell
sudo usermod -a -G kvm $USER
# Add nix build users to kvm group as well
for i in {1..32}; do sudo usermod -a -G kvm nixbld${i}; done
# Hold current stable. "nixos-stable" will track latest stable, -unstable, etc.
nix-channel --add https://nixos.org/channels/nixos-19.09 nixos
nix-channel --update
git clone https://github.com/lordcirth/nixos_configs
cd nixos_configs
# import ./core.nix and build 'config.system.build.core' using nixpkgs/nixos,
# To use a separate nixpkgs than the system channel, nix-build takes, eg, "-I ../nixpkgs"
nix-build '<nixpkgs/nixos>' --arg configuration ./core.nix -A config.system.build.core
# 1.3GB
ls -lh ./result/
total 1.3G
-r--r--r-- 1 root root 4.0G Dec 31 1969 nixos.img
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment