-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path.justfile
More file actions
155 lines (119 loc) · 4.79 KB
/
.justfile
File metadata and controls
155 lines (119 loc) · 4.79 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
155
# SPDX-FileCopyrightText: 2022-2023 Chris Montgomery <chmont@proton.me>
# SPDX-License-Identifier: GPL-3.0-or-later
###: https://just.systems/man/en/
mod nixify ".just/nixify.mod.just"
mod secrets
default:
@just --choose
##: legal/reuse
copyright := 'Chris Montgomery <chmont@proton.me>'
default-license := 'GPL-3.0-or-later'
docs-license := 'CC-BY-SA-4.0'
public-domain-license := 'CC0-1.0'
##: binary cache
cachix-cache-name := 'dotfield'
cachix-jobs := '4'
cachix-exec := "cachix watch-exec " + cachix-cache-name + " --jobs " + cachix-jobs
##: directories/paths
prj-root := env_var('PRJ_ROOT')
prj-data := env_var('PRJ_DATA_HOME')
user-configs-dir := justfile_directory() / "src/users" / env("USER") / "config"
ironbar-dir := user-configs-dir / "ironbar/dot-config/ironbar"
push *ARGS="-b main":
for remote in origin github; do \
jj git push {{ ARGS }} --remote $remote; \
done
stow scope:
cd {{ user-configs-dir }} && stow -R {{ scope }}
stow-all *FLAGS:
cd {{ user-configs-dir }} \
&& fd --type d --max-depth 1 --exec-batch \
stow -R {{ FLAGS }} '{.}'
# <- Rebuild the system and provide a summary of the changes
build *ARGS='':
{{cachix-exec}} nh -- os build "{{prj-root}}" {{ARGS}}
# <- Build the system for activation next boot
boot *ARGS='':
{{cachix-exec}} nh -- os boot "{{prj-root}}" {{ARGS}}
# <- Rebuild the system and switch to the next generation
switch *ARGS='':
{{cachix-exec}} nh -- os switch "{{prj-root}}" {{ARGS}}
home args:
{{cachix-exec}} nh -- home {{prj-root}} {{args}}
home-specialise name:
nh home switch {{prj-root}} -s {{name}}
# <- Run flake checks
check *ARGS:
nix flake check --verbose {{ ARGS }}
# <- Inspect flake outputs
inspect:
nix-inspect
[doc: "Lint the project files"]
lint:
pre-commit run -a
[doc: "Write linter fixes to project files"]
fix: (_deadnix "--edit")
statix fix
[doc: "Format the project files"]
fmt *FILES:
treefmt {{ FILES }}
_deadnix method='--fail' *ARGS='--no-underscore':
fd -t f -e nix --exclude='packages/**/*.nix' --exec-batch \
deadnix {{method}} {{ARGS}}
fd -t f -e nix . packages --exec-batch \
deadnix {{method}} --no-lambda-pattern-names {{ARGS}}
# <- Generate a Nix package expression from a URL
init-package pname url:
nix-init --url {{url}} packages/{{pname}}/package.nix
@echo "Add this to packages/default.nix:"
@echo '{{pname}} = callPackage ./{{pname}}/package.nix { };'
[doc: "Replace a symlink to a Nix store file with a writeable copy of the file contents"]
@derealise-symlink symlink:
if [[ ! -L "{{ symlink }}" ]]; then >&2 echo "Not a symlink: {{ symlink }}"; exit; fi
if [[ ! -d "{{ symlink }}" ]]; then \
cp --backup --suffix ".realised.bak" --copy-contents --verbose --remove-destination \
"$(readlink "{{ symlink }}")" "{{ symlink }}"; \
chmod --changes 644 "{{ symlink }}"; \
fi
[doc: "Restore the original Nix store link backed up during derealisation"]
@realise-symlink derealised:
if [[ ! -L "{{ derealised }}.realised.bak" ]]; then >&2 echo "Realisation not found: {{ derealised }}.realised.bak"; exit; fi
mv --backup --suffix ".derealised.bak" --verbose "{{ derealised }}.realised.bak" "{{ derealised }}"
ironbar-dev:
watchexec -w {{ ironbar-dir }} -- 'systemctl --user restart ironbar'
###: THEME =====================================================================
emacs-eval-cmd := "emacsclient --no-wait --eval"
kitty-set-colors-cmd := "kitty @set-colors -a -c"
gtk-ui-schema := "org.gnome.desktop.interface"
# <- Set the theme for all applications
# NOTE: Existing Ghostty windows require manual reload (Ctrl+Shift+,)
[linux]
theme kind='dark': && (wm-set-theme kind)
nh home switch 'path:{{ prj-root }}' -c '{{ env("USER") }}@{{ `hostname` }}' -s {{ kind }}
{{ emacs-eval-cmd }} '(ceamx-ui/{{ kind }})'
# <- Use the 'light' theme for all applications
light: (theme "light")
# <- Use the 'dark' theme for all applications
dark: (theme "dark")
[private]
[linux]
gtk-theme command='get' kind='':
gsettings {{ command }} {{ gtk-ui-schema }} color-scheme \
{{ if command == 'set' { "prefer-" + kind } else { '' } }}
# <- Switch the current GTK theme kind [default: dark]
[private]
[linux]
wm-set-theme kind="dark": (gtk-theme "set" kind)
###: LICENSING =================================================================
# <- Validate the project's licensing and copyright info
license-check:
reuse lint
# <- Add a GPL-3.0-or-later license header to the specified files
license-gpl +FILES:
reuse annotate -l {{default-license}} -c '{{copyright}}' {{FILES}}
# <- Add a CC-BY-SA-4.0 license header to the specified files
license-cc +FILES:
reuse annotate -l {{docs-license}} -c '{{copyright}}' {{FILES}}
# <- Add a public domain CC0-1.0 license header to the specified files
license-public-domain +FILES:
reuse annotate -l {{public-domain-license}} -c '{{copyright}}' {{FILES}}