From cdf254a4443e389130a370bb75d4e49096c96c13 Mon Sep 17 00:00:00 2001 From: Sebastian Fischer Date: Mon, 9 Mar 2026 19:27:47 +0100 Subject: [PATCH] [TASK] Add check before commit that nix files have valid syntax --- Makefile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9a3078f --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +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 + + +.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