From 50185f2b0af654cc63461b11cb610f88a2664c1b Mon Sep 17 00:00:00 2001 From: dichgrem Date: Mon, 1 Dec 2025 16:03:11 +0800 Subject: [PATCH] style:justfile --- Justfile | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/Justfile b/Justfile index fb304ff..223957f 100644 --- a/Justfile +++ b/Justfile @@ -5,79 +5,80 @@ hostname := `hostname` username := `whoami` -anywhere input: +@anywhere input: # Perform nixos-anywhere install nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-generate-config ./hosts/{{input}}/hardware.nix --flake .#{{input}} --target-host root@{{input}} -anywhere-lb input: +@anywhere-lb input: # Perform nixos-anywhere install (local builder) nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-generate-config ./hosts/{{input}}/hardware.nix --flake .#{{input}} --target-host root@{{input}} --build-on local -anywhere-vm input: +@anywhere-vm input: # Test nixos-anywhere install in vm nix run github:nix-community/nixos-anywhere -- --flake .#{{input}} --vm-test -build input: +@build input: # Build sudo nixos-rebuild build --flake .#{{input}} --show-trace -L -v -build-vm input: +@build-vm input: # Build a vm sudo nixos-rebuild build-vm --flake .#{{input}} --show-trace -L -v -clean: +@switch input: + # Let system rebuild and switch + sudo nixos-rebuild switch --flake .#{{input}} --show-trace -L -v + + +@clean: # Remove useless nix-channel files sudo rm -rf /nix/var/nix/profiles/per-user/root/channels /root/.nix-defexpr/channels -format: - # Use alejandra and deadnix to format code - deadnix -e - alejandra . - - -gc: +@gc: # Do garbage-clean (remove unused packages, etc) sudo nix profile wipe-history --older-than 7d --profile /nix/var/nix/profiles/system sudo nix-collect-garbage --delete-old -ghc: +@ghc: # Generate hardware.nix nixos-generate-config --show-hardware-config > ./hosts/{{hostname}}/hardware.nix -install: +@install: # Install this flake bash install.sh -list: +@cat: # List system packages nix-store -qR /run/current-system | cat -profile: - # Show system profile - sudo nix profile history --profile /nix/var/nix/profiles/system +@list: + sudo nix-env -p /nix/var/nix/profiles/system --list-generations -switch input: - # Let system rebuild and switch - sudo nixos-rebuild switch --flake .#{{input}} --show-trace -L -v +@diff: + sudo nix profile diff-closures --profile /nix/var/nix/profiles/system -update: +@delete generation: + sudo nix-env -p /nix/var/nix/profiles/system --delete-generations {{generation}} + + +@update: # Update flake.lock nix flake update --extra-experimental-features flakes --extra-experimental-features nix-command --show-trace -upgrade: +@upgrade: # Let system totally upgrade ## Set hostname and username in flake.nix sed -i "/^\s*hostname[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"{{hostname}}\"/" ./flake.nix @@ -87,7 +88,7 @@ upgrade: sudo nixos-rebuild switch --flake .#{{hostname}} --show-trace -upgrade-debug: +@upgrade-debug: # Let system totally upgrade (deBug Mode) ## Set hostname and username in flake.nix sed -i "/^\s*hostname[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"{{hostname}}\"/" ./flake.nix