tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
gclient2nix: add importGclientDeps & gclientUnpackHook
Yureka
11 months ago
0e730af4
082d26cd
+72
2 changed files
expand all
collapse all
unified
split
pkgs
by-name
gc
gclient2nix
gclient-unpack-hook.sh
package.nix
+28
pkgs/by-name/gc/gclient2nix/gclient-unpack-hook.sh
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
# shellcheck shell=bash
2
+
3
+
gclientUnpackHook() {
4
+
echo "Executing gclientUnpackHook"
5
+
6
+
runHook preUnpack
7
+
8
+
if [ -z "${gclientDeps-}" ]; then
9
+
echo "gclientDeps missing"
10
+
exit 1
11
+
fi
12
+
13
+
for dep in $(@jq@ -c "to_entries[]" "$gclientDeps")
14
+
do
15
+
local name="$(echo "$dep" | @jq@ -r .key)"
16
+
echo "copying $name..."
17
+
local path="$(echo "$dep" | @jq@ -r .value.path)"
18
+
mkdir -p $(dirname "$name")
19
+
cp -r "$path/." "$name"
20
+
chmod u+w -R "$name"
21
+
done
22
+
23
+
runHook postUnpack
24
+
}
25
+
26
+
if [ -z "${dontGclientUnpack-}" ] && [ -z "${unpackPhase-}" ]; then
27
+
unpackPhase=(gclientUnpackHook)
28
+
fi
+44
pkgs/by-name/gc/gclient2nix/package.nix
···
6
path,
7
fetchgit,
8
nurl,
0
0
0
0
9
}:
10
11
let
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
12
python = python3.withPackages (
13
ps: with ps; [
14
joblib
···
31
url = "https://chromium.googlesource.com/chromium/tools/depot_tools";
32
rev = "452fe3be37f78fbecefa1b4b0d359531bcd70d0d";
33
hash = "sha256-8IiJOm0FLa/u1Vd96tb33Ruj4IUTCeYgBpTk88znhPw=";
0
0
0
0
34
};
35
}
36
''
···
6
path,
7
fetchgit,
8
nurl,
9
+
writers,
10
+
callPackage,
11
+
fetchFromGitiles,
12
+
fetchFromGitHub,
13
}:
14
15
let
16
+
fetchers = {
17
+
inherit fetchgit fetchFromGitiles fetchFromGitHub;
18
+
};
19
+
20
+
importGclientDeps =
21
+
depsAttrsOrFile:
22
+
let
23
+
depsAttrs = if lib.isAttrs depsAttrsOrFile then depsAttrsOrFile else lib.importJSON depsAttrsOrFile;
24
+
fetchdep = dep: fetchers.${dep.fetcher} dep.args;
25
+
fetchedDeps = lib.mapAttrs (_name: fetchdep) depsAttrs;
26
+
manifestContents = lib.mapAttrs (_: dep: {
27
+
path = dep;
28
+
}) fetchedDeps;
29
+
manifest = writers.writeJSON "gclient-manifest.json" manifestContents;
30
+
in
31
+
manifestContents
32
+
// {
33
+
inherit manifest;
34
+
__toString = _: manifest;
35
+
};
36
+
37
+
gclientUnpackHook = callPackage (
38
+
{
39
+
lib,
40
+
makeSetupHook,
41
+
jq,
42
+
}:
43
+
44
+
makeSetupHook {
45
+
name = "gclient-unpack-hook";
46
+
substitutions = {
47
+
jq = lib.getExe jq;
48
+
};
49
+
} ./gclient-unpack-hook.sh
50
+
) { };
51
+
52
python = python3.withPackages (
53
ps: with ps; [
54
joblib
···
71
url = "https://chromium.googlesource.com/chromium/tools/depot_tools";
72
rev = "452fe3be37f78fbecefa1b4b0d359531bcd70d0d";
73
hash = "sha256-8IiJOm0FLa/u1Vd96tb33Ruj4IUTCeYgBpTk88znhPw=";
74
+
};
75
+
76
+
passthru = {
77
+
inherit fetchers importGclientDeps gclientUnpackHook;
78
};
79
}
80
''