nixos/Justfile
2026-05-22 15:51:43 -03:00

49 lines
1.5 KiB
Makefile

# List all available recipes
default:
@just --list
# Rebuild and switch to the new configuration (uses current hostname by default)
switch hostname=`hostname`:
sudo nixos-rebuild switch --flake .#{{hostname}}
# Build without switching — useful to check the result before applying
build hostname=`hostname`:
nixos-rebuild build --flake .#{{hostname}}
# Apply the new configuration temporarily (reverts on next boot)
test hostname=`hostname`:
sudo nixos-rebuild test --flake .#{{hostname}}
# Update all flake inputs to their latest locked versions
update:
nix flake update
# Update a single flake input (e.g. just update-input nixpkgs)
update-input input:
nix flake update {{input}}
# Check the flake for evaluation errors
check:
nix flake check
# Open a Nix REPL with the flake loaded
repl:
nix repl --expr 'builtins.getFlake (toString ./.)'
# Delete Nix store paths older than 7 days and run the garbage collector
gc:
sudo nix-collect-garbage --delete-older-than 7d
nix-collect-garbage --delete-older-than 7d
# List all system generations
generations:
sudo nix-env --list-generations --profile /nix/var/nix/profiles/system
# Edit the SOPS-encrypted secrets file
secrets:
sops secrets/secrets.yaml
# Show a diff between the running system and the current build
diff hostname=`hostname`:
nix build .#nixosConfigurations.{{hostname}}.config.system.build.toplevel --no-link
nvd diff /run/current-system $(nix path-info .#nixosConfigurations.{{hostname}}.config.system.build.toplevel)