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