about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2024-12-19 13:11:40 -0800
committerFranck Cuny <franck@fcuny.net>2024-12-19 13:11:40 -0800
commitc13f5d955ba44e28c4b2b241eaa5cf92748d7021 (patch)
tree975c9e832f8dd5856a21e79e754692858474fc6a
parentadd a default recipe to just (diff)
downloadworld-c13f5d955ba44e28c4b2b241eaa5cf92748d7021.tar.gz
add a few more rules to justfile
-rw-r--r--justfile29
-rw-r--r--nix/users/fcuny/shell.nix2
2 files changed, 29 insertions, 2 deletions
diff --git a/justfile b/justfile
index 842e16d..ac8dc64 100644
--- a/justfile
+++ b/justfile
@@ -6,7 +6,7 @@ nixaddr := ""
 hostname := lowercase(`hostname -s`)
 
 default:
-    just --list
+    @just --list
 
 [group('nix')]
 [doc('update dependencies')]
@@ -24,6 +24,33 @@ test-nix:
 fmt:
 	nix fmt
 
+# Nix Store can contains corrupted entries if the nix store object has been modified unexpectedly.
+# This command will verify all the store entries,
+# and we need to fix the corrupted entries manually via `sudo nix store delete <store-path-1> <store-path-2> ...`
+[group('nix')]
+[doc('verify all the store entries')]
+verify-store:
+  nix store verify --all
+
+[group('nix')]
+[doc('garbage collect all unused nix store entries (system-wide and home-manager)')]
+gc:
+  # garbage collect all unused nix store entries(system-wide)
+  sudo nix-collect-garbage --delete-older-than 7d
+  # garbage collect all unused nix store entries(for the user - home-manager)
+  # https://github.com/NixOS/nix/issues/8508
+  nix-collect-garbage --delete-older-than 7d
+
+[group('nix')]
+[doc('list recent version')]
+history:
+	nix profile history --profile /nix/var/nix/profiles/system
+
+[group('nix')]
+[doc('show all the auto gc roots in the nix store')]
+gcroot:
+  ls -al /nix/var/nix/gcroots/auto/
+
 [group('secrets')]
 [doc('edit a secret')]
 [macos]
diff --git a/nix/users/fcuny/shell.nix b/nix/users/fcuny/shell.nix
index e690437..69b771f 100644
--- a/nix/users/fcuny/shell.nix
+++ b/nix/users/fcuny/shell.nix
@@ -41,7 +41,7 @@ in
       set fish_greeting ""
     '';
     shellAbbrs = {
-      ncg = "nix-collect-garbage -d";
+      ncg = "nix-collect-garbage -7d";
       c = "clear";
     };
     shellAliases = {