-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
154 lines (113 loc) · 3.63 KB
/
justfile
File metadata and controls
154 lines (113 loc) · 3.63 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# justfile
# cheatsheet: https://cheatography.com/linux-china/cheat-sheets/justfile/
# ===== Settings ===== #
# define alias
alias b := rebuild
alias e := eval
# set options
set positional-arguments := true
set dotenv-load := true
# assign default value to vars
profile := "$PROFILE"
# default recipe to display help information
default:
@just --list
# ===== Nix ===== #
# rebuild nixos
rebuild host=profile:
@sudo nixos-rebuild switch --upgrade --flake .#{{ host }}
# build nixos (debug mode)
rebuild-debug host=profile:
@nom build .#nixosConfigurations.{{ host }}.config.system.build.toplevel --show-trace --verbose
# update all flake inputs
up:
@nix flake update
# update a particular flake input
upp input:
@nix flake lock --update-input {{ input }}
# update a particular flake input with fzf
upx:
@nix flake metadata --json | nix run nixpkgs#jq '.locks.nodes.root.inputs[]' | sed 's/\"//g' | nix run nixpkgs#fzf | xargs nix flake lock --update-input
# show flake outputs
show:
@nix flake show
# check flake
check:
@nix flake check
# locate pkg
locate pkg:
@nix eval nixpkgs#{{ pkg }}.outPath
# build nix pkg
build pkg:
@nom build .#{{ pkg }}
# eval and build nixosConfiguration for currentSystem
fast-build:
@nix run .#nix-fast-build -- --flake ".#checks.$(nix eval --raw --impure --expr builtins.currentSystem)"
# eval and build nixosConfiguration for all profiles
fast-build-all:
@nix run .#nix-fast-build
# eval
eval host=profile:
@nix build .#nixosConfigurations.{{ host }}.config.system.build.toplevel --print-out-paths
# run nix pkg
run pkg:
@nix run .#{{ pkg }}
# view flake.lock
lock:
@nix-melt
# nix-prefetch-url
prefetch-url url:
@nix-prefetch-url --type sha256 '{{ url }}' | xargs nix hash to-sri --type sha256
# nix-prefetch-git
prefetch-git repo rev:
@nix-prefetch-git --url 'git@github.com:{{ repo }}' --rev '{{ rev }}' --fetch-submodules
# activate nix-repl
repl:
@nix repl -f flake:nixpkgs
# search dependencies in nixpkgs
search-deps pkg:
@nix why-depends /run/current-system $(nix-build '<nixpkgs>' -A {{ pkg }})
# garbage collect all unused nix store entries older than x days
gc days:
@sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than {{ days }}d
@sudo nix-collect-garbage --delete-older-than {{ days }}d
# garbage collect all unused nix store entries
gc-all:
@sudo nix store gc --debug
@sudo nix-collect-garbage --delete-old
# apply fix from linters
lint:
@statix fix --ignore 'templates/' .
@deadnix --edit --exclude 'templates/' .
# ===== Remote deploy ===== #
# remote deploy with colmena
deploy host:
@colmena apply --verbose --on {{ host }} --show-trace
# remote deploy servers with @tags with colmena
deploy-with-tags tags:
@colmena apply --verbose --on @{{ tags }} --show-trace
# ===== Misc ===== #
# count total number of nix-related files
count:
@rg '' --glob "!.git" --glob "!home-estate" --glob "!secrets" --files-with-matches | wc -l
# ===== Git ===== #
# stage all files
add:
@git add .
# git pull
pull:
@git pull --rebase
sync-mirror-remote:
@git push -u mirror
@git push -u mirror --tags
@git branch --set-upstream-to=origin/master master
# ===== Tests ===== #
# clean local dot configs
dot-clean config:
@rm -rf ${HOME}/.config/{{ config }}
# rsync dot configs from dot-nvim
dot-test config: (dot-clean config)
@rsync -avz --copy-links --chmod=D2755,F744 $HOME/Workspace/personal/dot-submodules/dot-{{ config }}/ ${HOME}/.config/{{ config }}
# rsync dot configs from dot-{config} repo
dot-sync config:
@rsync -avz --copy-links --chmod=D2755,F744 $HOME/Workspace/personal/dot-submodules/dot-{{ config }}/ ${HOME}/.config/{{ config }}