Skip to content

feat(nix): migrate to flake-parts modular architecture#32

Open
ahmedelgabri wants to merge 17 commits intomainfrom
claude/migrate-nix-flake-parts-dtva1
Open

feat(nix): migrate to flake-parts modular architecture#32
ahmedelgabri wants to merge 17 commits intomainfrom
claude/migrate-nix-flake-parts-dtva1

Conversation

@ahmedelgabri
Copy link
Owner

@ahmedelgabri ahmedelgabri commented Jan 4, 2026

Complete Migration to Flake-Parts with Dendritic Pattern

This PR completes the migration of the entire Nix configuration to flake-parts following the Dendritic Pattern architecture.

🎯 Summary

The configuration now follows a modular, aspect-oriented architecture where:

  • Every file is a flake-parts module (auto-discovered via import-tree)
  • Features are organized by purpose, not by platform
  • Hosts import features via inputs.self.modules.*
  • Single source of truth for each feature across all systems

📊 Changes Overview

Modules Migrated (26 Feature Modules)

Shared modules (21) - work on both darwin and nixos:

  • Core: git, vim, tmux, ssh, gpg, user-shell
  • Terminal: kitty, ghostty, yazi, bat, ripgrep
  • Development: node, python, go, rust
  • Applications: gui, mail, discord, ai, zk, mpv, yt-dlp
  • Utilities: misc, agenix

Darwin-only modules (2):

  • hammerspoon, karabiner

System modules (7):

  • user-options, nix-daemon, state-version, home-manager-integration, fonts, darwin-defaults, feature-defaults

Architecture Improvements

Before:

nix/modules/
├── shared/          # 23 modules + default.nix
└── darwin/          # 2 modules + default.nix

After:

nix/
├── features/        # 26 feature modules
├── system/          # 7 system modules
└── hosts/           # 4 host configs (single file each)

✨ Key Benefits

  1. ✅ Aspect-Oriented Organization - Organize by feature (git, vim), not platform (darwin, nixos)
  2. ✅ Auto-Discovery - All modules discovered via import-tree
  3. ✅ Single File Per Feature - Each feature is self-contained
  4. ✅ Single File Per Host - No more configuration.nix + flake-parts.nix split
  5. ✅ No specialArgs Anti-Pattern - Access modules via inputs.self.modules.*
  6. ✅ Sensible Defaults - feature-defaults module enables common features
  7. ✅ Easy Overrides - Hosts can override with lib.mkDefault
  8. ✅ Cross-Platform - Single module works on both darwin and nixos

🏗️ Architecture

Feature Modules

Every feature module follows this pattern:

# nix/features/git.nix
{inputs, ...}: let
  gitModule = {pkgs, lib, config, ...}: let
    cfg = config.my.modules.git;
  in {
    options.my.modules.git.enable = lib.mkEnableOption "git module";
    config = lib.mkIf cfg.enable {
      # Git configuration here
    };
  };
in {
  flake.modules.darwin.git = gitModule;
  flake.modules.nixos.git = gitModule;
}

Host Configuration

Hosts import system and feature modules:

# nix/hosts/alcantara.nix
{inputs, ...}: {
  flake.modules.darwin.alcantara = {config, pkgs, ...}: {
    imports = with inputs.self.modules.darwin; [
      user-options
      nix-daemon
      state-version
      home-manager-integration
      fonts
      defaults
      feature-defaults  # Enables most features by default
    ];

    # Override or enable opt-in features
    my.modules = {
      mail.enable = true;
      gpg.enable = true;
      discord.enable = true;
    };
  };
}

Auto-Discovery

All modules are auto-discovered via import-tree:

# flake.nix
inputs.import-tree.url = "github:vic/import-tree";

outputs = inputs @ {flake-parts, import-tree, ...}:
  flake-parts.lib.mkFlake {inherit inputs;} {
    systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
    imports = [(import-tree ./nix)];  # Auto-discover all modules!
  };

📝 Migration Details

