Skip to content

Commit df2e38a

Browse files
committed
feat: add Wayland/Sway profile for Arch Linux VM
Add optional profile architecture for composable configurations: - Create common/profiles/wayland.nix with Sway window manager - Add defaultUsername variable for DRY principle - Add arch homeConfiguration with Wayland profile via extraModules - Update CLAUDE.md with profile architecture documentation Benefits: - Default Linux configs stay minimal (Docker/containers unaffected) - Explicit opt-in for desktop environments via extraModules - Easy to compose multiple profiles in future - Clear separation between base and optional functionality
1 parent d56367c commit df2e38a

File tree

4 files changed

+263
-4
lines changed

4 files changed

+263
-4
lines changed

CLAUDE.md

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ git pull && nixswitch
1818

1919
### Linux (Home Manager)
2020
```bash
21-
# Apply generic Linux configuration
21+
# Apply generic Linux configuration (minimal - for Docker/containers)
2222
hmswitch
2323

2424
# Apply user-specific configuration (if exists)
2525
hm-user
2626

27+
# Apply Arch VM with Wayland/Sway
28+
home-manager switch --flake ~/.config/nix#arch
29+
2730
# Manual commands
2831
home-manager switch --flake ~/.config/nix#linux
2932
home-manager switch --flake ~/.config/nix#$(whoami) # user-specific
@@ -51,6 +54,8 @@ This is a **cross-platform Nix configuration** managing both macOS hosts and Lin
5154
│ ├── programs/default.nix # Shared program configs (direnv, gh, zsh)
5255
│ ├── packages.nix # Package definitions for all systems
5356
│ ├── home-packages.nix # Home Manager package imports
57+
│ ├── profiles/ # Optional configuration profiles
58+
│ │ └── wayland.nix # Wayland/Sway desktop environment
5459
│ ├── claude-code/ # Claude Code integration with custom commands
5560
│ ├── neovim/ # Neovim configuration
5661
│ ├── tmux/ # Tmux configuration
@@ -93,6 +98,7 @@ This is a **cross-platform Nix configuration** managing both macOS hosts and Lin
9398
### Making Configuration Changes
9499
1. Edit configuration files in appropriate directory:
95100
- `common/` for shared changes
101+
- `common/profiles/` for optional profiles (Wayland, etc.)
96102
- `systems/aarch64-darwin/` for macOS-specific
97103
- `systems/aarch64-linux/` for Linux-specific
98104
2. Apply changes using commands above
@@ -104,11 +110,42 @@ This is a **cross-platform Nix configuration** managing both macOS hosts and Lin
104110
- **macOS system packages**: Edit `common/packages.nix` (darwinSystemPackages list)
105111
- **macOS GUI apps**: Edit `systems/aarch64-darwin/homebrew.nix`
106112
- **Linux-specific packages**: Edit `systems/aarch64-linux/home-linux.nix`
113+
- **Profile-specific packages**: Edit `common/profiles/*.nix` (e.g., `wayland.nix` for Sway/Wayland packages)
107114

108115
**IMPORTANT**: Platform-specific packages must be separated:
109116
- macOS-only packages (like `reattach-to-user-namespace`) go in `darwinPackages` and are imported via `systems/aarch64-darwin/home.nix`
117+
- Profile-specific packages (like Sway/Wayland tools) go in `common/profiles/*.nix` and are opt-in via `extraModules`
110118
- Never put macOS-only packages in shared `devPackages` or they'll break Linux builds
111119

120+
### Configuration Profiles
121+
122+
**Profile Architecture**: Optional configurations that extend the base system without polluting minimal environments.
123+
124+
**Available Profiles**:
125+
- `common/profiles/wayland.nix` - Wayland/Sway desktop environment with window manager, status bar, and utilities
126+
127+
**Using Profiles**:
128+
Profiles are opt-in via `extraModules` in `flake.nix`:
129+
130+
```nix
131+
# Minimal configuration (default)
132+
linux = mkHomeManagerConfig {
133+
username = "user";
134+
};
135+
136+
# With Wayland/Sway profile
137+
arch = mkHomeManagerConfig {
138+
username = "svenlito";
139+
extraModules = [ ./common/profiles/wayland.nix ];
140+
};
141+
```
142+
143+
**Benefits**:
144+
- Default stays minimal (Docker/containers unaffected)
145+
- Explicit opt-in for additional functionality
146+
- Easy to compose multiple profiles
147+
- Clear separation of concerns
148+
112149
### Adding New Hosts
113150
Create new configuration in `flake.nix`:
114151
```nix
@@ -143,7 +180,8 @@ Located in `common/claude-code/`, this provides:
143180
- **Node.js**: Uses nodePackages.pnpm from nixpkgs
144181

145182
### Multi-Environment Support
146-
- **Generic Linux**: Flexible Home Manager configuration for any Linux environment
183+
- **Generic Linux**: Flexible Home Manager configuration for any Linux environment (minimal by default)
184+
- **Profile-based configs**: Optional modules for desktop environments (Wayland/Sway), server tools, etc.
147185
- **Development Shell**: Available via `nix develop` for working on this configuration
148186
- **Auto-Detection**: Shell aliases automatically detect system type and hostname
149187

@@ -156,12 +194,18 @@ Located in `common/claude-code/`, this provides:
156194
- SSH configuration for VM connectivity
157195

158196
### Linux (home-manager)
159-
- Minimal configuration - only Linux-specific settings
197+
- **Minimal by default** - base configuration for Docker/containers
198+
- **Profile system** - opt-in desktop environments (Wayland/Sway) or additional tools
160199
- Docker integration (docker-compose package)
161200
- Linux-specific packages: htop, neofetch, curl, wget
162201
- Imports both `common/home-manager-base.nix` and `common/default.nix`
163202
- Auto-optimise-store enabled (better suited for Linux than macOS)
164203

204+
**Available Configurations**:
205+
- `#linux` - Minimal (Docker/containers)
206+
- `#ubuntu` - Minimal for Ubuntu environments
207+
- `#arch` - Full desktop with Wayland/Sway (via `wayland.nix` profile)
208+
165209
## Security Considerations
166210
- SSH keys managed through 1Password integration
167211
- Tailscale for secure cloud connectivity

common/profiles/wayland.nix

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
# Wayland/Sway Profile
2+
# Optional module for desktop environments with Sway window manager
3+
# Usage: Add to extraModules in flake.nix for specific configurations
4+
{ config, pkgs, ... }:
5+
6+
{
7+
# Wayland-specific packages
8+
home.packages = with pkgs; [
9+
# Window manager
10+
sway # Tiling Wayland compositor
11+
swaylock # Screen locker
12+
swayidle # Idle management daemon
13+
14+
# UI components
15+
waybar # Customizable status bar
16+
wofi # Application launcher
17+
mako # Notification daemon
18+
19+
# Utilities
20+
grim # Screenshot tool
21+
slurp # Screen region selector
22+
wl-clipboard # Clipboard utilities (wl-copy, wl-paste)
23+
foot # Wayland-native terminal emulator
24+
25+
# Additional desktop tools
26+
firefox # Web browser (Wayland-native)
27+
];
28+
29+
# Sway window manager configuration
30+
wayland.windowManager.sway = {
31+
enable = true;
32+
config = {
33+
modifier = "Mod4"; # Super/Windows key
34+
terminal = "foot";
35+
menu = "wofi --show drun";
36+
37+
bars = [{ command = "waybar"; }];
38+
39+
# Keybindings with vi-style navigation
40+
keybindings = let mod = config.wayland.windowManager.sway.config.modifier;
41+
in {
42+
# Basic actions
43+
"${mod}+Return" =
44+
"exec ${config.wayland.windowManager.sway.config.terminal}";
45+
"${mod}+Shift+q" = "kill";
46+
"${mod}+d" = "exec ${config.wayland.windowManager.sway.config.menu}";
47+
48+
# Focus navigation (vi-style)
49+
"${mod}+h" = "focus left";
50+
"${mod}+j" = "focus down";
51+
"${mod}+k" = "focus up";
52+
"${mod}+l" = "focus right";
53+
54+
# Move windows (vi-style)
55+
"${mod}+Shift+h" = "move left";
56+
"${mod}+Shift+j" = "move down";
57+
"${mod}+Shift+k" = "move up";
58+
"${mod}+Shift+l" = "move right";
59+
60+
# Workspaces
61+
"${mod}+1" = "workspace number 1";
62+
"${mod}+2" = "workspace number 2";
63+
"${mod}+3" = "workspace number 3";
64+
"${mod}+4" = "workspace number 4";
65+
"${mod}+5" = "workspace number 5";
66+
"${mod}+6" = "workspace number 6";
67+
"${mod}+7" = "workspace number 7";
68+
"${mod}+8" = "workspace number 8";
69+
"${mod}+9" = "workspace number 9";
70+
"${mod}+0" = "workspace number 10";
71+
72+
# Move containers to workspaces
73+
"${mod}+Shift+1" = "move container to workspace number 1";
74+
"${mod}+Shift+2" = "move container to workspace number 2";
75+
"${mod}+Shift+3" = "move container to workspace number 3";
76+
"${mod}+Shift+4" = "move container to workspace number 4";
77+
"${mod}+Shift+5" = "move container to workspace number 5";
78+
"${mod}+Shift+6" = "move container to workspace number 6";
79+
"${mod}+Shift+7" = "move container to workspace number 7";
80+
"${mod}+Shift+8" = "move container to workspace number 8";
81+
"${mod}+Shift+9" = "move container to workspace number 9";
82+
"${mod}+Shift+0" = "move container to workspace number 10";
83+
84+
# Layout
85+
"${mod}+b" = "splith";
86+
"${mod}+v" = "splitv";
87+
"${mod}+s" = "layout stacking";
88+
"${mod}+w" = "layout tabbed";
89+
"${mod}+e" = "layout toggle split";
90+
"${mod}+f" = "fullscreen toggle";
91+
"${mod}+Shift+space" = "floating toggle";
92+
"${mod}+space" = "focus mode_toggle";
93+
94+
# Reload/Exit
95+
"${mod}+Shift+c" = "reload";
96+
"${mod}+Shift+e" =
97+
"exec swaynag -t warning -m 'Exit sway?' -b 'Yes' 'swaymsg exit'";
98+
99+
# Screenshots
100+
"Print" = ''exec grim -g "$(slurp)" - | wl-copy'';
101+
"Shift+Print" = ''
102+
exec grim -g "$(slurp)" ~/Pictures/screenshot-$(date +%Y%m%d-%H%M%S).png'';
103+
};
104+
105+
# Input configuration (adjust as needed)
106+
input = {
107+
"*" = {
108+
xkb_layout = "us";
109+
# Uncomment for touchpad
110+
# tap = "enabled";
111+
# natural_scroll = "enabled";
112+
};
113+
};
114+
115+
# Output configuration (adjust for your display)
116+
output = {
117+
"*" = {
118+
bg = "#1e1e2e solid_color"; # Catppuccin Mocha background
119+
};
120+
};
121+
};
122+
};
123+
124+
# Waybar status bar configuration
125+
programs.waybar = {
126+
enable = true;
127+
settings = {
128+
mainBar = {
129+
layer = "top";
130+
position = "top";
131+
height = 30;
132+
modules-left = [ "sway/workspaces" "sway/mode" ];
133+
modules-center = [ "sway/window" ];
134+
modules-right = [ "cpu" "memory" "clock" ];
135+
136+
cpu = {
137+
format = " {usage}%";
138+
tooltip = false;
139+
};
140+
141+
memory = {
142+
format = " {}%";
143+
tooltip = false;
144+
};
145+
146+
clock = {
147+
format = " {:%H:%M}";
148+
format-alt = " {:%Y-%m-%d}";
149+
tooltip-format = "<tt><small>{calendar}</small></tt>";
150+
};
151+
152+
"sway/workspaces" = {
153+
disable-scroll = true;
154+
all-outputs = true;
155+
};
156+
};
157+
};
158+
159+
# Catppuccin Mocha theme for Waybar
160+
style = ''
161+
* {
162+
font-family: "Hack Nerd Font";
163+
font-size: 13px;
164+
border: none;
165+
border-radius: 0;
166+
}
167+
168+
window#waybar {
169+
background: #1e1e2e;
170+
color: #cdd6f4;
171+
}
172+
173+
#workspaces button {
174+
padding: 0 5px;
175+
background: transparent;
176+
color: #cdd6f4;
177+
border-bottom: 3px solid transparent;
178+
}
179+
180+
#workspaces button.focused {
181+
background: #313244;
182+
border-bottom: 3px solid #89b4fa;
183+
}
184+
185+
#clock,
186+
#cpu,
187+
#memory {
188+
padding: 0 10px;
189+
margin: 0 5px;
190+
background: #313244;
191+
}
192+
'';
193+
};
194+
195+
# Mako notification daemon configuration
196+
services.mako = {
197+
enable = true;
198+
backgroundColor = "#1e1e2e";
199+
textColor = "#cdd6f4";
200+
borderColor = "#89b4fa";
201+
borderSize = 2;
202+
borderRadius = 5;
203+
defaultTimeout = 5000;
204+
};
205+
}

flake.nix

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131

3232
outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew, home-manager, }:
3333
let
34+
# Default username across all configurations
35+
defaultUsername = "svenlito";
36+
3437
# Utility function to create nixpkgs for different systems
3538
mkNixpkgs = system:
3639
import nixpkgs {
@@ -105,7 +108,7 @@
105108
darwinConfigurations = {
106109
"rick" = mkDarwinSystem (validateUsername "rick" {
107110
hostname = "rick";
108-
username = "svenlito";
111+
username = defaultUsername;
109112
});
110113
};
111114

@@ -118,6 +121,12 @@
118121
};
119122

120123
ubuntu = mkHomeManagerConfig { username = "ubuntu"; };
124+
125+
# Arch Linux VM with Wayland/Sway profile
126+
arch = mkHomeManagerConfig {
127+
username = defaultUsername;
128+
extraModules = [ ./common/profiles/wayland.nix ];
129+
};
121130
};
122131

123132
# Development shell for working on this configuration

systems/aarch64-darwin/homebrew.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# Development & Terminal
3232
"orbstack"
3333
"ghostty"
34+
"utm"
3435

3536
# Networking & VPN
3637
"tailscale-app"

0 commit comments

Comments
 (0)