65 lines
2 KiB
Makefile
65 lines
2 KiB
Makefile
export MAKEFLAGS :=
|
|
|
|
HOST ?= $(shell hostname)
|
|
HOME_MANAGER_FLAGS ?=
|
|
|
|
define nix-run
|
|
@echo "$(1) $(2)"
|
|
@if hash $(1) 2>/dev/null; then $(1) $(2); else nix-shell -p $(1) --run "$(1) $(2)"; fi
|
|
endef
|
|
|
|
all:
|
|
@echo 'no default action, available actions:'
|
|
@for n in format lint build build-all deploy deploy-full upload-secrets \
|
|
upload-secrets-all setup-git-hooks; do echo " - $$n"; done
|
|
@echo
|
|
@exit 1
|
|
|
|
format:
|
|
$(call nix-run,nixfmt,$(shell find . -type f -name '*.nix'))
|
|
$(call nix-run,stylua,--verify .)
|
|
|
|
lint:
|
|
$(call nix-run,deadnix,--fail)
|
|
$(call nix-run,statix,check)
|
|
$(call nix-run,stylua,--check .)
|
|
$(call nix-run,nixfmt,--check $(shell find . -type f -name '*.nix'))
|
|
$(call nix-run,shellcheck,--shell bash extra/bin/*.sh)
|
|
|
|
build:
|
|
@if [ -z "$(M)" ]; then echo 'no machine specified using M=' 2>&1; exit 1; fi
|
|
$(call nix-run,morph,build --on '$(M)' ./default.nix)
|
|
|
|
build-all:
|
|
$(MAKE) build M="{name,serv,trek}"
|
|
|
|
deploy:
|
|
@if [ -z "$(M)" ]; then echo 'no machine specified using M=' 2>&1; exit 1; fi
|
|
$(call nix-run,morph,deploy --passwd --on '$(M)' ./default.nix switch)
|
|
|
|
deploy-full:
|
|
@if [ -z "$(M)" ]; then echo 'no machine specified using M=' 2>&1; exit 1; fi
|
|
$(call nix-run,morph,deploy --passwd --upload-secrets --on '$(M)' ./default.nix switch)
|
|
|
|
upload-secrets:
|
|
@if [ -z "$(M)" ]; then echo 'no machine specified using M=' 2>&1; exit 1; fi
|
|
$(call nix-run,morph,upload-secrets --passwd --on '$(M)' ./default.nix)
|
|
|
|
upload-secrets-all:
|
|
$(call nix-run,morph,upload-secrets --passwd ./default.nix)
|
|
|
|
deploy-standalone:
|
|
@if [ ! -f ./system/home-manager/standalone/$(HOST).nix ]; then \
|
|
echo 'no standalone configuration for this machine available: $(HOST)' 2>&1; \
|
|
exit 1; \
|
|
fi
|
|
$(call nix-run,home-manager,\
|
|
-f ./system/home-manager/standalone/$(HOST).nix $(HOME_MANAGER_FLAGS) switch)
|
|
|
|
setup-git-hooks:
|
|
echo -e '#!/usr/bin/env sh\nexec make lint' >.git/hooks/pre-commit
|
|
chmod +x .git/hooks/pre-commit
|
|
|
|
empty-out-secrets:
|
|
for f in $$(find secrets -type f -name '*.nix'); do echo '{ }' > $$f; done
|