Skip to content

Commit ed53007

Browse files
yusukeshibclaude
andauthored
Remove gc command (#31)
## Summary - Remove the `gc` command which inappropriately ran `nix-collect-garbage -d` - nixy uses `nix build --out-link`, not `nix profile`, so there are no nixy-specific generations to GC - Added FAQ entry in README explaining how to clean up Nix store manually - Bump version to 0.1.5 ## Rationale The `gc` command was problematic because: 1. It ran `nix-collect-garbage -d` which affects ALL Nix profiles system-wide 2. nixy doesn't create its own profile generations (uses `--out-link` instead) 3. Users expecting nixy-scoped cleanup got system-wide cleanup instead Users who want to clean up unused Nix store paths can run `nix-collect-garbage -d` directly. ## Test plan - [x] Run cargo test (59 tests pass) - [x] `nixy --help` no longer shows gc command - [x] Documentation updated (README.md and README_ja.md) Closes #21 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1fddc70 commit ed53007

9 files changed

Lines changed: 19 additions & 64 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "nixy-rs"
3-
version = "0.1.5"
3+
version = "0.1.6"
44
edition = "2021"
55
rust-version = "1.80"
66
description = "Homebrew-style wrapper for Nix using flake.nix"

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ Packages are installed globally and available in all terminal sessions.
143143
| `nixy search <query>` | | Search for packages |
144144
| `nixy upgrade [input...]` | | Upgrade all inputs or specific ones |
145145
| `nixy sync` | | Build environment from flake.nix (for new machines) |
146-
| `nixy gc` | | Clean up old package versions |
147146

148147
### Profile Management
149148

@@ -274,6 +273,15 @@ Packages with non-free licenses (e.g., `graphite-cli`, `slack`) are allowed by d
274273
nixy install slack
275274
```
276275

276+
**How do I clean up old Nix store paths?**
277+
nixy doesn't provide a garbage collection command because it uses `nix build --out-link` instead of `nix profile`. To clean up unused Nix store paths, use the standard Nix command directly:
278+
279+
```bash
280+
nix-collect-garbage -d
281+
```
282+
283+
Note: This will clean up ALL unused Nix profiles and store paths on your system, not just nixy-related ones.
284+
277285
---
278286

279287
## Appendix

README_ja.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ nixy upgrade # 全パッケージをアップグレード
127127
| `nixy search <query>` | | パッケージを検索 |
128128
| `nixy upgrade [input...]` | | 全 input または指定した input をアップグレード |
129129
| `nixy sync` | | flake.nix から環境をビルド(新しいマシン用) |
130-
| `nixy gc` | | 古いパッケージを削除 |
131130

132131
### プロファイル管理
133132

@@ -258,6 +257,15 @@ nixy sync # 古い状態を適用
258257
nixy install slack
259258
```
260259

260+
**古い Nix ストアパスをクリーンアップするには?**
261+
nixy は `nix profile` ではなく `nix build --out-link` を使用しているため、ガベージコレクションコマンドを提供していません。未使用の Nix ストアパスをクリーンアップするには、標準の Nix コマンドを直接使用してください:
262+
263+
```bash
264+
nix-collect-garbage -d
265+
```
266+
267+
注意:これは nixy 関連のものだけでなく、システム上のすべての未使用の Nix プロファイルとストアパスをクリーンアップします。
268+
261269
---
262270

263271
## 付録

src/cli.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ pub enum Commands {
3838
/// Build environment from flake.nix and create symlink
3939
Sync(SyncArgs),
4040

41-
/// Garbage collect old generations
42-
Gc,
43-
4441
/// Output shell config (for eval in rc files)
4542
Config {
4643
/// Shell type (bash, zsh, fish)

src/commands/gc.rs

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

src/commands/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
pub mod config;
2-
pub mod gc;
32
pub mod install;
43
pub mod list;
54
pub mod profile;

src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ fn main() {
3030
Commands::Search { query } => commands::search::run(&query),
3131
Commands::Upgrade(args) => commands::upgrade::run(&config, args),
3232
Commands::Sync(_) => commands::sync::run(&config),
33-
Commands::Gc => commands::gc::run(),
3433
Commands::Config { shell } => commands::config::run(&shell),
3534
Commands::Profile(args) => commands::profile::run(&config, args),
3635
Commands::SelfUpgrade(args) => commands::self_upgrade::run(args.force),

src/nix.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -301,20 +301,6 @@ impl Nix {
301301
.map(String::from)
302302
.collect())
303303
}
304-
305-
/// Run garbage collection
306-
pub fn gc() -> Result<()> {
307-
let status = Command::new("nix-collect-garbage")
308-
.arg("-d")
309-
.status()
310-
.map_err(|e| Error::NixCommand(e.to_string()))?;
311-
312-
if !status.success() {
313-
return Err(Error::NixCommand("Garbage collection failed".to_string()));
314-
}
315-
316-
Ok(())
317-
}
318304
}
319305

320306
#[cfg(test)]

tests/integration.rs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -393,29 +393,6 @@ fn test_search_requires_query() {
393393
assert!(!output.status.success());
394394
}
395395

396-
// =============================================================================
397-
// GC command tests
398-
// =============================================================================
399-
400-
#[test]
401-
fn test_gc_runs() {
402-
// GC should run without error (even if nix gc does nothing)
403-
let output = nixy_cmd().arg("gc").output().unwrap();
404-
// May succeed or fail depending on nix availability
405-
let stdout = String::from_utf8_lossy(&output.stdout);
406-
let stderr = String::from_utf8_lossy(&output.stderr);
407-
// Should at least attempt to run
408-
assert!(
409-
output.status.success()
410-
|| stdout.contains("garbage")
411-
|| stderr.contains("nix")
412-
|| stderr.contains("gc"),
413-
"GC should attempt to run: stdout={}, stderr={}",
414-
stdout,
415-
stderr
416-
);
417-
}
418-
419396
// =============================================================================
420397
// Help content tests
421398
// =============================================================================
@@ -468,14 +445,6 @@ fn test_help_shows_sync_command() {
468445
assert!(stdout.contains("sync"));
469446
}
470447

471-
#[test]
472-
fn test_help_shows_gc_command() {
473-
let output = nixy_cmd().arg("--help").output().unwrap();
474-
assert!(output.status.success());
475-
let stdout = String::from_utf8_lossy(&output.stdout);
476-
assert!(stdout.contains("gc"));
477-
}
478-
479448
#[test]
480449
fn test_help_shows_config_command() {
481450
let output = nixy_cmd().arg("--help").output().unwrap();

0 commit comments

Comments
 (0)