-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJustfile
86 lines (63 loc) · 2.47 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
# SPDX-FileCopyrightText: 2022-2023 Chris Montgomery <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later
###: https://just.systems/man/en/
prj-root := env_var('PRJ_ROOT')
cache-dir := env_var('PRJ_CACHE_HOME')
upstream-src-path := env_var('BASE16_SCHEMES_PATH')
out-dir := prj-root / "src"
json-dir := cache-dir / "json"
repo-copyright := 'Chris Montgomery <[email protected]>'
repo-license := 'GPL-3.0-or-later'
docs-license := 'CC-BY-SA-4.0'
upstream-license := 'MIT'
###: GENERAL =================================================================
default:
@just --list --unsorted --color=always | rg -v "\s*default"
fmt:
treefmt src/*.nix
###: WORKFLOW =================================================================
generate: prepare && license fmt
fd --type file --extension yaml . {{ upstream-src-path }} --exec \
just yaml-to-json
fd --type file --extension json . {{ json-dir }} --exec \
just json-to-nix
yaml-to-json file:
yaml2json < {{ file }} > {{ cache-dir }}/json/{{ file_stem( file ) }}.json
json-to-nix file:
nix eval --expr 'builtins.fromJSON (builtins.readFile {{file}})' --impure \
> {{ out-dir / file_stem( file ) }}.nix
prepare:
mkdir -p {{ json-dir }} {{ out-dir }}
clean: prepare
rm -rf {{ json-dir }} {{ out-dir }}
###: LICENSING =================================================================
license-template := "--template compact"
# <- Update license annotations
license: (license-upstream "src") && fmt license-check
# <- Validate the project's licensing and copyright info
license-check:
reuse lint
# <- Annotate the specified files with the default code license
license-repo +FILES:
reuse annotate --recursive {{ license-template }} \
--license '{{ repo-license }}' \
--copyright '{{ repo-copyright }}' \
{{ FILES }}
# <- Annotate the specified files with the upstream license
license-upstream +FILES:
reuse annotate --recursive {{ license-template }} \
--license '{{ upstream-license }}' \
--copyright 'Chris Kempson and contributors' \
--year '2012-2022' \
{{ FILES }}
reuse annotate --recursive {{ license-template }} \
--license '{{ upstream-license }}' \
--copyright 'Tinted Theming (https://github.com/tinted-theming)' \
--year '2022' \
{{ FILES }}
# <- Annotate the specified files with the default docs license
license-docs +FILES:
reuse annotate --recursive {{ license-template }} \
--license '{{ docs-license }}' \
--copyright '{{ repo-copyright }}' \
{{ FILES }}