# Lockfile utils
.PHONY: update-lockfile
update-lockfile:
	nix flake update --commit-lock-file

.PHONY: update-lockfile-without-commit
update-lockfile-without-commit:
	nix flake update

# Agenix utils
.PHONY: edit-secret
edit-secret:
	cd secrets && agenix -e $(filter-out $@,$(MAKECMDGOALS))

.PHONY: rekey-secrets
rekey-secrets:
	cd secrets && agenix -r

# NixOS utils
.PHONY: clean-old-nixos-profiles
clean-old-nixos-profiles:
	doas nix-collect-garbage -d

# Garbage Collect
.PHONY: gc
gc:
	nix store gc

# Update a flake input by name (ex: 'nixpkgs')
.PHONY: update-input
update-input:
	nix flake update $(filter-out $@,$(MAKECMDGOALS))

# Build Custom Install ISO
.PHONY: iso
iso:
	nix build .#packages.x86_64-linux.iso

# Build Custom kexec image
.PHONY: kexec-img
kexec-img:
	nix build .#packages.x86_64-linux.kexec

# Deploy a host by name (ex: 's0') but don't activate
.PHONY: deploy
deploy:
	deploy --remote-build --boot --debug-logs --skip-checks .#$(filter-out $@,$(MAKECMDGOALS))

# Deploy a host by name (ex: 's0')
.PHONY: deploy-activate
deploy-activate:
	deploy --remote-build --debug-logs --skip-checks .#$(filter-out $@,$(MAKECMDGOALS))