Using Hydra to build custom images
2025-07-31
Building custom images
You can build images with either the legacy (non-flake) and flake method, there are a few great resources such as nix.dev and NixOS Wiki. For example if we wanted a minimal (CLI only) ISO for x86_64 with helix and git we can do that here:
1 {
2 description = "Minimal NixOS installation media";
3 inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
4 outputs = { self, nixpkgs }: {
5 nixosConfigurations = {
6 exampleIso = nixpkgs.lib.nixosSystem {
7 system = "x86_64-linux";
8 modules = [
9 ({ pkgs, modulesPath, ... }: {
10 imports = [ (modulesPath + "/installer/cd-dvd/installation-cd-minimal.nix") ];
11 environment.systemPackages with pkgs; = [ helix git ];
12 })
13 ];
14 };
15 };
16 };
17 }
We would build the image like this using flakes:
1 git init
2 git add flake.nix
3 nix build .#nixosConfigurations.exampleIso.config.system.build.images.iso
I started my own nixos live disk repository recently for building images for my Pi 4, Pi 5 and x86_64 minimal CLI versions.
If we want to build an image for aarch64-linux with the graphical installer for GNOME with the latest kernel, hostname set and helix.
1 {
2 description = "Minimal NixOS installation media";
3 inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
4 outputs = {self, nixpkgs }: {
5 nixosConfigurations = {
6 drack = nixpkgs.lib.nixosSystem {
7 system = "aarch64-linux";
8 modules = [
9 ({ pkgs, lib, modulesPath, ... }: {
10 imports = [ "modulesPath/installer/cd-dvd/installation-cd-graphical-calamares-gnome.nix" ];
11 boot.kernelPackages = pkgs.linuxPackages_latest;
12 boot.supportedFilesystems = lib.mkForce [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" "ntfs" "cifs" ];
13 environment.systemPackages = with pkgs; [ helix ];
14 networking.hostName = "drack";
15 services.openssh.enable = true;
16 system.stateVersion = "25.05";
17 })
18 ];
19 };
20 };
21 };
22 }
Having Hydra get a job
With the following in the flake we can have Hydra start building the images:
1 hydraJobs = {
2 images = {
3 vetra = self.nixosConfigurations.vetra.config.system.build.sdImage;
4 sidera = self.nixosConfigurations.sidera.config.system.build.sdImage;
5 drack = self.nixosConfigurations.drack.config.system.build.isoImage;
6 test-gui = self.nixosConfigurations.test-gui.config.system.build.isoImage;
7 test-cli = self.nixosConfigurations.test-cli.config.system.build.isoImage;
8 };
9 };

Other questions
Reach out to me on Mastodon for questions!