What Changed

  1. Removed:

    • nix/modules/shared/ (23 modules + default.nix)
    • nix/modules/darwin/ (2 modules + default.nix)
    • nix/programs/ (example directory)
  2. Added:

    • nix/features/ (26 feature modules in flake-parts format)
    • nix/system/feature-defaults.nix (replaces old default.nix)
  3. Migrated:

    • All feature modules to flake.modules.{darwin,nixos}.<name> pattern
    • All hosts to single-file configuration
    • Fixed relative paths (../../../config/ → ../../config/)
    • Fixed broken host imports (pandoras-box, rocket, nixos)

Commits

  1. refactor(nix): use import-tree and migrate to nix/ directory
  2. refactor(nix): cleanup and break down modules into focused aspects
  3. fix(nix): properly migrate pandoras-box and rocket host configs
  4. feat(nix): complete migration to flake-parts with Dendritic Pattern
  5. docs(nix): update migration documentation

⚠️ Testing Required

Before merging, please test:

# Check flake validity
nix flake check

# Test build for each host
nix build .#darwinConfigurations.alcantara.system --dry-run
nix build .#darwinConfigurations.pandoras-box.system --dry-run
nix build .#darwinConfigurations.rocket.system --dry-run
nix build .#nixosConfigurations.nixos.config.system.build.toplevel --dry-run

# Test evaluation
nix eval .#darwinConfigurations.alcantara.config.system.build.toplevel

# Test actual activation (on a test system first!)
darwin-rebuild switch --flake .#alcantara

Known Testing Gaps:

  • ⚠️ This PR was created without access to nix command for testing
  • ⚠️ Changes need to be validated in a real Nix environment
  • ⚠️ Relative paths (../../config/) need verification
  • ⚠️ Activation scripts need testing
  • ⚠️ Home-manager integration needs verification

📚 Documentation

See DENDRITIC-MIGRATION.md for:

  • Complete architecture overview
  • How to add new features
  • Benefits and rationale
  • Usage examples
  • Resources

🔄 Migration Path

Adding New Features

  1. Create a feature module in nix/features/:
# nix/features/example.nix
{inputs, ...}: let
  exampleModule = {pkgs, lib, config, ...}: let
    cfg = config.my.modules.example;
  in {
    options.my.modules.example.enable = lib.mkEnableOption "example";
    config = lib.mkIf cfg.enable {
      # Your config here
    };
  };
in {
  flake.modules.darwin.example = exampleModule;
  flake.modules.nixos.example = exampleModule;
}
  1. Optionally add to nix/system/feature-defaults.nix
  2. Enable in hosts as needed

Disabling Features

Hosts can disable features enabled by default:

my.modules = {
  discord.enable = lib.mkForce false;  # Disable completely
  # OR
  discord.enable = false;              # If not using mkDefault
};

🔗 Resources

🎉 Result

The configuration now has:

  • ✅ Clean separation of concerns (features, system, hosts)
  • ✅ Auto-discovery of all modules
  • ✅ Aspect-oriented organization
  • ✅ Feature-based architecture
  • ✅ Single file per host and feature
  • ✅ No specialArgs anti-pattern
  • ✅ Cross-platform compatibility

This migration sets a solid foundation for future improvements and makes the configuration more maintainable and understandable.

@ahmedelgabri
Copy link
Owner Author

@claude

claude added 2 commits January 4, 2026 15:45
This commit migrates the entire Nix configuration from a monolithic flake
to a modular flake-parts architecture, achieving a single unified
configuration that works across all systems managed by this flake.

## Key Changes

### Architecture
- Added flake-parts as a flake input
- Converted main flake.nix to use `flake-parts.lib.mkFlake`
- Created modular flake-parts structure in `flake-modules/`
- Extracted shared configuration into dedicated modules

