Merge branch 'hydra-images' into 'main'

Hydra images

See merge request ahoneybun/ahoneybun-net!10
This commit is contained in:
Aaron Honeycutt 2025-07-31 18:21:15 -06:00
commit fe6fa5e73e
2 changed files with 92 additions and 0 deletions

View file

@ -0,0 +1,92 @@
+++
title = "Using Hydra to build custom images"
date = 2025-07-31
draft = false
[taxonomies]
categories = [ "nixos" ]
tags = [ "nixos", "nixos-server", "nixos-25.05", "hydra", "custom-images"]
+++
# 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](https://nix.dev/tutorials/nixos/building-bootable-iso-image) and [NixOS Wiki](https://nixos.wiki/wiki/Creating_a_NixOS_live_CD). For example if we wanted a minimal (CLI only) ISO for x86_64 with helix and git we can do that here:
```nix,linenos
{
description = "Minimal NixOS installation media";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
outputs = { self, nixpkgs }: {
nixosConfigurations = {
exampleIso = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
({ pkgs, modulesPath, ... }: {
imports = [ (modulesPath + "/installer/cd-dvd/installation-cd-minimal.nix") ];
environment.systemPackages with pkgs; = [ helix git ];
})
];
};
};
};
}
```
We would build the image like this using flakes:
```nix,linenos
git init
git add flake.nix
nix build .#nixosConfigurations.exampleIso.config.system.build.images.iso
```
I started my own [nixos live disk repository](https://gitlab.com/ahoneybun-nix/nixos-live-disk) 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.
```nix,linenos
{
description = "Minimal NixOS installation media";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
outputs = {self, nixpkgs }: {
nixosConfigurations = {
drack = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
modules = [
({ pkgs, lib, modulesPath, ... }: {
imports = [ "${modulesPath}/installer/cd-dvd/installation-cd-graphical-calamares-gnome.nix" ];
boot.kernelPackages = pkgs.linuxPackages_latest;
boot.supportedFilesystems = lib.mkForce [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" "ntfs" "cifs" ];
environment.systemPackages = with pkgs; [ helix ];
networking.hostName = "drack";
services.openssh.enable = true;
system.stateVersion = "25.05";
})
];
};
};
};
}
```
# Having Hydra get a job
With the following in the flake we can have Hydra start building the images:
```nix,linenos
hydraJobs = {
images = {
vetra = self.nixosConfigurations.vetra.config.system.build.sdImage;
sidera = self.nixosConfigurations.sidera.config.system.build.sdImage;
drack = self.nixosConfigurations.drack.config.system.build.isoImage;
test-gui = self.nixosConfigurations.test-gui.config.system.build.isoImage;
test-cli = self.nixosConfigurations.test-cli.config.system.build.isoImage;
};
};
```
{{ figure(src="/images/hydra-ci-images/hydra-custom-images.png", alt="Hydra building images for different architectures", caption="Hydra building images for different architectures") }}
# Other questions
Reach out to me on Mastodon for questions!

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB