-
Notifications
You must be signed in to change notification settings - Fork 128
Expand file tree
/
Copy pathfetch-refs.nix
More file actions
52 lines (48 loc) · 1.5 KB
/
fetch-refs.nix
File metadata and controls
52 lines (48 loc) · 1.5 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
with builtins;
let
fetch =
repo:
foldl' (x: f: f x) "https://api.github.com/repos/${repo}/git/refs/tags" [
fetchurl
readFile
fromJSON
(map (
y:
if y.object.type == "tag" then
# on basically all releases, the ref points to a tag
# this is neat, because it wraps the commit hash in a `tag` name.
foldl' (x: f: f x) y.object.url [
fetchurl
readFile
fromJSON
]
else
let
startsWith = prefix: string: substring 0 (stringLength prefix) string == prefix;
removePrefix =
prefix: string:
assert startsWith prefix string;
substring (stringLength prefix) (stringLength string) string;
in
# but on some releases, the ref directly points to the commit
# then we have to manually extract the ""tag"" name (not a real tag; but to humans there is no difference)
y // { tag = removePrefix "refs/tags/" y.ref; }
))
(filter (x: x.object.type == "commit"))
(map (x: ''"${x.object.sha}" = "${x.tag}";''))
(concatStringsSep "\n ")
];
in
''
# This file is generated automatically by fetch-refs.nix
# Do not edit it manually, your changes will be lost.
#
# Both niri and xwayland-satellite are listed.
# This is because commit hashes are globally unique.
{
# niri
${fetch "YaLTeR/niri"}
# xwayland-satellite
${fetch "Supreeeme/xwayland-satellite"}
}
''