style:justfile

This commit is contained in:
dichgrem
2025-12-01 16:03:11 +08:00
parent ea529f56a9
commit 50185f2b0a

View File

@@ -5,79 +5,80 @@ hostname := `hostname`
username := `whoami` username := `whoami`
anywhere input: @anywhere input:
# Perform nixos-anywhere install # 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}} 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) # 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 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 # Test nixos-anywhere install in vm
nix run github:nix-community/nixos-anywhere -- --flake .#{{input}} --vm-test nix run github:nix-community/nixos-anywhere -- --flake .#{{input}} --vm-test
build input: @build input:
# Build # Build
sudo nixos-rebuild build --flake .#{{input}} --show-trace -L -v sudo nixos-rebuild build --flake .#{{input}} --show-trace -L -v
build-vm input: @build-vm input:
# Build a vm # Build a vm
sudo nixos-rebuild build-vm --flake .#{{input}} --show-trace -L -v 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 # Remove useless nix-channel files
sudo rm -rf /nix/var/nix/profiles/per-user/root/channels /root/.nix-defexpr/channels sudo rm -rf /nix/var/nix/profiles/per-user/root/channels /root/.nix-defexpr/channels
format: @gc:
# Use alejandra and deadnix to format code
deadnix -e
alejandra .
gc:
# Do garbage-clean (remove unused packages, etc) # Do garbage-clean (remove unused packages, etc)
sudo nix profile wipe-history --older-than 7d --profile /nix/var/nix/profiles/system sudo nix profile wipe-history --older-than 7d --profile /nix/var/nix/profiles/system
sudo nix-collect-garbage --delete-old sudo nix-collect-garbage --delete-old
ghc: @ghc:
# Generate hardware.nix # Generate hardware.nix
nixos-generate-config --show-hardware-config > ./hosts/{{hostname}}/hardware.nix nixos-generate-config --show-hardware-config > ./hosts/{{hostname}}/hardware.nix
install: @install:
# Install this flake # Install this flake
bash install.sh bash install.sh
list: @cat:
# List system packages # List system packages
nix-store -qR /run/current-system | cat nix-store -qR /run/current-system | cat
profile: @list:
# Show system profile sudo nix-env -p /nix/var/nix/profiles/system --list-generations
sudo nix profile history --profile /nix/var/nix/profiles/system
switch input: @diff:
# Let system rebuild and switch sudo nix profile diff-closures --profile /nix/var/nix/profiles/system
sudo nixos-rebuild switch --flake .#{{input}} --show-trace -L -v
update: @delete generation:
sudo nix-env -p /nix/var/nix/profiles/system --delete-generations {{generation}}
@update:
# Update flake.lock # Update flake.lock
nix flake update --extra-experimental-features flakes --extra-experimental-features nix-command --show-trace nix flake update --extra-experimental-features flakes --extra-experimental-features nix-command --show-trace
upgrade: @upgrade:
# Let system totally upgrade # Let system totally upgrade
## Set hostname and username in flake.nix ## Set hostname and username in flake.nix
sed -i "/^\s*hostname[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"{{hostname}}\"/" ./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 sudo nixos-rebuild switch --flake .#{{hostname}} --show-trace
upgrade-debug: @upgrade-debug:
# Let system totally upgrade (deBug Mode) # Let system totally upgrade (deBug Mode)
## Set hostname and username in flake.nix ## Set hostname and username in flake.nix
sed -i "/^\s*hostname[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"{{hostname}}\"/" ./flake.nix sed -i "/^\s*hostname[[:space:]]*=[[:space:]]*\"/s/\"\(.*\)\"/\"{{hostname}}\"/" ./flake.nix