I am using nixos-generate -f iso -c image.nix to generate a custom nixos.iso file.
I want to add a directory to the generated iso though. My first thought was using an override of isoImage.contents as hinted at iso-image.nix, but now I am stuck, the nixos-generate telling me:
error: Cannot merge definitions of isoImage.contents' given in /home/me/nixos2qemuvm/machine-config.nixâ and `/home/me/.nix-defexpr/channels/nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nixâ.
I havenât tried this, but I think the ââ is wrong here. isoImage.contents appears to be a list of objects. Youâre providing a string.
Something like this will probably work better:
However there is probably another catch: The builder is probably run in a sandbox and will probably be unable to access anything not referenced by a derivation.
A workaround for that could be to use a path instead of a string as the source. This will copy /home/my/thisfolder to the nix store for the build (think about if thatâs actually ok for you).
So i suggest something like this:
I need to correct some of my assumptions in the examples I gave above as those were wrong.
First the nixos-generate -f iso -c image.nix call given with the image.nix listed would generate an iso file indeed and still would be possible to boot from using qemu but - and this is the error i guess - writing it to an usbstick and trying to boot it will lead to an endless Booting kernel message best case.
What to do instead ?
Take the following iso.nix and iso-config.nix files to actually create correct iso file (Iâll provide vm.nix and vm-config.nix further below):
# iso.nix
# nix-build '<nixpkgs/nixos>' -A config.system.build.isoImage --arg configuration "{ imports = [ ./iso.nix ]; }"
# or nixos-generate -f iso -c iso.nix
# This module defines a small NixOS installation CD. It does not
# contain any graphical stuff.
{config, pkgs, ...}:
{
imports = [
<nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix>
./iso-config.nix
# Provide an initial copy of the NixOS channel so that the user
# doesn't need to run "nix-channel --update" first.
<nixpkgs/nixos/modules/installer/cd-dvd/channel.nix>
];
}