@@ -27,48 +27,94 @@ writeShellApplication {
27
27
cat <<'EOF'
28
28
# generated by zon2nix (https://github.com/Cloudef/zig2nix)
29
29
30
- { lib, linkFarm, fetchurl, fetchgit, runCommandLocal, zig, name ? "zig-packages" }:
30
+ {
31
+ lib,
32
+ linkFarm,
33
+ fetchurl,
34
+ fetchgit,
35
+ runCommandLocal,
36
+ zig,
37
+ name ? "zig-packages",
38
+ }:
31
39
32
40
with builtins;
33
41
with lib;
34
42
35
43
let
36
- unpackZigArtifact = { name, artifact }: runCommandLocal name {
37
- nativeBuildInputs = [ zig ];
38
- } ${ "''" }
39
- hash="$(zig fetch --global-cache-dir "$TMPDIR" '' ${artifact})"
40
- mv "$TMPDIR/p/$hash" "$out"
41
- chmod 755 "$out"
42
- ${ "''" } ;
44
+ unpackZigArtifact =
45
+ { name, artifact }:
46
+ runCommandLocal name
47
+ {
48
+ nativeBuildInputs = [ zig ];
49
+ }
50
+ ${ "''" }
51
+ hash="$(zig fetch --global-cache-dir "$TMPDIR" '' ${artifact})"
52
+ mv "$TMPDIR/p/$hash" "$out"
53
+ chmod 755 "$out"
54
+ ${ "''" } ;
43
55
44
- fetchZig = { name, url, hash }: let
45
- artifact = fetchurl { inherit url hash; };
46
- in unpackZigArtifact { inherit name artifact; };
56
+ fetchZig =
57
+ {
58
+ name,
59
+ url,
60
+ hash,
61
+ }:
62
+ let
63
+ artifact = fetchurl { inherit url hash; };
64
+ in
65
+ unpackZigArtifact { inherit name artifact; };
47
66
48
- fetchGitZig = { name, url, hash }: let
49
- parts = splitString "#" url;
50
- url_base = elemAt parts 0;
51
- url_without_query = elemAt (splitString "?" url_base) 0;
52
- rev_base = elemAt parts 1;
53
- rev = if match "^[a-fA-F0-9]{40}$" rev_base != null then rev_base else "refs/heads/'' ${rev_base}";
54
- in fetchgit {
55
- inherit name rev hash;
56
- url = url_without_query;
57
- deepClone = false;
58
- };
59
-
60
- fetchZigArtifact = { name, url, hash }: let
61
- parts = splitString "://" url;
62
- proto = elemAt parts 0;
63
- path = elemAt parts 1;
64
- fetcher = {
65
- "git+http" = fetchGitZig { inherit name hash; url = "http://'' ${path}"; };
66
- "git+https" = fetchGitZig { inherit name hash; url = "https://'' ${path}"; };
67
- http = fetchZig { inherit name hash; url = "http://'' ${path}"; };
68
- https = fetchZig { inherit name hash; url = "https://'' ${path}"; };
67
+ fetchGitZig =
68
+ {
69
+ name,
70
+ url,
71
+ hash,
72
+ }:
73
+ let
74
+ parts = splitString "#" url;
75
+ url_base = elemAt parts 0;
76
+ url_without_query = elemAt (splitString "?" url_base) 0;
77
+ rev_base = elemAt parts 1;
78
+ rev = if match "^[a-fA-F0-9]{40}$" rev_base != null then rev_base else "refs/heads/'' ${rev_base}";
79
+ in
80
+ fetchgit {
81
+ inherit name rev hash;
82
+ url = url_without_query;
83
+ deepClone = false;
69
84
};
70
- in fetcher.'' ${proto};
71
- in linkFarm name [
85
+
86
+ fetchZigArtifact =
87
+ {
88
+ name,
89
+ url,
90
+ hash,
91
+ }:
92
+ let
93
+ parts = splitString "://" url;
94
+ proto = elemAt parts 0;
95
+ path = elemAt parts 1;
96
+ fetcher = {
97
+ "git+http" = fetchGitZig {
98
+ inherit name hash;
99
+ url = "http://'' ${path}";
100
+ };
101
+ "git+https" = fetchGitZig {
102
+ inherit name hash;
103
+ url = "https://'' ${path}";
104
+ };
105
+ http = fetchZig {
106
+ inherit name hash;
107
+ url = "http://'' ${path}";
108
+ };
109
+ https = fetchZig {
110
+ inherit name hash;
111
+ url = "https://'' ${path}";
112
+ };
113
+ };
114
+ in
115
+ fetcher.'' ${proto};
116
+ in
117
+ linkFarm name [
72
118
EOF
73
119
74
120
while {
@@ -88,6 +134,6 @@ writeShellApplication {
88
134
}
89
135
EOF
90
136
done < <(jq -r 'to_entries | .[] | .key, .value.name, .value.url, .value.hash' "$path")
91
- printf ']'
137
+ printf ']\n '
92
138
'' ;
93
139
}
0 commit comments