### New Files
- `flake-modules/per-system.nix`: Per-system outputs (formatter, devShells, apps)
- `flake-modules/hosts.nix`: Darwin & NixOS system configurations
- `nix/shared-configuration.nix`: Unified config for all systems (extracted from sharedConfiguration)
- `nix/overlays.nix`: All nixpkgs overlays in one place
- `FLAKE-PARTS-MIGRATION.md`: Comprehensive migration documentation

### Benefits
1. **Single source of truth**: shared-configuration.nix applies to all systems
2. **Better modularity**: Clear separation of concerns across files
3. **Reduced boilerplate**: No more manual `forAllSystems` iteration
4. **Standard patterns**: Follows flake-parts conventions
5. **Improved maintainability**: Easier to understand and modify

### Unchanged
- `nix/modules/shared/settings.nix`: Remains untouched (NixOS/nix-darwin module)
- All host-specific configurations: Continue to work as before
- Module system: Platform-specific modules unchanged

## Migration Details

The original `sharedConfiguration` function has been split into two modules:
1. `nix/shared-configuration.nix`: Core system configuration
2. `nix/overlays.nix`: Package overlays and customizations

Both modules are now imported by all system configurations (Darwin and NixOS),
ensuring consistent configuration across all managed systems.

Platform-specific behavior is preserved through `pkgs.stdenv.isDarwin`
conditionals within the shared configuration.

## Verification

To verify this migration:
```bash
nix flake check
nix flake show
nix build .#<hostname>
darwin-rebuild switch --flake .#<hostname>
```

See FLAKE-PARTS-MIGRATION.md for complete documentation.

References:
- https://flake.parts/
- https://github.com/hercules-ci/flake-parts
- https://wiki.nixos.org/wiki/Flake_Parts
Extract settings.nix from nix/modules/shared/ to nix/ for better
consistency with the modular flake-parts architecture.

## Changes

- Moved `nix/modules/shared/settings.nix` → `nix/settings.nix`
- Updated `nix/modules/shared/default.nix` to remove settings.nix import
- Updated `flake-modules/hosts.nix` to import settings.nix in both:
  - darwinConfigurations
  - nixosConfigurations
- Updated FLAKE-PARTS-MIGRATION.md documentation

## Rationale

This creates a consistent structure where all core system modules are
at the same level:

```
nix/
├── settings.nix              # Custom options & config
├── shared-configuration.nix  # Core system configuration
└── overlays.nix              # Package overlays
```

All three modules are platform-aware (handling both Darwin and Linux)
and are imported by all system configurations, maintaining a single
unified configuration across all managed systems.

## Content

The settings.nix module remains functionally unchanged:
- Defines custom `config.my.*` options
- Sets up home-manager aliases
- Configures XDG directories
- Manages environment variables
- Platform-specific home directory logic (Darwin vs Linux)

Only the file location has changed for better organization.
@ahmedelgabri ahmedelgabri force-pushed the claude/migrate-nix-flake-parts-dtva1 branch from 1d2cafd to 1928e40 Compare January 4, 2026 14:45
claude added 15 commits January 4, 2026 15:30
This commit migrates the entire Nix configuration to the Dendritic Pattern,
where every file is a flake-parts module. This represents a fundamental
architectural shift from configuration-type organization (Darwin/NixOS/home)
to aspect-oriented organization by feature.

## What is the Dendritic Pattern?

The Dendritic Pattern treats each .nix file as a top-level flake-parts module.
Instead of separating code by configuration type, you organize by feature or
aspect. Each module can contribute to multiple configuration types simultaneously.

## Key Changes

### Architecture
- **Auto-discovery**: `importTree` function recursively imports all .nix files
- **Feature modules**: Define `flake.modules.{darwin,nixos,homeManager}.<name>`
- **Host modules**: Import features, no knowledge of feature internals
- **No specialArgs**: Access `inputs.self.modules.*` directly
- **perSystem outputs**: Overlays, dev shells, apps use perSystem properly

### New Structure

