Skip to content

Commit 699501e

Browse files
committed
chore: Add CLAUDE.md
1 parent 2580886 commit 699501e

2 files changed

Lines changed: 46 additions & 19 deletions

File tree

CLAUDE.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,31 @@ This is a Nix-based dotfiles repository using Flakes for managing system configu
1010

1111
## Essential Commands
1212

13-
All system management is done through the `hey` command (located in `bin/hey`), which wraps a justfile:
13+
System management can be done through the `hey` command (located in `bin/hey`) or directly with darwin-rebuild:
1414

1515
```bash
16+
# Using hey wrapper (if available):
1617
hey rebuild # Rebuild and switch to new configuration (alias: hey re)
1718
hey upgrade # Update flake inputs and rebuild
1819
hey rollback # Roll back to previous generation
1920
hey gc # Run garbage collection
2021
hey check # Run flake checks
2122
hey show # Show flake outputs
2223
hey test # Quick rebuild without adding to bootloader
24+
25+
# Direct darwin-rebuild commands:
26+
sudo darwin-rebuild switch -I darwin=. # Rebuild and switch to new configuration
27+
sudo darwin-rebuild switch --flake . # Alternative flake syntax
28+
darwin-rebuild --list-generations # List available generations
29+
sudo darwin-rebuild --rollback # Roll back to previous generation
30+
nix-collect-garbage -d # Garbage collection
2331
```
2432

2533
For development:
2634
```bash
27-
hey shell <package> # Start nix shell with package
28-
hey repl # Start nix repl with flake
29-
hey search <term> # Search for packages
35+
hey shell <package> # Start nix shell with package (or: nix shell nixpkgs#<package>)
36+
hey repl # Start nix repl with flake (or: nix repl)
37+
hey search <term> # Search for packages (or: nix search nixpkgs <term>)
3038
```
3139

3240
## Architecture
@@ -76,14 +84,14 @@ in {
7684

7785
### Testing Configuration Changes
7886
1. Make changes to relevant files
79-
2. Run `hey test` for quick testing (doesn't update boot)
80-
3. Run `hey rebuild` to apply permanently
81-
4. If issues occur: `hey rollback`
87+
2. Run `sudo darwin-rebuild switch -I darwin=.` to rebuild and switch
88+
3. If issues occur: `sudo darwin-rebuild --rollback`
8289

8390
### Updating Dependencies
8491
```bash
85-
hey upgrade # Update all flake inputs
86-
nix flake update # Update specific input
92+
nix flake update # Update all flake inputs
93+
nix flake update <input> # Update specific input
94+
sudo darwin-rebuild switch -I darwin=. # Apply updates
8795
```
8896

8997
### Adding New Packages
@@ -108,7 +116,8 @@ nix flake update # Update specific input
108116

109117
## Notes
110118

111-
- The `hey` command must be run from the repository root
112-
- After major updates, run `hey gc` to clean old generations
119+
- Commands must be run from the repository root
120+
- After major updates, run `nix-collect-garbage -d` to clean old generations
113121
- Host-specific settings override module defaults
114-
- The system uses home-manager for user-level configuration
122+
- The system uses home-manager for user-level configuration
123+
- The `hey` command (if available) provides convenient wrappers for common operations

bin/hey

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env cached-nix-shell
2-
#! nix-shell -i "just --justfile" --quiet
3-
#! nix-shell -p just
2+
#! nix-shell -p just -i "just --justfile" --quiet
43

54
# Nix's CLI has a poor user story, in my opinion. It could be better; Guix is a
65
# good role model here. I wrote this script to abstract the more common
@@ -13,7 +12,7 @@
1312
# are often and easily forgotten. This spares me that fumbling phase and also
1413
# serves as a reference.
1514

16-
FLAKE := "../"
15+
FLAKE := "."
1716
HOST := ""
1817
# FIXME HOST := env_var('HOST')
1918

@@ -49,9 +48,15 @@ rebuild +ARGS='switch':
4948
shift
5049
fi
5150
set -x
52-
sudo nixos-rebuild \
53-
--flake {{FLAKE}} \
54-
--option pure-eval no {{ARGS}} "$@"
51+
if [[ "$(uname)" == "Darwin" ]]; then
52+
sudo darwin-rebuild \
53+
-I darwin={{FLAKE}} \
54+
{{ARGS}} "$@"
55+
else
56+
sudo nixos-rebuild \
57+
--flake {{FLAKE}} \
58+
--option pure-eval no {{ARGS}} "$@"
59+
fi
5560

5661
repl:
5762
#!/usr/bin/env bash
@@ -88,8 +93,17 @@ show:
8893
rebuild --fast test {{ARGS}}
8994

9095
rollback:
96+
#!/usr/bin/env bash
9197
# Roll back to last generation
92-
rebuild --rollback switch
98+
if [[ "$(uname)" == "Darwin" ]]; then
99+
sudo darwin-rebuild --rollback
100+
else
101+
rebuild --rollback switch
102+
fi
103+
104+
gc:
105+
# Run garbage collection
106+
nix-collect-garbage -d
93107

94108
alias u := update
95109

@@ -112,6 +126,10 @@ update +FLAKES='':
112126
# Search nixpkgs for a package
113127
nix search nixpkgs {{QUERY}}
114128

129+
@shell PACKAGE:
130+
# Start nix shell with package
131+
nix shell nixpkgs#{{PACKAGE}}
132+
115133
@swap PATHS:
116134
#!/usr/bin/env bash
117135
# Recursively swap nix-store symlinks with copies (or back).

0 commit comments

Comments
 (0)