main

IX

IX is a Nix configuration built with Dendritic Pattern and den.

Project Structure

./
├── .secrets/   # Generated secrets for each hosts by Vaultix
├── modules/    # All files auto imported by import-tree if not started with `_`
│   ├── core/        # Aspects included by all hosts
│   ├── desktop/     # Aspects only for desktop hosts
│   ├── dev/         # Aspects only for develop hosts
│   ├── disk/        # Aspects about file systems
│   ├── flake-parts/ # flake-parts modules, partly out of den
│   ├── hardware/    # Aspects about specific hardware
│   ├── hosts/       # Declare all hosts
│   │   ├── cyrene/      # Cloud root server
│   │   ├── hyacine/     # Proxy server
│   │   ├── kevin/       # Private laptop
│   │   ├── mobius/      # Homelab root server
│   │   ├── tribios/     # Homelab router
│   │   └── schema.nix   # Declare config schema for all hosts
│   ├── secret/      # Aspects about secrets, powered by Vaultix
│   ├── services/    # Aspects about services, usually provides web service
│   ├── users/       # Declare all users
│   │   ├── hpcesia/     # Project author, currently the only user
│   │   ├── schema.nix   # Declare config schema for all users
│   │   └── theme.nix    # User specific color-theme class
│   ├── flake-file.nix   # Declare general flake inputs, not all inputs
│   └── mk-settings.nix  # Provide `settings` from aspects to each hosts/users
├── templates/  # Flake templates for development
└── flake.nix   # Generated by flake-file

Code Style

  • Comments should describe why not what, code should be self documenting as to what. After edit, refine your comments that exceed 2 lines.
  • Always use the current workspace changes as the baseline. If current workspace changed unexpectedly, they are user-made; always respect the user’s changes.
  • After 3+ workarounds in the same area, redesign the component instead of patching further.

Development Commands

# Build a nixosConfiguration for specific host
# --no-nom: disable nix output monitor, which only make sense for human
# --diff=never: disable nix diff viewer due to poor network quality
just build <hostname> --no-nom --diff=never -- --verbose

# Regenerate flake.nix & flake.lock after modifying flake inputs by flake-file
just write-flake

# Format all files by treefmt
nix fmt

# Edit and cache Vaultix secrets, need password and ONLY for human use
edit-secret <file_path> # `edit-secret` available in nix devshell
git add <file_path> # track secret file in git

cache-secret # also in nix devshell
git add ./.secrets # track cached secret files in git

# Get path of a nix flake input
nix eval --impure --expr '(builtins.import ./default.nix).inputs.<input>.outPath'