```
modules/
├── lib.nix                  # Helper functions (mkDarwin, mkNixos, mkHome)
├── overlays.nix             # perSystem overlays (not NixOS modules!)
├── dev-shells.nix           # perSystem devShells
├── apps.nix                 # perSystem apps + formatter
├── system/                  # System-level feature modules
│   ├── settings.nix         # flake.modules.{darwin,nixos}.settings
│   ├── nix.nix              # flake.modules.{darwin,nixos}.nix
│   ├── fonts.nix            # flake.modules.{darwin,nixos}.fonts
│   └── darwin-defaults.nix  # flake.modules.darwin.defaults
├── programs/                # Program feature modules
│   └── git.nix              # flake.modules.{darwin,nixos,homeManager}.git
└── hosts/                   # Host configurations
    ├── alcantara/
    │   ├── configuration.nix   # flake.modules.darwin.alcantara
    │   └── flake-parts.nix     # flake.darwinConfigurations.alcantara
    ├── pandoras-box/
    ├── rocket/
    └── nixos/
```

### Benefits

1. **Aspect-Oriented**: Organize by feature, not by configuration type
2. **Cross-Cutting**: One file can configure darwin + nixos + home simultaneously
3. **No specialArgs Anti-Pattern**: Direct access to modules via inputs.self
4. **Flexibility**: Rename/move files freely, no rigid structure
5. **Auto-Discovery**: Just add a .nix file, it's automatically imported
6. **Proper perSystem**: Overlays are perSystem, not NixOS modules

### Created Files

**Core Infrastructure:**
- `modules/lib.nix` - Helper functions for creating configurations
- `modules/overlays.nix` - perSystem overlays with custom packages
- `modules/dev-shells.nix` - Development shell environments
- `modules/apps.nix` - Bootstrap apps and formatter

**System Features:**
- `modules/system/settings.nix` - Custom options (config.my.*)
- `modules/system/nix.nix` - Nix daemon configuration
- `modules/system/fonts.nix` - Font packages
- `modules/system/darwin-defaults.nix` - macOS system defaults

**Program Features:**
- `modules/programs/git.nix` - Example cross-platform git module

**Host Configurations:**
- `modules/hosts/{alcantara,pandoras-box,rocket,nixos}/` - Host configs
  - `configuration.nix` - Module definition with feature imports
  - `flake-parts.nix` - Configuration output using lib helpers

**Documentation:**
- `DENDRITIC-MIGRATION.md` - Comprehensive migration guide

### Modified Files

- `flake.nix` - Replaced manual imports with auto-discovery importTree function

## Migration Status

✅ **Completed:**
- Auto-discovery infrastructure
- Helper functions
- perSystem outputs (overlays, shells, apps)
- System feature modules
- Example program module (git)
- All host configurations

🚧 **TODO:**
- Migrate remaining program modules from nix/modules/shared/
- Create darwin-specific modules (hammerspoon, karabiner)
- Remove old nix/ structure after full migration

## How Feature Modules Work

```nix
# modules/programs/git.nix
{...}: let
  systemGitModule = {pkgs, ...}: {
    environment.systemPackages = [pkgs.git];
  };

  homeGitModule = {config, lib, ...}: {
    programs.git = {
      enable = lib.mkDefault true;
      userName = config.my.name;
      userEmail = config.my.email;
    };
  };
in {
  # Available to darwin hosts
  flake.modules.darwin.git = systemGitModule;

  # Available to nixos hosts
  flake.modules.nixos.git = systemGitModule;

  # Available to home-manager
  flake.modules.homeManager.git = homeGitModule;
}
```

## How Host Modules Work

```nix
# modules/hosts/alcantara/configuration.nix
{inputs, ...}: {
  flake.modules.darwin.alcantara = {config, ...}: {
    imports = with inputs.self.modules.darwin; [
      settings nix fonts defaults git
    ];

    networking.hostName = "alcantara";

    home-manager.users.${config.my.username}.imports =
      with inputs.self.modules.homeManager; [git];
  };
}

# modules/hosts/alcantara/flake-parts.nix
{inputs, ...}: {
  flake.darwinConfigurations =
    inputs.self.lib.mkDarwin "aarch64-darwin" "alcantara";
}
```

