# rgbcube/ncc architecture

> Architecture diagram of the GitHub repository rgbcube/ncc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rgbcube/ncc
- Repository: https://github.com/rgbcube/ncc

## Overview

#### Purpose and Entry Points
This is a Nix flake-based personal infrastructure/configuration repository (“ncc”), defining reproducible host systems, user environments, services, and a small set of custom packages. The flake entry point and pinned dependency graph are `flake.nix` and `flake.lock`. Host-specific compositions live under `hosts/`.

#### Host Composition
Each machine is represented by a host directory or host module, which selects and specializes the shared module stack. Current targets include Istanbul and Vienna, with host-specific module files and generated reports:
- `hosts/istanbul/istanbul.mod.nix`
- `hosts/vienna/vienna.mod.nix`
- `hosts/pala.mod.nix`

Encrypted per-host credentials are colocated as Age files, such as `hosts/istanbul/password.age` and `hosts/vienna/password.age`.

#### Shared Nix Module Layer
`modules/` is the primary declarative configuration layer. It defines OS, desktop, shell, packages, user management, networking, and application behavior, intended to be composed by hosts rather than run independently. Architecturally central modules include:
- System/user baseline: `modules/home.mod.nix`, `modules/primary-user.mod.nix`, `modules/nix.mod.nix`
- Platform-specific desktop behavior: `modules/darwin-desktop.mod.nix`, `modules/darwin-wm.mod.nix`, `modules/hardware.mod.nix`
- Boot and storage: `modules/linux-boot.mod.nix`, `modules/disko.mod.nix`
- Network and remote access: `modules/network/network.mod.nix`, `modules/ssh.mod.nix`, `modules/dns.mod.nix`

This indicates support for both Linux/NixOS-oriented and Darwin-oriented configurations.

#### Options and Reusable Libraries
Custom option schemas provide the public configuration contract consumed by modules and hosts:
- `options/flake-outputs.mod.nix`
- `options/persist.mod.nix`
- `options/theme.mod.nix`
- `options/dns.mod.nix`

Shared evaluation and generation logic is centralized in `lib/`, including system targeting, network/DNS utilities, and Rust-package support:
- `lib/default.nix`
- `lib/systems.nix`
- `lib/network.nix`
- `lib/rust.nix`

#### Secrets and Persistence Boundary
Secrets are deliberately separated from ordinary declarative configuration via Age-encrypted files and a root secrets declaration:
- `secrets.nix`
- `modules/secrets.mod.nix`
- `modules/network/password.env.age`
- `modules/version-control/radicle.age`

Host and module definitions should consume declared secret outputs rather than embed credentials. Persistence is modeled as a configurable concern through `options/persist.mod.nix`, likely supporting immutable or ephemeral-system patterns alongside `modules/immutable-users.mod.nix`.

#### Services and External Infrastructure
Service modules define managed system daemons and their integration with host configuration:
- `services/base.mod.nix`
- `services/hickory-dns.mod.nix`
- `services/monerod.mod.nix`
- `services/managed-files.mod.nix`

Material external/runtime concerns include DNS through Hickory DNS, Syncthing (`modules/syncthing.mod.nix`), SSH, network credentials, and a Monero daemon. These are system-service boundaries rather than an application-server architecture.

#### Custom Packages
`packages/` builds locally maintained artifacts as flake/package outputs. It includes keyboard firmware, desktop utilities, proprietary-tool packaging, and a Rust executable:
- `packages/corne-firmware/corne-firmware.mod.nix`
- `packages/fast-workspace-switch/fast-workspace-switch.mod.nix`
- `packages/matrix-imagepack-sync/matrix-imagepack-sync.mod.nix`

`packages/matrix-imagepack-sync/main.rs` is the principal non-Nix application source, with Cargo metadata in its containing directory. Package modules integrate these artifacts back into the shared Nix configuration and outputs.

