-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjustfile
159 lines (126 loc) · 3.66 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
#! /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
[private]
[script]
default:
while true; do
if ! just --choose --unsorted; then
echo $?
echo "Exiting..."
exit 0
fi
done
[macos]
switch *args:
darwin-rebuild switch --flake {{ source_dir() }} {{ args }}
[linux]
switch *args:
nixos-rebuild switch --flake {{ source_dir() }} {{ args }}
[macos]
rebuild *args:
darwin-rebuild {{ args }}
[linux]
rebuild *args:
nixos-rebuild {{ args }}
# update flake inputs
update *inputs:
nix flake update {{ inputs }}
repl dir='.' file='repl.nix' args="":
nix repl --verbose --trace-verbose --file {{ dir }}/{{ file }} {{ args }}
[private]
link-flake:
just link-system-flake
just link flake.nix ~/.config/home-manager/flake.nix
[macos]
[private]
link-system-flake:
just link flake.nix /etc/nix-darwin/flake.nix
[linux]
[private]
link-system-flake:
just link flake.nix /etc/nixos/flake.nix
[macos]
[private]
bootstrap:
nix run nix-darwin -- switch --flake {{ source_dir() }}
just link-flake
run app *args:
nix run .#{{ app }} {{ args }}
@netrc:
op inject -i netrc.tpl -o ~/.netrc
check: just-check flake-check
[private]
just-check:
just --check
flake-check:
env FLAKE_CHECKER_NO_TELEMETRY=true nix run github:DeterminateSystems/flake-checker
[linux]
[macos]
fix-eol:
rg -g '!windows/*' -l -0 $'\r$' | xargs -0 dos2unix --
[private]
[script]
link path link context=source_dir():
target="{{ clean(join(context, path)) }}"
link="{{ clean(link) }}"
if [ ! -d "$(dirname "$link")" ]; then
echo "{{ BOLD }}{{ YELLOW }} skipped:{{ RESET }} {{ BLUE }}$(dirname "$link"){{ RESET }} does not exist";
elif [ "$(readlink -qe "$link")" = "$(readlink -qe "$target")" ]; then
echo "{{ BOLD }}{{ GREEN }} found:{{ RESET }} {{ BLUE }}$link{{ RESET }} -> {{ BLUE }}$target{{ RESET }}";
else
ln -s -T "$target" "$link";
echo "{{ BOLD }}{{ GREEN }} created:{{ RESET }} {{ BLUE }}$link{{ RESET }} -> {{ BLUE }}$target{{ RESET }}";
fi;
fmt: just-fmt nix-fmt
[private]
just-fmt:
just --fmt
[private]
nix-fmt:
nix fmt
shell:
@exec zsh
nix-develop *args:
nix develop --command zsh {{ args }}
nix-shell *args:
nix shell --command zsh {{ args }}
git *args:
git {{ args }}
neogit:
nvim --cmd "let g:auto_session_enabled = v:false" +Neogit
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 }}
[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{{ RESET }}"
exec just $args
help:
@just --list --unsorted
BOLD := "$(tput bold)"
RESET := "$(tput sgr0)"
BLACK := "$(tput bold)$(tput setaf 0)"
RED := "$(tput bold)$(tput setaf 1)"
GREEN := "$(tput bold)$(tput setaf 2)"
YELLOW := "$(tput bold)$(tput setaf 3)"
BLUE := "$(tput bold)$(tput setaf 4)"
MAGENTA := "$(tput bold)$(tput setaf 5)"
CYAN := "$(tput bold)$(tput setaf 6)"
WHITE := "$(tput bold)$(tput setaf 7)"
BLACKB := "$(tput bold)$(tput setab 0)"
REDB := "$(tput setab 1)$(tput setaf 0)"
GREENB := "$(tput setab 2)$(tput setaf 0)"
YELLOWB := "$(tput setab 3)$(tput setaf 0)"
BLUEB := "$(tput setab 4)$(tput setaf 0)"
MAGENTAB := "$(tput setab 5)$(tput setaf 0)"
CYANB := "$(tput setab 6)$(tput setaf 0)"
WHITEB := "$(tput setab 7)$(tput setaf 0)"