## References

- Dendritic Pattern: https://github.com/mightyiam/dendritic
- Dendritic Design Guide: https://github.com/Doc-Steve/dendritic-design-with-flake-parts
- NixOS Discourse: https://discourse.nixos.org/t/pattern-every-file-is-a-flake-parts-module/61271
- flake-parts: https://flake.parts/

This migration establishes a solid foundation for a maintainable, flexible,
and scalable Nix configuration following modern best practices.
This commit cleans up the Dendritic Pattern migration by:
1. Removing old/redundant directories and files
2. Breaking down monolithic modules into focused, single-purpose modules
3. Consolidating host configs into single files

## Removed Old Files

- ❌ `flake-modules/` - No longer needed, replaced by `modules/`
- ❌ `nix/overlays.nix` - Now in `modules/overlays.nix`
- ❌ `nix/settings.nix` - Broken down into focused modules
- ❌ `nix/shared-configuration.nix` - Broken down into focused modules
- ❌ `modules/system/settings.nix` - Split into user-options + home-manager-integration
- ❌ `modules/system/nix.nix` - Split into nix-daemon + state-version

## New Focused Modules

Following the Dendritic Pattern principle of "each file represents one aspect":

**System Modules:**
- `modules/system/user-options.nix` - Defines config.my.* options only
- `modules/system/home-manager-integration.nix` - Home-manager base setup and XDG aliases
- `modules/system/nix-daemon.nix` - Nix daemon, GC, optimization, substituters
- `modules/system/state-version.nix` - State version management for system and home-manager

Each module has a single, clear responsibility.

## Consolidated Host Configs

Changed from:
```
modules/hosts/alcantara/
├── configuration.nix
└── flake-parts.nix
```

To:
```
modules/hosts/alcantara.nix  # Single file!
```

Each host now has a single file that:
1. Defines `flake.modules.{darwin,nixos}.<hostname>`
2. Imports feature modules
3. Creates `flake.{darwin,nixos}Configurations.<hostname>`

**Benefits:**
- ✅ Simpler structure - one file per host
- ✅ All host config in one place
- ✅ Less directory nesting
- ✅ Easier to understand and maintain

## Updated Structure

```
modules/
├── lib.nix                               # Helpers
├── overlays.nix                          # perSystem overlays
├── dev-shells.nix                        # perSystem shells
├── apps.nix                              # perSystem apps
├── system/                               # System aspects
│   ├── user-options.nix                  # config.my.* options
│   ├── home-manager-integration.nix      # HM base config
│   ├── nix-daemon.nix                    # Nix daemon
│   ├── state-version.nix                 # State versions
│   ├── fonts.nix                         # Fonts
│   └── darwin-defaults.nix               # macOS defaults
├── programs/
│   └── git.nix                           # Git feature
└── hosts/
    ├── alcantara.nix                     # Single file!
    ├── pandoras-box.nix
    ├── rocket.nix
    └── nixos.nix
```

## Example: user-options.nix

```nix
{lib, ...}: let
  userOptionsModule = {config, pkgs, options, ...}: {
    options.my = { /* define all config.my.* options */ };
    config = { /* basic config using those options */ };
  };
in {
  flake.modules.darwin.user-options = userOptionsModule;
  flake.modules.nixos.user-options = userOptionsModule;
}
```

Single-purpose: Only defines options and basic configuration.

## Example: Consolidated Host

```nix
# modules/hosts/alcantara.nix
{inputs, ...}: {
  # Define the module
  flake.modules.darwin.alcantara = {config, ...}: {
    imports = with inputs.self.modules.darwin; [
      user-options
      nix-daemon
      state-version
      home-manager-integration
      fonts
      defaults
      git
    ];

    networking.hostName = "alcantara";
    # ... host config
  };

  # Create the configuration
  flake.darwinConfigurations =
    inputs.self.lib.mkDarwin "aarch64-darwin" "alcantara";
}
```

