-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjustfile
188 lines (151 loc) · 4 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
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#! /usr/bin/env nix
import? 'justfile.local'
#! nix shell nixpkgs#just nixpkgs#gum --command just --justfile
# mod nixos
# mod windows
# mod firewalla
set shell := ["bash", "-e", "-u", "-o", "pipefail", "-c"]
set unstable := true
export XDG_CONFIG_HOME := env('XDG_CONFIG_HOME', home_dir() / ".config")
export FLAKE_CHECKER_NO_TELEMETRY := 'true'
[private]
[script]
default:
while true; do
if ! just --choose --unsorted; then
echo $?
echo "Exiting..."
exit 0
fi
done
# Install and activate system flake
[group('nix')]
[macos]
[private]
bootstrap:
nix run nix-darwin -- switch --flake {{ source_dir() }}
just link-flake
# Build and activate system flake
[group('nix')]
[macos]
switch *args:
darwin-rebuild switch --flake {{ source_dir() }} {{ args }}
# Build and activate system flake
[group('nix')]
[linux]
switch *args:
nixos-rebuild switch --flake {{ source_dir() }} {{ args }}
# Build system flake
[group('nix')]
[macos]
rebuild *args:
darwin-rebuild {{ args }}
# Build system flake
[group('nix')]
[linux]
rebuild *args:
nixos-rebuild {{ args }}
[group('nix')]
[macos]
check:
darwin-rebuild check
# Update flake inputs
[group('nix')]
update *inputs:
nix flake update --commit-lock-file {{ inputs }}
[group('nix')]
repl dir=source_dir() file='repl.nix' args="":
nix repl --verbose --trace-verbose --file {{ dir }}/{{ file }} {{ args }}
# Run a nix application
[group('nix')]
[no-cd]
run *args:
nix run {{ args }}
# Runs an application from nixpkgs
[group('nix')]
[no-cd]
pkg name *args:
nix run nixpkgs#{{ name }} -- {{ args }}
# Froms an application from flake output attribute `apps.<system>.<name>`
[group('nix')]
[no-cd]
app name *args:
nix run {{ source_dir() }}#{{ name }} -- {{ args }}
# creates symlink to flake.nix
[group('nix')]
[private]
link-flake: link-system-flake
just link flake.nix "$XDG_CONFIG_HOME/home-manager/flake.nix"
# creates symlink to flake.nix in /etc/nix-darwin
[group('nix')]
[macos]
[private]
link-system-flake:
just link flake.nix /etc/nix-darwin/flake.nix
[group('nix')]
[linux]
[private]
link-system-flake:
just link flake.nix /etc/nixos/flake.nix
[group('nix')]
[private]
nix-fmt:
nix fmt
[group('nix')]
flake-checker:
env nix run github:DeterminateSystems/flake-checker
lint:
just --fmt --check
[private]
link-global-justfile:
@just link justfile "$XDG_CONFIG_HOME/just/justfile"
[private]
[script]
link path link context=source_dir():
target="{{ clean(join(context, path)) }}"
link="{{ clean(link) }}"
if [ "$(readlink -qe "$link")" = "$(readlink -qe "$target")" ]; then
echo -e "{{ BOLD }}{{ BLUE }}exists:{{ NORMAL }} {{ CYAN }}$target{{ NORMAL }} <-- {{ BLUE }}$link{{ NORMAL }}";
else
echo -e "{{ BOLD }}{{ GREEN }}create:{{ NORMAL }} {{ CYAN }}$target{{ NORMAL }} <-- {{ GREEN }}$link{{ NORMAL }}";
mkdir -p "$(dirname "$link")";
ln -s -i -T "$target" "$link";
fi;
[linux]
[macos]
[private]
fix-eol:
rg -g '!windows/*' -l -0 $'\r$' | xargs -0 dos2unix --
fmt: just-fmt nix-fmt
[private]
just-fmt:
just --fmt
shell:
@exec zsh
[group('nix')]
nix-develop *args:
nix develop --command zsh {{ args }}
[group('nix')]
nix-shell *args:
nix shell --command zsh {{ args }}
git *args:
git {{ args }}
neogit:
nvim --cmd "let g:auto_session_enabled = v:false" +Neogit
@netrc:
op inject -i netrc.tpl -o ~/.netrc
clickhouse-client-config output=(home_dir() / ".clickhouse-client" / "config.xml"):
@mkdir -p {{ parent_dir(output) }}
op inject -i config/clickhouse-client/config.xml -o {{ output }}
clickhouse-connection connection *args:
wezterm cli set-tab-title "clickhouse://{{ connection }}"
clickhouse client --connection {{ connection }} {{ args }}
[script]
just *args:
if ! args=$(gum input --prompt="just " --value="{{ args }}" --placeholder="" --header="$(just --list)\n\n"); then
exit $?
fi
echo -e "{{ BOLD }}just $args{{ NORMAL }}"
exec just $args
help:
@just --list --unsorted