Commit f3e026f
Remove marker-based editing, use packages.json state file (#32)
## Summary
This PR removes the marker-based flake.nix editing system in favor of a
JSON state file (`packages.json`) that tracks installed packages. The
flake.nix is now completely regenerated on every change instead of being
edited in place.
- Add new `state` module with `PackageState` struct for managing
packages.json
- Add `migration` module for one-time automatic migration from
marker-based format
- Simplify template generation (no more markers in output)
- Update install/uninstall/list commands to use state file
- Remove `editor.rs` (marker editing no longer needed)
- Remove `--force` flag from install (no longer relevant)
- Remove ~1200 lines of marker manipulation code
**State file format**
(`~/.config/nixy/profiles/<profile>/packages.json`):
```json
{
"version": 1,
"packages": ["ripgrep", "fzf", "bat"],
"custom_packages": [
{
"name": "neovim",
"input_name": "neovim-nightly",
"input_url": "github:nix-community/neovim-nightly-overlay",
"package_output": "packages"
}
]
}
```
**Benefits:**
- Simpler code (removed complex string manipulation)
- Cleaner flake.nix (no marker comments)
- Easier debugging (state visible in JSON)
- Better testability (state separate from generation)
- One-time automatic migration for existing users
Fixes #26
## Test plan
- [x] Run `cargo test` - all 138 tests pass (75 unit + 63 integration)
- [x] Run `cargo clippy` - no warnings
- [ ] Test migration: create a flake with markers, run nixy command,
verify packages.json is created
- [ ] Test install: `nixy install hello` - verify packages.json updated
and flake.nix regenerated
- [ ] Test uninstall: `nixy uninstall hello` - verify package removed
from state and flake
- [ ] Test list: `nixy list` - verify packages listed from state file
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent ed53007 commit f3e026f
15 files changed
Lines changed: 1139 additions & 1694 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | 69 | | |
74 | 70 | | |
75 | 71 | | |
| |||
0 commit comments