Everything in one file - definition + output.

## Impact

This cleanup makes the Dendritic Pattern implementation cleaner and more
maintainable:
- Each module has a single, clear purpose
- No redundant files
- Simpler directory structure
- Easier to understand what each file does
- True aspect-oriented organization
This commit properly migrates to the Dendritic Pattern by:
1. Using official import-tree instead of custom implementation
2. Migrating all flake-parts modules to nix/ directory (not parallel modules/)
3. Consolidating the structure under the existing nix/ directory

## Changes

### Use import-tree
- ✅ Added `import-tree` as a flake input
- ✅ Using `(import-tree ./nix)` instead of custom importTree function
- ✅ Removes 30+ lines of custom code

### Proper Migration (not parallel structure)
- ✅ Moved all files from `modules/` → `nix/`
- ✅ Removed the parallel `modules/` directory
- ✅ Everything now lives under `./nix` as it should

## Final Structure

```
nix/
├── lib.nix                           # flake-parts: helpers
├── overlays.nix                      # flake-parts: perSystem overlays
├── dev-shells.nix                    # flake-parts: perSystem devShells
├── apps.nix                          # flake-parts: perSystem apps
│
├── system/                           # flake-parts: system aspects
│   ├── user-options.nix
│   ├── home-manager-integration.nix
│   ├── nix-daemon.nix
│   ├── state-version.nix
│   ├── fonts.nix
│   └── darwin-defaults.nix
│
├── programs/                         # flake-parts: program features
│   └── git.nix
│
├── hosts/                            # flake-parts: host configs (single files!)
│   ├── alcantara.nix
│   ├── pandoras-box.nix
│   ├── rocket.nix
│   ├── nixos.nix
│   └── nixos/                        # NixOS-specific (hardware config)
│
├── modules/                          # OLD: to be migrated feature by feature
│   ├── darwin/                       # Old darwin modules
│   └── shared/                       # Old shared modules (vim, tmux, etc)
│
├── pkgs/                             # Custom packages
└── secrets/                          # agenix secrets
```

## What This Achieves

✅ **Single directory**: Everything under `nix/`, not split across `modules/` and `nix/`
✅ **Official tool**: Using `import-tree` package instead of custom code
✅ **Clean migration**: Old modules remain in `nix/modules/` to be migrated incrementally
✅ **Dendritic Pattern**: Auto-discovery with every file as a flake-parts module

## Next Steps

The foundation is now properly in place. Next:
- Migrate features from `nix/modules/shared/` to `nix/programs/`
- Each feature becomes a flake-parts module
- Define `flake.modules.{darwin,nixos,homeManager}.<feature>`
- Hosts import features via `inputs.self.modules.*`

## flake.nix

```nix
inputs.import-tree.url = "github:vic/import-tree";

outputs = inputs @ {flake-parts, import-tree, ...}:
  flake-parts.lib.mkFlake {inherit inputs;} {
    systems = [/* ... */];
    imports = [(import-tree ./nix)];  # Auto-discover all modules!
  };
```

Simple, clean, and using the official tool!
- Remove broken self-referential imports
- Add proper host-specific configuration from git history
- pandoras-box: add homebrew casks (transmit, jdownloader, brave, signal)
- rocket: add work-specific config (Miro email, company, work packages)
- Remove git module imports (will be migrated separately)
This completes the migration of the entire Nix configuration to flake-parts
following the Dendritic Pattern architecture.

## Key Changes

### Feature Modules Migration
- Migrated all 26 feature modules from nix/modules/ to nix/features/
- Each module now defines flake.modules.{darwin,nixos}.<name>
- Shared modules (git, vim, tmux, etc.) work on both darwin and nixos
- Darwin-only modules (hammerspoon, karabiner) only define darwin variant
- All modules auto-discovered via import-tree

