Skip to content

Commit f3e026f

Browse files
yusukeshibclaude
andauthored
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

File tree

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "nixy-rs"
3-
version = "0.1.6"
3+
version = "0.1.7"
44
edition = "2021"
55
rust-version = "1.80"
66
description = "Homebrew-style wrapper for Nix using flake.nix"
@@ -17,6 +17,8 @@ dirs = "5"
1717
thiserror = "2"
1818
colored = "2"
1919
regex = "1"
20+
serde = { version = "1", features = ["derive"] }
21+
serde_json = "1"
2022
self_update = { version = "0.42", default-features = false, features = ["rustls"] }
2123

2224
[dev-dependencies]

src/cli.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ pub struct InstallArgs {
6666
/// Install from local nix file
6767
#[arg(long, short)]
6868
pub file: Option<PathBuf>,
69-
70-
/// Force regeneration even if flake.nix has custom modifications
71-
#[arg(long)]
72-
pub force: bool,
7369
}
7470

7571
#[derive(Args)]

0 commit comments

Comments
 (0)