u/GyroTech

Custom ISO installer or is it possible to make variant of actual machine into ISO installer
▲ 4 r/NixOS

Custom ISO installer or is it possible to make variant of actual machine into ISO installer

Hi all!

I've been building out my NixOS deployments and am moving into the dendritic pattern (following the awesome guide from Doc-Steve) and am really enjoying it.

One of my small issues is that my destkop and laptop are different enough that using the standard installer ISO on either is frustrating. My laptop needs wifi and an es keymap, desktop a static IP config and colemak, just as a couple of examples.

My question is if there is some way to "detect" what the output of the build is going to be, and include different modules based on that. E.G.

{
  inputs,
  ...
}:
{
  flake.nixosConfigurations = inputs.self.lib.mkNixos "x86_64-linux" "laptop-02";

  flake.modules.nixos."laptop-02" =
    { pkgs, lib, ... }:
    {
      lib.mkMerge [
      {
        imports = with inputs.self.modules.nixos; [
          "${inputs.nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
          systemd-boot
          tpmHostSecrets
        ];
      }
      (lib.mkIf <building-an-ISO> {
        imports = with inputs.self.modules.nixos; [
          system-minimal
        ];
      })
      (lib.mkIf <not-building-an-ISO> {
        imports = with inputs.self.modules.nixos; [
          system-graphical
          tools-dev
          tools-maint
          tools-cloud
          tools-k8s
        ];
      })

      boot.kernelPackages = pkgs.linuxPackages_latest;

      time.timeZone = "Europe/Madrid";

      system.stateVersion = "25.11";
    };
}

Is something like this possible, or do I just need to build a custom installer ISO with all the options, and that runs a script on startup and sets whatever can be changed at runtime in a script or something like that?

u/GyroTech — 28 days ago