Installing a custom ISO from USB to HDD

Hi All,

For starters, we’re completely new to NixOS and are attempting to bootstrap ourselves, but running into issues when attempting to install a custom image from a USB.

Using the instructions outlined @ Building bootable ISO image, we created a ‘myimage.nix’ file containing:

{ pkgs, modulesPath, lib, ... }: {
  imports = [
    "${modulesPath}/installer/cd-dvd/installation-cd-graphical-gnome.nix"
  ];

  # use the latest Linux kernel
  boot.kernelPackages = pkgs.linuxPackages_latest;

  # Needed for https://github.com/NixOS/nixpkgs/issues/58959
  boot.supportedFilesystems = lib.mkForce [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" "ntfs" "cifs" ];
}

We then executed the following commands:

NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/74e2faf5965a12e8fa5cff799b1b19c6cd26b0e3.tar.gz 
nix-shell -p nixos-generators --run "nixos-generate --format iso --configuration ./myimage.nix -o result"

Resulting in an ISO, which we then burned to a USB stick. So far, so good … :slight_smile:

We then booted from this USB stick, and after a few seconds, our custom NixOS image booted from the stick – and we smiled with great satisfaction!

We then began looking for the ‘graphical installer’ to install the image on the computer – but came up short.

Clearly, we are missing something silly here. :frowning:

Can anyone explain how we can build a custom image with custom packages, filesystem, etc. that we can then simply burn to a USB stick, boot and install onto your average PC?

Apologies in advance for the newbie question.

Thanks.

1 Like

You are modifying the iso you are booting into, not the system you are installing. After you have booted the default ISO, formatted the disk and generated config, you can modify the files in /mnt/etc/nixos/ by your liking and the nixos-install will already install your custom config.

@Sandro Yes, upon thinking abut it a bit more, our approach is/was off kilter as you’ve pointed out.

Taking a step back, the problem we’re attempting to solve is this; we want to automate the setup/configuration of an appliance (a purpose-build custom pc with fixed hardware and software) to ensure quality while minimizing errors and manufacturing time & costs.

We recently discovered, the NixOS, the Nix package manager, and Nix language and after scanning the docs thought its features would be a good fit – thus we’re here attempting to vet it.

Two approaches to solving this problem come to mind:

  1. Capture/record the installations choices made via the current installer (text or graphical) to be used later to automate the installation process
    Note, this approach assumes there are recording/playback features built into the current installers.
  2. Craft a custom installer to carry out this job.
    Note, do-able we’re sure, but possibly requires special skills, and knowledge and untimely.

Of course, once the initial installation process was completed, standard nixos-rebuild or equivalent commands could/would be used to further finalize the process.

We’re open to a variety of solutions including partial solutions; again our goal is to up our quality while reducing over assembly time/costs.

Thoughts/suggestions?

maybe don’t use this, it pulls a lot of things.
you can declare gnome and X in your configuration file.

Beyond the contents of the configuration.nix you want for the end machine (the build on the pc), the rest of the steps are basically just disk preparation: partitioning, making and mounting filesystems.

Since you have a fixed-configuration PC, this should be easy to capture as a shell script, e.g. in my case:

DISK = /dev/CHOOSE_YOUR_DISK

sgdisk     --zap-all               $DISK
sgdisk     -n1:1M:+512M   -t1:EF00 $DISK
sgdisk     -n2:0:+2G      -t2:BE00 $DISK
sgdisk     -n4:-8G:0      -t4:8200 $DISK
sgdisk     -n3:0:0        -t3:BF00 $DISK

zpool create ...

You can have the iso builder include that on the iso, of course. And you might well want the software config in the iso similar to the appliance (for “liveCD” testing and recovery). Or you might want the iso to be an unattended, unconditional installer that runs the script and sets up the disk without further interaction.