Skip to content
hackardoXPublic

About

A repository containing my configuration for nix

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

Avatar

NixOS Nix config for hackardoX

Last commit Nix Flakes Ready

Welcome to my personal Nix configuration repository. This repository contains my nix-darwin configuration for macOS, built using flake-parts and following the dendritic pattern.

Table of Contents

  1. Getting Started
  2. Features
  3. Architecture
  4. Resources

Getting Started

Before diving in, ensure that you have Nix installed on your system. If not, you can download and install it from the official Nix website or from the Determinate Systems installer.

Clone and setup

# Install git if needed:
nix-shell -p git

git clone https://github.com/hackardoX/nix.git
cd nix

# First-time setup on macOS:
nix run github:lnl7/nix-darwin#darwin-rebuild -- switch --flake .

# macOS (darwin hosts):
nh darwin switch          # Andrea-MacBook-Air, Proton-MacBook-Pro

# NixOS (HomeLab), on the machine itself:
sudo nh os switch         # HomeLab (Apple Silicon)

Remote Deployment

Initial provisioning for NixOS nodes (e.g., HomeLab on Apple Silicon, Hetzner VPS):

nix run github:nix-community/nixos-anywhere -- \
  --flake .#HomeLab --build-on remote <user>@<ip_address>

Subsequent updates via deploy-rs:

deploy homelab   # alias for HomeLab; extra deploy-rs flags are passed through, e.g. deploy homelab --dry-activate

The SSH agent must hold the deploy key (ssh-add ~/.ssh/deploy), since sudo on the target authenticates through agent forwarding.

Features

Here's an overview of what my Nix configuration offers:

  • Partitioned Inputs: Separate flakes for homelab and laptops isolate private/host-specific dependencies (e.g., asahi-firmware) from the root lockfile.

  • Flake-parts Architecture: Modular flake structure using flake-parts for better composability and organization.

  • Dendritic Pattern: Configuration follows the dendritic pattern for a clean, modular structure.

  • External Dependency Integrations:

    • Nixvim for Neovim configuration.
    • Catppuccin for consistent, high-quality system-wide theming.
    • Git-hooks for automated commit validation (Commitizen, Sign-offs).
    • Treefmt-nix for a unified formatting interface.
  • macOS Support: Seamlessly configure and manage Nix on macOS using nix-darwin.

  • Home Manager: Manage your dotfiles, home environment, and user-specific configurations with Home Manager.

  • DevShell Support: The flake provides a development shell for convenient development and maintenance of your Nix environment.

  • Secret Management: Secure secret handling with sops-nix.

  • CI with Cachix: Continuous integration that pushes built artifacts to Cachix for efficient builds.

  • Remote Deployment: Easily deploy Nix configuration with deploy-rs

Architecture

This configuration uses flake-parts with the dendritic pattern for a modular and composable structure.

Dendritic Pattern

The dendritic pattern organizes Nix configurations into small, focused modules that compose together like dendrites in a neural network. Each module defines a specific piece of functionality and declares its dependencies explicitly.

Key benefits:

  • Modularity: Each feature is isolated in its own module
  • Composability: Modules combine freely and can be reused across configurations
  • Clarity: Module relationships and dependencies are explicit and declarative

Learn more at the dendritic pattern documentation.

Directory Structure

.
├── flake.nix                        # Main entry point
├── partitions/                      # Isolated input sets
│   ├── homelab/flake.nix            # Apple Silicon NixOS deps
│   └── laptops/flake.nix            # macOS hosts deps
└── modules/                         # Shared configuration
    ├── hosts/                       # Host-specific configs
    │   ├── HomeLab/                 # NixOS (aarch64-linux)
    │   ├── Andrea-MacBook-Air/      # Darwin (aarch64-darwin)
    │   └── ...
    └── ...                          # Feature modules

All modules are discovered recursively using flake-parts' import-tree. The modules/hosts/ directory contains host-specific configurations that select which modules to enable for each machine.

Module Organization

Configuration is organized into focused modules by functionality (e.g., shell, git, editor, fonts). Each host configuration in modules/hosts/ selects which modules to enable and provides host-specific settings like username and system version.

Resources

Configurations that inspired this setup:

Documentation:

About

A repository containing my configuration for nix

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages