Custom ISO - limit size

Hi there

Are there any pointers for how to create a custom ISO image that’s as small as possible?
Right now I’m following these instructions, but I don’t need all the installation stuff and such and a 530MB image seems rather large to me.

I would like to just have a minimal bootable ISO with the packages and the configuration that I defined in my .nix file present.

Does anyone have any specific pointers? Thanks!

1 Like

The <nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix> imports <nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-base.nix> which in turn imports

Now you can have a look at these three files and think about the things that you might want to kill. Here are some ideas:

{ config, lib, pkgs, ... }:

with lib;

  imports = [

  # Probably not a good idea to override, but can shave off some extra kilobytes
  #boot.initrd.availableKernelModules = mkForce [ ... ]

  # If you only need in-tree filesystems
  boot.supportedFilesystems = mkForce [ ];
  # If you don't need non-free firmware
  hardware.enableRedistributableFirmware = mkForce false;

  # If you only want to partition the disk
  environment.systemPackages = mkForce [ pkgs.parted ];

  # If you don't want the docs
  documentation.enable = mkForce false;
  documentation.nixos.enable = mkForce false;

  # If you don't need wifi
  networking.wireless.enable = mkForce false;

  # This is used to pull in stdenv to speed up the installation, so removing it
  # means you have to download it
  system.extraDependencies = mkForce [];

Alternatively you can base your ISO off of <nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix> which does not include anything (not even users). This might be a good option if you don’t want to install from that ISO.