Custom ISO - limit size

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 = [
    <nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix>
  ];

  # 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.

4 Likes