MAKEFLAGS += --warn-undefined-variables SHELL := $(shell which bash) .EXPORT_ALL_VARIABLES: .ONESHELL: .SHELLFLAGS := -eu -o pipefail -c .SILENT: .PHONY: add-pre-commit-hook add-pre-commit-hook: printf '#!/bin/sh\nmake test\n' > .git/hooks/pre-commit chmod +x .git/hooks/pre-commit # # uses etc # .PHONY: sync-etc sync-etc: sudo rsync -a --exclude='hardware-configuration.nix' nixos/ /etc/nixos/ sudo nixos-rebuild switch --flake /etc/nixos#cesium sudo cp /etc/nixos/flake.lock nixos/flake.lock 2>/dev/null || true .PHONY: upgrade-etc upgrade-etc: sudo nix flake update --flake /etc/nixos --commit-lock-file sudo nixos-rebuild switch --flake /etc/nixos#cesium sudo cp /etc/nixos/flake.lock nixos/flake.lock 2>/dev/null || true .PHONY: sync-etc-dry-run sync-etc-dry-run: sudo rsync -a --dry-run --verbose --exclude='hardware-configuration.nix' nixos/ /etc/nixos/ # # uses ./nixos # .PHONY: rebuild rebuild: sudo nixos-rebuild switch --flake path:$(CURDIR)/nixos .PHONY: upgrade upgrade: sudo nix flake update --flake $(CURDIR)/nixos --commit-lock-file sudo nixos-rebuild switch --flake path:$(CURDIR)/nixos # # for both # .PHONY: cleanup cleanup: sudo nix-store --optimise && sudo nix-collect-garbage -d .PHONY: test test: echo "Find nix files" find nixos -name "*.nix" | while read f; do echo "Checking $$f" nix-instantiate --parse "$$f" > /dev/null done echo "All files OK" .DEFAULT_GOAL := test