Main entry points: [`hosts/istanbul/istanbul.mod.nix`](https://github.com/rgbcube/ncc/blob/dentride/hosts/istanbul/istanbul.mod.nix) (Host compositions), [`flake.nix`](https://github.com/rgbcube/ncc/blob/dentride/flake.nix) (Flake outputs), [`services/base.mod.nix`](https://github.com/rgbcube/ncc/blob/dentride/services/base.mod.nix) (Service integration), [`packages/fast-workspace-switch/fast-workspace-switch.mod.nix`](https://github.com/rgbcube/ncc/blob/dentride/packages/fast-workspace-switch/fast-workspace-switch.mod.nix) (Custom package modules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Flake entry"]
  node_flake{{"Flake outputs<br/>Nix flake<br/>[flake.nix]"}}
  node_lock["Pinned inputs<br/>lockfile<br/>[flake.lock]"]
  node_lib["Evaluation library<br/>Nix library<br/>[default.nix]"]
end

subgraph group_config["Configuration layer"]
  node_options["Custom option contracts<br/>Nix options"]
  node_hosts["Host compositions<br/>host modules<br/>[istanbul.mod.nix]"]
  node_baseline["System and user baseline<br/>Nix modules<br/>[home.mod.nix]"]
  node_platform["Platform desktop and hardware<br/>Nix modules"]
  node_boot_storage["Boot and storage<br/>Nix modules<br/>[linux-boot.mod.nix]"]
  node_network["Network and remote access<br/>Nix modules<br/>[network.mod.nix]"]
end

subgraph group_secrets["Secrets &amp; persistence"]
  node_persistence["Persistence model<br/>Nix option<br/>[persist.mod.nix]"]
  node_secret_declarations["Secret declarations<br/>Nix secrets<br/>[secrets.nix]"]
  node_encrypted_secrets["Age credentials<br/>encrypted files<br/>[password.age]"]
  node_immutable_users["Immutable users<br/>Nix module"]
end

subgraph group_runtime["Managed services"]
  node_service_base["Service integration<br/>Nix service module<br/>[base.mod.nix]"]
  node_dns_service["Hickory DNS<br/>system daemon"]
  node_monero_service["Monero daemon<br/>system daemon<br/>[monerod.mod.nix]"]
  node_syncthing["Syncthing<br/>system service<br/>[syncthing.mod.nix]"]
end

subgraph group_packages["Custom packages"]
  node_package_outputs["Custom package modules<br/>Nix packages"]
  node_matrix_sync["Matrix imagepack sync<br/>Rust executable<br/>[main.rs]"]
end

node_lock -->|"pins inputs"| node_flake
node_lib -->|"evaluates outputs"| node_flake
node_options -->|"defines output contract"| node_flake
node_flake -->|"builds targets"| node_hosts
node_hosts -->|"composes"| node_baseline
node_hosts -->|"specializes"| node_platform
node_hosts -->|"configures"| node_boot_storage
node_hosts -->|"configures"| node_network
node_options -->|"declares"| node_persistence
node_hosts -->|"selects"| node_persistence
node_persistence -->|"supports"| node_immutable_users
node_encrypted_secrets -->|"encrypted inputs"| node_secret_declarations
node_secret_declarations -.->|"provides secret outputs"| node_hosts
node_hosts -->|"enables services"| node_service_base
node_service_base -->|"manages"| node_dns_service
node_service_base -->|"manages"| node_monero_service
node_network -->|"integrates DNS"| node_dns_service
node_hosts -->|"enables"| node_syncthing
node_package_outputs -->|"exports packages"| node_flake
node_matrix_sync -->|"packaged as"| node_package_outputs
node_package_outputs -.->|"installs into environments"| node_baseline

click node_flake "https://github.com/rgbcube/ncc/blob/dentride/flake.nix"
click node_lock "https://github.com/rgbcube/ncc/blob/dentride/flake.lock"
click node_lib "https://github.com/rgbcube/ncc/blob/dentride/lib/default.nix"
click node_options "https://github.com/rgbcube/ncc/blob/dentride/options/flake-outputs.mod.nix"
click node_hosts "https://github.com/rgbcube/ncc/blob/dentride/hosts/istanbul/istanbul.mod.nix"
click node_baseline "https://github.com/rgbcube/ncc/blob/dentride/modules/home.mod.nix"
click node_platform "https://github.com/rgbcube/ncc/blob/dentride/modules/darwin-desktop.mod.nix"
click node_boot_storage "https://github.com/rgbcube/ncc/blob/dentride/modules/linux-boot.mod.nix"
click node_network "https://github.com/rgbcube/ncc/blob/dentride/modules/network/network.mod.nix"
click node_persistence "https://github.com/rgbcube/ncc/blob/dentride/options/persist.mod.nix"
click node_secret_declarations "https://github.com/rgbcube/ncc/blob/dentride/secrets.nix"
click node_encrypted_secrets "https://github.com/rgbcube/ncc/blob/dentride/hosts/istanbul/password.age"
click node_immutable_users "https://github.com/rgbcube/ncc/blob/dentride/modules/immutable-users.mod.nix"
click node_service_base "https://github.com/rgbcube/ncc/blob/dentride/services/base.mod.nix"
click node_dns_service "https://github.com/rgbcube/ncc/blob/dentride/services/hickory-dns.mod.nix"
click node_monero_service "https://github.com/rgbcube/ncc/blob/dentride/services/monerod.mod.nix"
click node_syncthing "https://github.com/rgbcube/ncc/blob/dentride/modules/syncthing.mod.nix"
click node_package_outputs "https://github.com/rgbcube/ncc/blob/dentride/packages/fast-workspace-switch/fast-workspace-switch.mod.nix"
click node_matrix_sync "https://github.com/rgbcube/ncc/blob/dentride/packages/matrix-imagepack-sync/main.rs"

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_flake,node_lock,node_lib toneBlue
class node_options,node_hosts,node_baseline,node_platform,node_boot_storage,node_network toneAmber
class node_persistence,node_secret_declarations,node_encrypted_secrets,node_immutable_users toneMint
class node_service_base,node_dns_service,node_monero_service,node_syncthing toneRose
class node_package_outputs,node_matrix_sync toneIndigo
```

## Components

### Flake entry

- [Flake outputs](https://github.com/rgbcube/ncc/blob/dentride/flake.nix): Nix flake · Defines reproducible systems, environments, and package outputs. · `flake.nix`
- [Pinned inputs](https://github.com/rgbcube/ncc/blob/dentride/flake.lock): lockfile · `flake.lock`
- [Evaluation library](https://github.com/rgbcube/ncc/blob/dentride/lib/default.nix): Nix library · Shared system targeting, network, and Rust packaging logic. · `lib/default.nix`

### Configuration layer

- [Custom option contracts](https://github.com/rgbcube/ncc/blob/dentride/options/flake-outputs.mod.nix): Nix options · Public schemas consumed by hosts and modules. · `options/flake-outputs.mod.nix`
- [Host compositions](https://github.com/rgbcube/ncc/blob/dentride/hosts/istanbul/istanbul.mod.nix): host modules · Istanbul, Vienna, and Pala specialize the shared stack. · `hosts/istanbul/istanbul.mod.nix`
- [System and user baseline](https://github.com/rgbcube/ncc/blob/dentride/modules/home.mod.nix): Nix modules · Home, primary-user, and Nix baseline configuration. · `modules/home.mod.nix`
- [Platform desktop and hardware](https://github.com/rgbcube/ncc/blob/dentride/modules/darwin-desktop.mod.nix): Nix modules · Darwin desktop/window management and hardware behavior. · `modules/darwin-desktop.mod.nix`
- [Boot and storage](https://github.com/rgbcube/ncc/blob/dentride/modules/linux-boot.mod.nix): Nix modules · Linux boot and disk layout configuration. · `modules/linux-boot.mod.nix`
- [Network and remote access](https://github.com/rgbcube/ncc/blob/dentride/modules/network/network.mod.nix): Nix modules · Network, DNS, and SSH configuration. · `modules/network/network.mod.nix`

### Secrets & persistence

- [Persistence model](https://github.com/rgbcube/ncc/blob/dentride/options/persist.mod.nix): Nix option · Configures persistent state for immutable or ephemeral hosts. · `options/persist.mod.nix`
- [Secret declarations](https://github.com/rgbcube/ncc/blob/dentride/secrets.nix): Nix secrets · Maps encrypted credentials to consumable secret outputs. · `secrets.nix`
- [Age credentials](https://github.com/rgbcube/ncc/blob/dentride/hosts/istanbul/password.age): encrypted files · Host and module credentials remain encrypted at rest. · `hosts/istanbul/password.age`
- [Immutable users](https://github.com/rgbcube/ncc/blob/dentride/modules/immutable-users.mod.nix): Nix module · `modules/immutable-users.mod.nix`

### Managed services

- [Service integration](https://github.com/rgbcube/ncc/blob/dentride/services/base.mod.nix): Nix service module · Base wiring for managed system daemons. · `services/base.mod.nix`
- [Hickory DNS](https://github.com/rgbcube/ncc/blob/dentride/services/hickory-dns.mod.nix): system daemon · `services/hickory-dns.mod.nix`
- [Monero daemon](https://github.com/rgbcube/ncc/blob/dentride/services/monerod.mod.nix): system daemon · `services/monerod.mod.nix`
- [Syncthing](https://github.com/rgbcube/ncc/blob/dentride/modules/syncthing.mod.nix): system service · `modules/syncthing.mod.nix`

### Custom packages

- [Custom package modules](https://github.com/rgbcube/ncc/blob/dentride/packages/fast-workspace-switch/fast-workspace-switch.mod.nix): Nix packages · Builds firmware, desktop utilities, and local applications. · `packages/fast-workspace-switch/fast-workspace-switch.mod.nix`
- [Matrix imagepack sync](https://github.com/rgbcube/ncc/blob/dentride/packages/matrix-imagepack-sync/main.rs): Rust executable · Principal non-Nix application source packaged by the flake. · `packages/matrix-imagepack-sync/main.rs`

## Connections

- Pinned inputs → Flake outputs: pins inputs
- Evaluation library → Flake outputs: evaluates outputs
- Custom option contracts → Flake outputs: defines output contract
- Flake outputs → Host compositions: builds targets
- Host compositions → System and user baseline: composes
- Host compositions → Platform desktop and hardware: specializes
- Host compositions → Boot and storage: configures
- Host compositions → Network and remote access: configures
- Custom option contracts → Persistence model: declares
- Host compositions → Persistence model: selects
- Persistence model → Immutable users: supports
- Age credentials → Secret declarations: encrypted inputs
- Secret declarations → Host compositions: provides secret outputs
- Host compositions → Service integration: enables services
- Service integration → Hickory DNS: manages
- Service integration → Monero daemon: manages
- Network and remote access → Hickory DNS: integrates DNS
- Host compositions → Syncthing: enables
- Custom package modules → Flake outputs: exports packages
- Matrix imagepack sync → Custom package modules: packaged as
- Custom package modules → System and user baseline: installs into environments
