make: Run native commands directly or using nix-shell
instead of nix run
Signed-off-by: Christoph Heiss <christoph@c8h4.io>
This commit is contained in:
parent
40971c6a27
commit
b8f36f8dcc
|
@ -1,13 +1,16 @@
|
|||
---
|
||||
image: nixos/unstable
|
||||
packages:
|
||||
- nixos.deadnix
|
||||
- nixos.gnumake
|
||||
- nixos.nixfmt
|
||||
- nixos.statix
|
||||
- nixos.stylua
|
||||
sources:
|
||||
- https://git.sr.ht/~c8h4/nixos-config
|
||||
tasks:
|
||||
- setup: |
|
||||
mkdir -p .config/nix
|
||||
echo 'experimental-features = flakes nix-command' >.config/nix/nix.conf
|
||||
# Replace encrypted files such that the linting step won't choke on it
|
||||
for f in $(find nixos-config/secrets -type f -name '*.nix'); do echo '{ }' > $f; done
|
||||
- lint: |
|
||||
cd nixos-config
|
||||
|
|
40
Makefile
40
Makefile
|
@ -1,37 +1,34 @@
|
|||
export MAKEFLAGS :=
|
||||
|
||||
DEADNIX := nix run nixpkgs\#deadnix --
|
||||
MORPH := nix run nixpkgs\#morph --
|
||||
NIXFMT := nix run nixpkgs\#nixfmt --
|
||||
STATIX := nix run nixpkgs\#statix --
|
||||
STYLUA := nix run nixpkgs\#stylua --
|
||||
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: \
|
||||
'format', 'lint', 'build', 'build-all', 'deploy', 'deploy-full', 'upload-secrets', \
|
||||
'setup-git-hooks'" 2>&1
|
||||
@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:
|
||||
find . -type f -name '*.nix' -exec $(NIXFMT) {} +
|
||||
$(STYLUA) --verify .
|
||||
$(call nix-run,nixfmt,$(shell find . -type f -name '*.nix'))
|
||||
$(call nix-run,stylua,--verify .)
|
||||
|
||||
lint:
|
||||
$(DEADNIX) --fail
|
||||
$(STATIX) check
|
||||
$(STYLUA) --check .
|
||||
find . -type f -name '*.nix' -exec $(NIXFMT) --check {} +
|
||||
|
||||
build-all:
|
||||
$(MAKE) build M="{name,srht,trek}"
|
||||
|
||||
upload-secrets-all:
|
||||
$(MORPH) upload-secrets --passwd ./default.nix
|
||||
$(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'))
|
||||
|
||||
build:
|
||||
@if [ -z "$(M)" ]; then echo 'no machine specified using M=' 2>&1; exit 1; fi
|
||||
$(MORPH) build --on "$(M)" ./default.nix
|
||||
|
||||
build-all:
|
||||
$(MAKE) build M="{name,srht,trek}"
|
||||
|
||||
deploy:
|
||||
@if [ -z "$(M)" ]; then echo 'no machine specified using M=' 2>&1; exit 1; fi
|
||||
$(MORPH) deploy --passwd --on "$(M)" ./default.nix switch
|
||||
|
@ -44,6 +41,9 @@ upload-secrets:
|
|||
@if [ -z "$(M)" ]; then echo 'no machine specified using M=' 2>&1; exit 1; fi
|
||||
$(MORPH) upload-secrets --passwd --on "$(M)" ./default.nix
|
||||
|
||||
upload-secrets-all:
|
||||
$(MORPH) upload-secrets --passwd ./default.nix
|
||||
|
||||
setup-git-hooks:
|
||||
echo -e '#!/usr/bin/env sh\nexec make lint' >.git/hooks/pre-commit
|
||||
chmod +x .git/hooks/pre-commit
|
||||
|
|
Loading…
Reference in a new issue