-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.zig.zon.nix
More file actions
123 lines (120 loc) · 2.87 KB
/
Copy pathbuild.zig.zon.nix
File metadata and controls
123 lines (120 loc) · 2.87 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
# generated by zon2nix (https://github.com/jcollie/zon2nix)
{
lib,
linkFarm,
fetchzip,
fetchurl,
fetchgit,
runCommandLocal,
zig_0_16,
zstd,
name ? "zig-packages",
}:
let
unpackZigArtifact =
{
name,
artifact,
}:
runCommandLocal name
{
nativeBuildInputs = [ zig_0_16 ];
}
''
# workaround https://codeberg.org/ziglang/zig/issues/31866
# https://github.com/Cloudef/zig2nix/issues/54
touch "$TMPDIR/build.zig"
hash="$(cd "$TMPDIR" && zig fetch --global-cache-dir "$TMPDIR" ${artifact})"
mv "$TMPDIR/p/$hash.tar.gz" "$out"
chmod 755 "$out"
'';
fetchZig =
{
name,
url,
hash,
unpack,
}:
let
artifact =
if unpack then
fetchzip {
inherit url hash;
nativeBuildInputs = [ zstd ];
}
else
fetchurl { inherit url hash; };
in
unpackZigArtifact { inherit name artifact; };
fetchGitZig =
{
name,
url,
hash,
}:
let
parts = lib.splitString "#" url;
url_base = builtins.elemAt parts 0;
url_without_query = builtins.elemAt (lib.splitString "?" url_base) 0;
rev_base = builtins.elemAt parts 1;
rev =
if builtins.match "^[a-fA-F0-9]{40}$" rev_base != null then rev_base else "refs/heads/${rev_base}";
in
fetchgit {
inherit name rev hash;
url = url_without_query;
deepClone = false;
fetchSubmodules = false;
};
fetchZigArtifact =
{
name,
url,
hash,
unpack,
}:
let
parts = lib.splitString "://" url;
proto = builtins.elemAt parts 0;
path = builtins.elemAt parts 1;
fetcher = {
"git+http" = fetchGitZig {
inherit name hash;
url = "http://${path}";
};
"git+https" = fetchGitZig {
inherit name hash;
url = "https://${path}";
};
http = fetchZig {
inherit name hash unpack;
url = "http://${path}";
};
https = fetchZig {
inherit name hash unpack;
url = "https://${path}";
};
};
in
fetcher.${proto};
in
linkFarm name [
{
name = "gobject_codegen-0.3.1-B33qzdB-BwCJT3fq5N2TIeoLDjTCymXQfKR_aCZQhOej";
path = fetchZigArtifact {
name = "gobject_codegen";
url = "git+https://github.com/jcollie/zig-gobject#c59c96a61318a246acb80af60637e48dd96841fb";
hash = "sha256-Vm2Sy84n24azQ3MnuQ42avfS/giE4OBW6KtMj5nqwNA=";
unpack = true;
};
}
{
name = "xml-0.2.0-ZTbP3yI6AgB9Rpd2hQrueO63ib0Bm6mQiL_WB1t7JAmP";
path = fetchZigArtifact {
name = "xml";
url = "git+https://github.com/ianprime0509/zig-xml?ref=main#b97f2ab4868ae3cac9902b33a40d3f31d2df739d";
hash = "sha256-YbeAR/+CR2bhtBPexfLnruzIzkFDiS12eGU3y4Aviys=";
unpack = true;
};
}
]