# cloudwatt/nix-container-images architecture

> Architecture diagram of the GitHub repository cloudwatt/nix-container-images, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cloudwatt/nix-container-images
- Repository: https://github.com/cloudwatt/nix-container-images

## Overview

This repository builds declarative Docker images from NixOS-style configurations. The principal workflow is a consumer configuration passed to `lib.makeImage`, which defines image attributes and incorporates reusable system modules; the resulting image can run a command directly or use s6 as PID 1. Documented capabilities also include s6-managed services, partial systemd-service compatibility, Nix configuration, and a predefined Nix image. Source excerpts were unavailable, so relationships are limited to those described in the README.

Main entry points: [`lib/make-image.nix`](https://github.com/cloudwatt/nix-container-images/blob/master/lib/make-image.nix) (Image builder), [`modules/s6.nix`](https://github.com/cloudwatt/nix-container-images/blob/master/modules/s6.nix) (s6 services), [`modules/systemd.nix`](https://github.com/cloudwatt/nix-container-images/blob/master/modules/systemd.nix) (Systemd compatibility), [`images/nix.nix`](https://github.com/cloudwatt/nix-container-images/blob/master/images/nix.nix) (Nix image)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_image["Image creation"]
  node_make_image["Image builder<br/>[make-image.nix]"]
  node_image_options["Image options<br/>[image.nix]"]
end

subgraph group_system["System configuration"]
  node_system_module["System module<br/>[system.nix]"]
  node_system_path["System paths<br/>[system-path.nix]"]
  node_nix_daemon["Nix configuration<br/>[nix-daemon.nix]"]
  node_fake_module["Module compatibility<br/>[fake.nix]"]
end

subgraph group_services["Service management"]
  node_s6_module["s6 services<br/>[s6.nix]"]
  node_s6_lib["s6 helpers<br/>[s6-lib.nix]"]
  node_systemd_module["Systemd compatibility<br/>[systemd.nix]"]
end

subgraph group_examples["Predefined images"]
  node_nix_image["Nix image<br/>[nix.nix]"]
end

node_consumer(("Image author"))
node_s6_runtime["s6 runtime"]
node_container_image["Docker image"]

node_consumer -->|"configures via"| node_make_image
node_make_image -->|"accepts image config"| node_image_options
node_consumer -->|"defines services"| node_s6_module
node_systemd_module -->|"maps services to"| node_s6_module
node_s6_module -->|"runs services with"| node_s6_runtime
node_make_image -->|"builds"| node_container_image
node_consumer -->|"reuses NixOS modules"| node_system_module
node_consumer -->|"configures Nix"| node_nix_daemon
node_nix_image -->|"built as image"| node_make_image

click node_make_image "https://github.com/cloudwatt/nix-container-images/blob/master/lib/make-image.nix"
click node_image_options "https://github.com/cloudwatt/nix-container-images/blob/master/modules/image.nix"
click node_system_module "https://github.com/cloudwatt/nix-container-images/blob/master/modules/system.nix"
click node_system_path "https://github.com/cloudwatt/nix-container-images/blob/master/modules/system-path.nix"
click node_nix_daemon "https://github.com/cloudwatt/nix-container-images/blob/master/modules/nix-daemon.nix"
click node_fake_module "https://github.com/cloudwatt/nix-container-images/blob/master/modules/fake.nix"
click node_s6_module "https://github.com/cloudwatt/nix-container-images/blob/master/modules/s6.nix"
click node_s6_lib "https://github.com/cloudwatt/nix-container-images/blob/master/modules/s6-lib.nix"
click node_systemd_module "https://github.com/cloudwatt/nix-container-images/blob/master/modules/systemd.nix"
click node_nix_image "https://github.com/cloudwatt/nix-container-images/blob/master/images/nix.nix"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_make_image,node_image_options toneBlue
class node_system_module,node_system_path,node_nix_daemon,node_fake_module toneAmber
class node_s6_module,node_s6_lib,node_systemd_module toneMint
class node_nix_image toneRose
class node_consumer,node_s6_runtime,node_container_image toneIndigo
```

## Components

### Image creation

- [Image builder](https://github.com/cloudwatt/nix-container-images/blob/master/lib/make-image.nix): `lib/make-image.nix`
- [Image options](https://github.com/cloudwatt/nix-container-images/blob/master/modules/image.nix): `modules/image.nix`

### System configuration

- [System module](https://github.com/cloudwatt/nix-container-images/blob/master/modules/system.nix): `modules/system.nix`
- [System paths](https://github.com/cloudwatt/nix-container-images/blob/master/modules/system-path.nix): `modules/system-path.nix`
- [Nix configuration](https://github.com/cloudwatt/nix-container-images/blob/master/modules/nix-daemon.nix): `modules/nix-daemon.nix`
- [Module compatibility](https://github.com/cloudwatt/nix-container-images/blob/master/modules/fake.nix): `modules/fake.nix`

### Service management

- [s6 services](https://github.com/cloudwatt/nix-container-images/blob/master/modules/s6.nix): `modules/s6.nix`
- [s6 helpers](https://github.com/cloudwatt/nix-container-images/blob/master/modules/s6-lib.nix): `modules/s6-lib.nix`
- [Systemd compatibility](https://github.com/cloudwatt/nix-container-images/blob/master/modules/systemd.nix): `modules/systemd.nix`

### Predefined images

- [Nix image](https://github.com/cloudwatt/nix-container-images/blob/master/images/nix.nix): `images/nix.nix`

### Other components

- **Image author**
- **s6 runtime**
- **Docker image**

## Connections

- Image author → Image builder: configures via (evidence: `README.md`)
- Image builder → Image options: accepts image config (evidence: `README.md`)
- Image author → s6 services: defines services (evidence: `README.md`)
- Systemd compatibility → s6 services: maps services to (evidence: `README.md`)
- s6 services → s6 runtime: runs services with (evidence: `README.md`)
- Image builder → Docker image: builds (evidence: `README.md`)
- Image author → System module: reuses NixOS modules (evidence: `README.md`)
- Image author → Nix configuration: configures Nix (evidence: `README.md`)
- Nix image → Image builder: built as image (evidence: `README.md`)
