-
Notifications
You must be signed in to change notification settings - Fork 1
/
justfile
66 lines (54 loc) · 2.02 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
usage:
@echo "Usage: make <task>"
@echo "Tasks:"
@echo " lint-check Lint analysis with statix"
@echo " lint Lint with statix"
@echo " format-check Check formatting with alejandra"
@echo " format Format with alejandra"
@echo " deadcode-check Dead code analysis with deadnix"
@echo " deadcode Remove dead code with deadnix"
@echo " fix-all Run format, deadcode, and lint"
@echo " check-all Run format-check, deadcode-check, and lint-check"
@echo " rebuild Rebuild and switch to new NixOS configuration"
@echo " rebuild-upgrade Rebuild + Upgrade and switch to new NixOS configuration"
@exit 0
fix-all: format deadcode lint
check-all: format-check deadcode-check lint-check
lint-check:
@echo "Checking anti-pattern issues with statix..."
statix check
lint:
@echo "Linting with statix..."
statix fix
format-check:
@echo "Checking formatting issues with alejandra..."
alejandra -c .
format:
@echo "Formatting with alejandra..."
alejandra .
deadcode-check:
@echo "Checking for dead codes with deadnix..."
deadnix
deadcode:
@echo "Removing dead codes with deadnix..."
deadnix -e
confirm-action:
@read -p "Are you sure you want to delete all files in /etc/nixos and replace them with the current directory's contents? (y/N) " confirm; \
case $$confirm in \
[Yy]*) ;; \
*) echo "Operation aborted by user." 1>&2; exit 1 ;; \
esac
remove-files:
@doas rm -rf /etc/nixos/* /etc/nixos/.* || { echo "Failed to remove files in /etc/nixos" 1>&2; exit 1; }
copy-files:
@doas cp -r . /etc/nixos || { echo "Failed to copy files to /etc/nixos" 1>&2; exit 1; }
rebuild:
confirm-action
remove-files
copy-files
@doas nixos-rebuild switch || { echo "Failed to rebuild NixOS" 1>&2; exit 1; }
rebuild-upgrade:
confirm-action
remove-files
copy-files
@doas nixos-rebuild switch --upgrade || { echo "Failed to rebuild NixOS with upgrade" 1>&2; exit 1; }