### Modules Migrated
Shared modules (21):
- Core: git, vim, tmux, ssh, gpg, user-shell
- Terminal: kitty, ghostty, yazi, bat, ripgrep
- Development: node, python, go, rust
- Applications: gui, mail, discord, ai, zk, mpv, yt-dlp
- Utilities: misc, agenix

Darwin-only modules (2):
- hammerspoon, karabiner

System modules (already in nix/system/):
- user-options, nix-daemon, state-version
- home-manager-integration, fonts, darwin-defaults

### Feature Defaults
- Created nix/system/feature-defaults.nix to set sensible defaults
- Most commonly used features enabled by default with lib.mkDefault
- Hosts can override or opt-in to additional features

### Host Configuration Updates
- Updated all hosts (alcantara, pandoras-box, rocket, nixos)
- Now import feature-defaults module
- Removed direct git imports (use my.modules.git.enable instead)
- Fixed nixos.nix broken import path
- Fixed nixos.nix to use nixosModules instead of darwinModules for agenix

### Cleanup
- Removed old nix/modules/shared/ and nix/modules/darwin/
- Removed nix/programs/ (was example, not needed)
- All functionality preserved and migrated to new structure

## Architecture

Following the Dendritic Pattern:
- Every file is a flake-parts module
- Feature modules define flake.modules.{darwin,nixos,homeManager}.<name>
- Hosts import modules via inputs.self.modules.*
- No specialArgs anti-pattern
- Aspect-oriented organization (by feature, not by platform)
- Auto-discovery via import-tree

The configuration now has a clean separation of concerns with feature
modules in nix/features/, system modules in nix/system/, and host
configurations in nix/hosts/.
- Updated DENDRITIC-MIGRATION.md to reflect completed migration
- Added comprehensive PR description with architecture overview
- Documented testing checklist and known gaps
- Added examples for adding new features
- Included resources and migration path

The documentation now accurately reflects the final state of the
Dendritic Pattern migration with all 26 feature modules migrated,
7 system modules, and 4 host configurations.
- Add Architecture section describing flake-parts and Dendritic Pattern
- Fix broken link to mail.nix (nix/modules/shared → nix/features)
- Link to DENDRITIC-MIGRATION.md for complete details
- Explain auto-discovery, aspect-oriented organization, and module structure

The README now accurately reflects the new modular architecture.
This document described an intermediate migration step. The configuration
has since been fully migrated to the Dendritic Pattern architecture.

Direct users to DENDRITIC-MIGRATION.md for current documentation while
preserving this file for historical context.
…ts, explicit imports

Major corrections to the migration:

1. **Use nix/modules instead of nix/features**
   - Moved all feature modules back to nix/modules/
   - This is the standard location, no need for a separate features/ directory

2. **Remove feature-defaults.nix pattern**
   - Deleted nix/system/feature-defaults.nix
   - Hosts now explicitly import modules they need
   - No lib.mkDefault pattern - just direct imports
   - This is cleaner and more explicit with flake-parts

3. **Fix host structure**
   - Hosts now in nix/hosts/<hostname>/default.nix
   - NixOS has nix/hosts/nixos/flake-module.nix (separate from default.nix which has hardware config)
   - All feature modules explicitly imported in each host

4. **Remove unnecessary comments**
   - Removed "# The actual NixOS module for..." comments
   - Removed "# Define modules for..." comments
   - Kept original comments explaining why things work a certain way
   - Comments should explain why, not what

5. **Update documentation**
   - Fixed all references from nix/features → nix/modules
   - Removed feature-defaults sections
   - Updated examples to show explicit imports
   - Changed from 7 system modules to 6 (removed feature-defaults)

This makes the configuration simpler and more aligned with the Dendritic Pattern -
hosts explicitly declare what they need rather than relying on defaults.
- Move DENDRITIC-MIGRATION.md to docs/
- Move FLAKE-PARTS-MIGRATION.md to docs/
- Move PR_DESCRIPTION.md to docs/
- Update README.md reference to point to new location

