Nix flake for system configurations, dotfiles, and home server infrastructure

Zander Hawke ec9b4c46ac feat: add ngit-cli flake input for Nostr-based git CLI há 1 dia atrás
home ec9b4c46ac feat: add ngit-cli flake input for Nostr-based git CLI há 1 dia atrás
hosts 65c6ed39ba feat(odin): add NAT for container internet access and git in Gogs container há 1 dia atrás
lib 22772c5df6 feat(flake+git-hooks): readded git-hooks to the flake há 9 meses atrás
modules 1dd1940b17 feat(odin): add Gogs container with dark theme, admin provisioning, and cloudflared ingress há 1 dia atrás
overlays 887d2f4119 chore(odin): update tailscale and immich, remove patches há 7 meses atrás
packages 1120ccc82f fix(gogs): add `bash` to the wrapped `PATH` in `packages/gogs.nix` há 1 dia atrás
templates ba0a3c4e2f feat(templates): added devenv template há 10 meses atrás
.editorconfig c28f16b273 initial commit with most everything migrated and working há 1 ano atrás
.envrc 372f80741e fix(pre-commit): fixed pre-commit, removed vivaldi, fixed upgrade notes há 5 meses atrás
.gitignore 0c502fa50c feat: add Gogs Git service NixOS module and package há 2 dias atrás
LICENSE c28f16b273 initial commit with most everything migrated and working há 1 ano atrás
README.md 239c2ae6f2 docs: add origin and mirror repo há 1 dia atrás
flake.lock ec9b4c46ac feat: add ngit-cli flake input for Nostr-based git CLI há 1 dia atrás
flake.nix ec9b4c46ac feat: add ngit-cli flake input for Nostr-based git CLI há 1 dia atrás
shell.nix d5342c4790 fix(devenv): disable pre-commit hooks in dev shell há 5 meses atrás

README.md

Nix Configuration

A comprehensive Nix configuration for managing multiple machines with a unified approach. This repository contains configurations for macOS (Darwin) and Linux systems, with shared home-manager configurations and custom packages.

Origin Repository Mirror Repository

Overview

This repository manages the following machines:

  • meili - macOS laptop (aarch64-darwin)
  • modgud - Linux server (x86_64-linux)
  • odin - Home server (x86_64-linux)

Each machine has its own system configuration and home-manager setup, with shared modules and features.

Project Structure

.
├── flake.nix              # Main flake configuration
├── hosts/                 # System-specific configurations
│   ├── meili/             # macOS laptop configuration
│   ├── modgud/            # Linux server configuration
│   └── odin/              # Home server configuration (NixOS with containers)
├── home/                  # My home-manager configurations
│   └── features/          # Shared home-manager features
│       ├── cli/           # CLI tools (git, fish, tmux, etc.)
│       ├── desktop/       # Desktop applications (aerospace, ghostty, etc.)
│       └── nvim/          # Neovim configuration
├── modules/               # Shared NixOS/Darwin modules
│   └── nixos/             # NixOS modules (gogs, grist)
├── packages/              # Custom packages
├── lib/                   # Helper functions
└── overlays/              # Nixpkgs overlays

Quick Start

For macOS (meili)

Note: There is a thing where the terminal emulator needs full disk access for homebrew and other things to work correctly, but I'm also using Ghostty installed via Homebrew. Therefor, after the darwin-rebuild switch a brew bundle.

# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Add `darwin-rebuild` to shell
nix shell github:lnl7/nix-darwin#darwin-rebuild

# Apply system configuration
sudo darwin-rebuild switch --flake .#meili

# Install the brew packages
brew bundle

# Allow Full Disk Access to Ghossty
# System Settings
#   -> Privacy & Security
#   -> Full Disk Access
#   -> Add Ghostty

# Add kanata to Input Monitoring
# System Settings
#   -> Privacy & Security
#   -> Input Monitoring
#   -> + /run/current-system/sw/bin/kanata

# Apply system configuration one more time
sudo darwin-rebuild switch --flake .#meili

# Apply home-manager configuration
nix run github:nix-community/home-manager -- switch --flake .#thomas@meili

For Linux (modgud)

# Apply system configuration (if NixOS)
nix run github:nix-community/nixos-anywhere -- --flake .#modgud [email protected]

# Apply home-manager configuration
nix run github:nix-community/home-manager -- switch --flake .#thomas@modgud

For Asahi Fedora (fedora)

