tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
bazel_7: improve lockfile parsing
Guillaume Maudoux
2 years ago
166e47c5
bc3cba38
+45
-27
2 changed files
expand all
collapse all
unified
split
pkgs
development
tools
build-managers
bazel
bazel_7
bazel-repository-cache.nix
default.nix
+44
-26
pkgs/development/tools/build-managers/bazel/bazel_7/bazel-repository-cache.nix
···
36
then builtins.substring 2 (-1) str
37
else str;
38
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
39
extract_source = f: acc: value:
40
-
# We take any "attributes" object that has a "sha256" field. Every value
41
-
# under "attributes" is assumed to be an object, and all the "attributes"
42
-
# with a "sha256" field are assumed to have either a "urls" or "url" field.
43
-
#
44
-
# We add them to the `acc`umulator:
45
-
#
46
-
# acc // {
47
-
# "ffad2b06ef2e09d040...fc8e33706bb01634" = fetchurl {
48
-
# name = "source";
49
-
# sha256 = "ffad2b06ef2e09d040...fc8e33706bb01634";
50
-
# urls = [
51
-
# "https://mirror.bazel.build/github.com/golang/library.zip",
52
-
# "https://github.com/golang/library.zip"
53
-
# ];
54
-
# };
55
-
# }
56
let
57
attrs = value.attributes;
58
entry = hash: urls: name: {
···
65
passthru.urls = urls;
66
};
67
};
68
-
insert = acc: hash: urls: name:
69
-
acc // entry (sanitize hash) (map sanitize urls) (sanitize name);
70
-
accWithRemotePatches = lib.foldlAttrs
71
-
(acc: url: hash: insert acc hash [ url ] attrs.name)
0
0
0
0
0
0
0
0
0
0
0
0
72
acc
73
(attrs.remote_patches or { });
74
-
accWithNewSource = insert
75
-
accWithRemotePatches
76
-
(attrs.integrity or attrs.sha256)
77
-
(attrs.urls or [ attrs.url ])
78
-
attrs.name;
0
79
in
80
if builtins.isAttrs value && value ? attributes
0
81
&& (attrs ? sha256 || attrs ? integrity)
0
82
&& f attrs.name
83
-
then accWithNewSource
84
else acc;
85
86
requiredSourcePredicate = n: requiredDepNamePredicate (sanitize n);
···
36
then builtins.substring 2 (-1) str
37
else str;
38
39
+
# We take any "attributes" object that has a "sha256" field. Every value
40
+
# under "attributes" is assumed to be an object, and all the "attributes"
41
+
# with a "sha256" field are assumed to have either a "urls" or "url" field.
42
+
#
43
+
# We add them to the `acc`umulator:
44
+
#
45
+
# acc // {
46
+
# "ffad2b06ef2e09d040...fc8e33706bb01634" = fetchurl {
47
+
# name = "source";
48
+
# sha256 = "ffad2b06ef2e09d040...fc8e33706bb01634";
49
+
# urls = [
50
+
# "https://mirror.bazel.build/github.com/golang/library.zip",
51
+
# "https://github.com/golang/library.zip"
52
+
# ];
53
+
# };
54
+
# }
55
+
#
56
+
# !REMINDER! This works on a best-effort basis, so try to keep it from
57
+
# failing loudly. Prefer warning traces.
58
extract_source = f: acc: value:
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
59
let
60
attrs = value.attributes;
61
entry = hash: urls: name: {
···
68
passthru.urls = urls;
69
};
70
};
71
+
insert = acc: hash: urls:
72
+
let
73
+
validUrls = builtins.isList urls
74
+
&& builtins.all (url: builtins.isString url && builtins.substring 0 4 url == "http") urls;
75
+
validName = builtins.isString attrs.name;
76
+
validHash = builtins.isString hash;
77
+
valid = validUrls && validName && validHash;
78
+
in
79
+
if valid then acc // entry hash urls attrs.name
80
+
else acc;
81
+
withToplevelValue = acc: insert acc
82
+
(attrs.integrity or attrs.sha256)
83
+
(attrs.urls or [ attrs.url ]);
84
+
# for http_file patches
85
+
withRemotePatches = acc: lib.foldlAttrs
86
+
(acc: url: hash: insert acc hash [ url ])
87
acc
88
(attrs.remote_patches or { });
89
+
# for _distdir_tar
90
+
withArchives = acc: lib.foldl'
91
+
(acc: archive: insert acc attrs.sha256.${archive} attrs.urls.${archive})
92
+
acc
93
+
(attrs.archives or [ ]);
94
+
addSources = acc: withToplevelValue (withRemotePatches (withArchives acc));
95
in
96
if builtins.isAttrs value && value ? attributes
97
+
&& builtins.isAttrs attrs && attrs ? name
98
&& (attrs ? sha256 || attrs ? integrity)
99
+
&& (attrs ? urls || attrs ? url)
100
&& f attrs.name
101
+
then addSources acc
102
else acc;
103
104
requiredSourcePredicate = n: requiredDepNamePredicate (sanitize n);
+1
-1
pkgs/development/tools/build-managers/bazel/bazel_7/default.nix
···
579
};
580
581
# For ease of debugging
582
-
inherit distDir repoCache;
583
};
584
}
···
579
};
580
581
# For ease of debugging
582
+
inherit distDir repoCache lockfile;
583
};
584
}