All migration-related documentation is now organized in the docs/ directory
for better project structure.
- Delete docs/PR_DESCRIPTION.md (no longer needed)
- Fix host structure in architecture diagram (now in subdirectories)
- Update 'After' migration structure (6 system modules, not 7)
- Fix section heading for host configuration
- Update migration commits list with actual commits
- Change 'features/' references to 'modules/'
- Update key improvements to reflect explicit imports pattern
- Remove all references to feature-defaults (was removed)

Documentation now accurately reflects the final migration state:
- nix/modules/ (not nix/features/)
- nix/hosts/<hostname>/default.nix structure
- Explicit module imports in each host
- No feature-defaults pattern
…modules

- Remove my.modules.*.enable pattern from all 26 feature modules
  - Import statement now serves as the opt-in mechanism
  - Modules with configuration options (mail) retain other options
  - Simplifies module structure by removing unnecessary mkIf wrappers

- Fix duplicate imports in all host configuration files
  - Merge external and internal module imports into single list
  - Use ++ operator to concatenate import arrays

- Exclude non-flake-parts files from import-tree auto-discovery
  - Rename nix/pkgs/ → nix/_pkgs/ (package definitions)
  - Rename nix/secrets/ → nix/_secrets/ (agenix secrets)
  - Rename nix/hosts/nixos/{default,hardware-configuration}.nix with underscore prefix
  - Update all import paths to reference renamed files

This completes the flake-parts migration with explicit imports and no
feature-defaults pattern.
- Convert package definitions to flake-parts modules
  - Move nix/_pkgs/*.nix → nix/pkgs/ with flake-parts wrappers
  - Create hcron.nix and pragmatapro.nix as perSystem.packages modules
  - Update overlays.nix to reference new package file locations

- Convert secrets configuration to flake-parts module
  - Move nix/_secrets/secrets.nix → nix/secrets.nix
  - Wrap in flake-parts module exposing flake.age.secrets
  - Move nix/_secrets/npmrc.age → nix/secrets/npmrc.age
  - Update reference in node.nix module

- Rename NixOS configuration files without underscore prefix
  - Move _default.nix → configuration.nix
  - Move _hardware-configuration.nix → hardware.nix
  - Update import paths in flake-module.nix and configuration.nix

All files are now proper flake-parts modules and auto-discovered by
import-tree. No more underscore-prefixed exclusions needed.
- Fix package duplication in overlays
  - Remove duplicate flake-parts wrapper modules for hcron and pragmatapro
  - Move package definitions to nix/pkgs/_definitions/ (excluded from import-tree)
  - Update overlays.nix to reference _definitions/ subdirectory
  - Packages are now defined once in the overlay, not called twice

- Move secrets.nix to correct location
  - Move nix/secrets.nix → nix/secrets/secrets.nix
  - Maintains flake-parts module structure within secrets subdirectory

- Add missing modules to NixOS configuration
  - Add mail and discord to imports in flake-module.nix
  - These were previously enabled via .enable flags in configuration.nix
  - Now properly imported as modules (import = enable pattern)
- Update architecture diagram with correct file structure
  - pkgs/_definitions/ for package definitions (excluded from import-tree)
  - secrets/secrets.nix as auto-discovered flake-parts module
  - configuration.nix and hardware.nix for NixOS (not _default.nix)

- Document removal of enable pattern
  - Import = enable (no more .enable flags)
  - Clearer, simpler module structure
  - Direct configuration without mkIf wrappers

- Update code examples to reflect current implementation
  - Feature modules without enable options
  - Secrets module structure with flake.age.secrets
  - Package definitions in overlays (no duplicate perSystem.packages)

- Add all migration commits to timeline
- Update benefits section with new improvements
@ahmedelgabri
Copy link
Owner Author

@claude

1 similar comment
@ahmedelgabri
Copy link
Owner Author

@claude

@claude
Copy link

claude bot commented Jan 5, 2026

Claude encountered an error —— View job

Command failed: git fetch origin --depth=20 claude/migrate-nix-flake-parts-dtva1

I'll analyze this and get back to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants