Skip to content

Commit 4b2fbda

Browse files
committed
Refactor Nix configuration for improved cross-platform support
Major architectural improvements: - Remove Vagrant/Packer infrastructure in favor of direct Linux support - Add centralized version management (common/versions.nix) - Create shared Home Manager base configuration - Enhance package management with better categorization and documentation - Add platform-agnostic shell aliases and Nix utilities - Optimize build performance with improved substituter settings - Simplify deployment with auto-detection commands (nixswitch, hmswitch) - Update documentation to reflect new hybrid architecture This migration moves from VM-based development to direct Linux configuration, making the setup more maintainable and performant across macOS/Linux environments.
1 parent 5124a88 commit 4b2fbda

File tree

15 files changed

+477
-564
lines changed

15 files changed

+477
-564
lines changed

CLAUDE.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,30 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
66

77
### macOS (nix-darwin)
88
```bash
9-
# Apply system configuration (replace 'rick' with your hostname)
10-
darwin-rebuild switch --flake ~/.config/nix#rick
9+
# Apply system configuration (auto-detects hostname)
10+
nixswitch
11+
12+
# Or manually specify hostname
13+
sudo darwin-rebuild switch --flake ~/.config/nix#$(scutil --get LocalHostName)
1114

1215
# Update and apply configuration
13-
git pull && darwin-rebuild switch --flake ~/.config/nix#rick
16+
git pull && nixswitch
1417
```
1518

16-
### Development VM (Vagrant)
19+
### Linux (Home Manager)
1720
```bash
18-
# Start VM
19-
vagrant up
20-
21-
# SSH into VM
22-
vagrant ssh
21+
# Apply generic Linux configuration
22+
hmswitch
2323

24-
# Apply configuration changes
25-
vagrant provision
24+
# Apply user-specific configuration (if exists)
25+
hm-user
2626

27-
# Inside VM: Apply home-manager configuration
28-
nix run home-manager/master -- switch --flake ~/.config/nix#vagrant --impure
29-
```
30-
31-
### Cloud (EC2)
32-
```bash
33-
# Build AMI with Packer
34-
cd packer && packer build -var "aws_profile=dev" aws-ec2.pkr.hcl
27+
# Manual commands
28+
home-manager switch --flake ~/.config/nix#linux
29+
home-manager switch --flake ~/.config/nix#$(whoami) # user-specific
3530

36-
# Apply EC2 home-manager configuration
37-
nix run home-manager/master -- switch --flake ~/.config/nix#ec2 --impure
31+
# Update and apply configuration
32+
git pull && hmswitch
3833
```
3934

4035
## Architecture Overview
@@ -84,15 +79,20 @@ This is a **cross-platform Nix configuration** managing both macOS hosts and Lin
8479
- **Add everywhere**: Edit `common/packages.nix` (corePackages or devPackages lists)
8580
- **macOS system packages**: Edit `common/packages.nix` (darwinSystemPackages list)
8681
- **macOS GUI apps**: Edit `systems/aarch64-darwin/homebrew.nix`
87-
- **Linux-specific packages**: Edit `systems/aarch64-linux/vagrant.nix` or `ec2.nix`
82+
- **Linux-specific packages**: Edit `systems/aarch64-linux/home-linux.nix`
8883

8984
### Adding New Hosts
9085
Create new configuration in `flake.nix`:
9186
```nix
92-
"hostname" = darwinSystem {
87+
# For macOS
88+
"hostname" = mkDarwinSystem {
9389
hostname = "hostname";
9490
username = "username";
95-
# Additional config...
91+
};
92+
93+
# For Linux
94+
"username" = mkHomeManagerConfig {
95+
username = "username";
9696
};
9797
```
9898

@@ -109,9 +109,9 @@ Located in `common/claude-code/`, this provides:
109109
- **Node.js**: Uses nodePackages.pnpm from nixpkgs
110110

111111
### Multi-Environment Support
112-
- **Vagrant**: Local development VM with UTM integration
113-
- **EC2**: Cloud development with Packer AMI building
114-
- **Tailscale**: Secure connectivity for cloud instances
112+
- **Generic Linux**: Flexible Home Manager configuration for any Linux environment
113+
- **Development Shell**: Available via `nix develop` for working on this configuration
114+
- **Auto-Detection**: Shell aliases automatically detect system type and hostname
115115

116116
## Platform-Specific Notes
117117

Vagrantfile

Lines changed: 0 additions & 210 deletions
This file was deleted.

common/default.nix

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,25 @@
99
experimental-features = [ "nix-command" "flakes" ];
1010
trusted-users = [ "root" username ];
1111

12-
# Settings to improve lock handling
12+
# Performance optimizations
13+
max-jobs = "auto";
14+
cores = 0; # Use all available cores
15+
build-cores = 0;
16+
17+
# Settings to improve lock handling and build performance
1318
use-case-hack = true;
1419
fallback = true;
1520
keep-going = true;
16-
log-lines = 50;
17-
connect-timeout = 10;
18-
download-buffer-size = 65536; # 64MB download buffer
21+
log-lines = 25;
22+
download-buffer-size =
23+
268435456; # 256MB download buffer (optimized for 16GB RAM)
24+
25+
# Substituter optimizations for 16GB RAM system
26+
builders-use-substitutes = true;
27+
http-connections = 50; # Increased for faster parallel downloads
28+
max-substitution-jobs = 32; # Increased for better parallelization
29+
stalled-download-timeout = 300; # 5 minutes timeout
30+
connect-timeout = 30; # Optimized connection timeout
1931
};
2032

2133
# Set up automatic store optimization

common/home-manager-base.nix

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Base Home Manager configuration shared across all platforms
2+
{ nixpkgs, ... }:
3+
4+
{
5+
# Allow unfree packages
6+
nixpkgs.config.allowUnfree = true;
7+
8+
# Nix configuration with experimental features
9+
nix = {
10+
package = nixpkgs.legacyPackages.aarch64-linux.nix;
11+
settings = {
12+
experimental-features = [ "nix-command" "flakes" ];
13+
14+
# Additional performance settings
15+
auto-optimise-store = false; # Let nix-darwin handle this
16+
use-case-hack = true;
17+
fallback = true;
18+
};
19+
};
20+
}

0 commit comments

Comments
 (0)