Files
dotfiles/Makefile
Pierre Martin aa3fb5c5fe Add update and gc targets to Makefile
Add `make update` to run nixos-rebuild switch --upgrade-all followed by
garbage collection, and `make gc` to clean up user/system generations
older than 14 days and run nix-collect-garbage.
2026-03-19 09:55:15 +01:00

54 lines
1.4 KiB
Makefile

.PHONY: all fmt fmt-nix fmt-shell lint lint-shell check clean update gc
export NIX_PAGER=
all: fmt lint
# Formatage
fmt: fmt-nix fmt-shell
fmt-nix:
find . -name '*.nix' -not -path './.direnv/*' | xargs nixfmt
fmt-shell:
find . -name '*.sh' -not -path './.direnv/*' | xargs shfmt -w -i 2
# Validation
lint: lint-shell
lint-shell:
find . -name '*.sh' -not -path './.direnv/*' | xargs shellcheck
# Vérification sans modification
check:
find . -name '*.nix' -not -path './.direnv/*' | xargs nixfmt --check
find . -name '*.sh' -not -path './.direnv/*' | xargs shfmt -d -i 2
# Nettoyage
clean:
rm -rf .direnv result
# Mise à jour NixOS + home-manager + garbage collect
update:
sudo nixos-rebuild switch --upgrade-all
$(MAKE) gc
# Nettoyage Nix (générations > 14 jours + garbage collect)
gc:
@echo "=== Générations utilisateur ==="
nix-env --list-generations
@echo ""
@echo "Suppression des générations utilisateur > 14 jours..."
nix-env --delete-generations 14d
@echo ""
@echo "=== Générations système ==="
sudo nix-env --list-generations --profile /nix/var/nix/profiles/system
@echo ""
@echo "Suppression des générations système > 14 jours..."
sudo nix-env --delete-generations 14d --profile /nix/var/nix/profiles/system
@echo ""
@echo "=== Garbage collection ==="
sudo nix-collect-garbage
@echo ""
@echo "=== Espace disque /nix/store ==="
du -sh /nix/store