-
Notifications
You must be signed in to change notification settings - Fork 3
/
justfile
101 lines (82 loc) · 2.62 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
#! /usr/bin/env nix
#! nix shell nixpkgs#just nixpkgs#gum --command just --justfile
# mod nixos
# mod windows
# mod firewalla
default: help
help:
@just --list --unsorted
@link-flake:
just link-system-flake
just link flake.nix ~/.config/home-manager/flake.nix
[macos]
@link-system-flake:
just link flake.nix /etc/nix-darwin/flake.nix
[linux]
@link-system-flake:
just link flake.nix /etc/nixos/flake.nix
[macos]
bootstrap:
nix run nix-darwin -- switch --flake {{ source_dir() }}
just link-flake
[macos]
rebuild *args:
darwin-rebuild {{ args }}
[linux]
rebuild *args:
nixos-rebuild {{ args }}
[macos]
switch *args:
darwin-rebuild switch --flake {{ source_dir() }} {{ args }}
[linux]
switch *args:
nixos-rebuild switch --flake {{ source_dir() }} {{ 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 }}
run app *args:
nix run .#{{ app }} {{ args }}
netrc:
op inject -i netrc.tpl -o ~/.netrc
flake-checker:
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]
@link path link context=source_dir():
#!/usr/bin/env bash
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:
nix fmt
just --fmt --unstable
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)"