# Add trusted users
echo "trusted-users = root @wheel @admin" | sudo tee -a /etc/nix/nix.custom.conf
# Restart nix-daemon to apply changes
sudo systemctl restart nix-daemon

# Add ghostty
sudo dnf copr enable pgdev/ghostty
sudo dnf install ghostty

Features

Shared CLI Tools

  • Fish shell - Interactive shell with completions
  • Git - Version control with custom configuration
  • TMUX - Terminal multiplexer with custom keybindings
  • Starship - Cross-shell prompt
  • Bat - Better cat with syntax highlighting
  • SSH - Secure shell configuration
  • GnuPG - Encryption and signing

Desktop Features (macOS only)

  • AeroSpace - i3-style tiling window manager
  • Ghostty - Modern terminal emulator
  • Zen Browser - Privacy-focused browser
  • Brave Browser - Used for YouTube app window
  • YubiKey - Hardware security key support
  • Fonts - Custom font configuration

Development Tools

  • Neovim - Text editor with LSP, treesitter, and telescope
  • Custom packages - Including photo-cli for photo management

Custom Packages

This repository includes several custom packages:

  • gogs - Git hosting service (NixOS container on odin)
  • gogs-themes - Dark & responsive themes for Gogs
  • grist-core - Spreadsheet server (NixOS container on odin)
  • photo-cli - Photo management and organization tool
  • tmux-select-pane-no-wrap - TMUX pane selection without wrapping
  • aerospace-tmux-focus - Integration between AeroSpace and TMUX
  • hello - Example package

Machine-Specific Configurations

meili (macOS Laptop)

  • System: aarch64-darwin
  • Features: Full desktop environment with tiling window manager
  • Location: America/Los_Angeles timezone
  • Services: Remote login enabled

odin (Home Server)

  • System: x86_64-linux
  • Role: NixOS host running containers for Gogs (git hosting), Grist (spreadsheets), and Immich (photos)
  • Features: Cloudflare tunnel ingress, Btrfs with impermanence, age-encrypted secrets
  • Location: Europe/Vienna timezone
  • Services:
    • Gogs at git.t5.st - Self-hosted Git service with dark theme, registration disabled
    • Grist at grist.odin.t5.st - Spreadsheet server
    • Immich at photos.t5.st - Photo management
    • Cloudflare Tunnel - Ingress for all public services

Development

Adding a New Machine

  1. Create a new directory in hosts/ for your machine
  2. Add system configuration to flake.nix
  3. Create home-manager configuration in home/
  4. Add any machine-specific modules as needed

Adding New Features

  1. Create feature modules in home/features/
  2. Import them in the appropriate machine configurations
  3. Update documentation as needed

Notes

  • The configuration uses Nix flake inputs for reproducible builds
  • Home-manager configurations are shared between machines where appropriate
  • Custom packages are defined in the packages/ directory
  • The lib/ directory contains helper functions for creating configurations

Photo Management Commands

For photo organization, use the custom photo-cli package:

# Copy photos with folder hierarchy preservation
photo-cli copy \
  --process-type SubFoldersPreserveFolderHierarchy \
  --naming-style DateTimeWithSecondsAddress \
  --number-style PaddingZeroCharacter \
  --folder-append DayRange \
  --folder-append-location Prefix \
  --reverse-geocode OpenStreetMapFoundation \
  --openstreetmap-properties country city town suburb \
  --no-coordinate InSubFolder \
  --no-taken-date InSubFolder \
  --verify \
  --output ~/Photos

# Flatten all subfolders with address-based grouping
photo-cli copy \
  --process-type FlattenAllSubFolders \
  --group-by AddressHierarchy \
  --naming-style DayAddress \
  --reverse-geocode OpenStreetMapFoundation \
  --openstreetmap-properties country city town suburb \
  --number-style OnlySequentialNumbers \
  --no-taken-date AppendToEndOrderByFileName \
  --no-coordinate InSubFolder \
  --input ~/Backup \
  --output ~/Photos \
  --dry-run --verify

Roadmap

  • Use flakes for local paths: Convert local paths (e.g., import ./lib) to flake inputs. This improves reproducibility by explicitly declaring dependencies and makes it easier to manage different versions of local modules.
  • Centralize library functions: Make commonly used functions in the lib directory available as a module or overlay. This promotes code reuse and simplifies configuration.
  • Add descriptions to outputs: Add descriptions to the outputs of the flake. This makes it easier to understand the purpose of each output and improves the overall usability of the flake.