gclient2nix: add importGclientDeps & gclientUnpackHook
This commit is contained in:
parent
082d26cd46
commit
0e730af47a
28
pkgs/by-name/gc/gclient2nix/gclient-unpack-hook.sh
Normal file
28
pkgs/by-name/gc/gclient2nix/gclient-unpack-hook.sh
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# shellcheck shell=bash
|
||||||
|
|
||||||
|
gclientUnpackHook() {
|
||||||
|
echo "Executing gclientUnpackHook"
|
||||||
|
|
||||||
|
runHook preUnpack
|
||||||
|
|
||||||
|
if [ -z "${gclientDeps-}" ]; then
|
||||||
|
echo "gclientDeps missing"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for dep in $(@jq@ -c "to_entries[]" "$gclientDeps")
|
||||||
|
do
|
||||||
|
local name="$(echo "$dep" | @jq@ -r .key)"
|
||||||
|
echo "copying $name..."
|
||||||
|
local path="$(echo "$dep" | @jq@ -r .value.path)"
|
||||||
|
mkdir -p $(dirname "$name")
|
||||||
|
cp -r "$path/." "$name"
|
||||||
|
chmod u+w -R "$name"
|
||||||
|
done
|
||||||
|
|
||||||
|
runHook postUnpack
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "${dontGclientUnpack-}" ] && [ -z "${unpackPhase-}" ]; then
|
||||||
|
unpackPhase=(gclientUnpackHook)
|
||||||
|
fi
|
||||||
@ -6,9 +6,49 @@
|
|||||||
path,
|
path,
|
||||||
fetchgit,
|
fetchgit,
|
||||||
nurl,
|
nurl,
|
||||||
|
writers,
|
||||||
|
callPackage,
|
||||||
|
fetchFromGitiles,
|
||||||
|
fetchFromGitHub,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
fetchers = {
|
||||||
|
inherit fetchgit fetchFromGitiles fetchFromGitHub;
|
||||||
|
};
|
||||||
|
|
||||||
|
importGclientDeps =
|
||||||
|
depsAttrsOrFile:
|
||||||
|
let
|
||||||
|
depsAttrs = if lib.isAttrs depsAttrsOrFile then depsAttrsOrFile else lib.importJSON depsAttrsOrFile;
|
||||||
|
fetchdep = dep: fetchers.${dep.fetcher} dep.args;
|
||||||
|
fetchedDeps = lib.mapAttrs (_name: fetchdep) depsAttrs;
|
||||||
|
manifestContents = lib.mapAttrs (_: dep: {
|
||||||
|
path = dep;
|
||||||
|
}) fetchedDeps;
|
||||||
|
manifest = writers.writeJSON "gclient-manifest.json" manifestContents;
|
||||||
|
in
|
||||||
|
manifestContents
|
||||||
|
// {
|
||||||
|
inherit manifest;
|
||||||
|
__toString = _: manifest;
|
||||||
|
};
|
||||||
|
|
||||||
|
gclientUnpackHook = callPackage (
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
makeSetupHook,
|
||||||
|
jq,
|
||||||
|
}:
|
||||||
|
|
||||||
|
makeSetupHook {
|
||||||
|
name = "gclient-unpack-hook";
|
||||||
|
substitutions = {
|
||||||
|
jq = lib.getExe jq;
|
||||||
|
};
|
||||||
|
} ./gclient-unpack-hook.sh
|
||||||
|
) { };
|
||||||
|
|
||||||
python = python3.withPackages (
|
python = python3.withPackages (
|
||||||
ps: with ps; [
|
ps: with ps; [
|
||||||
joblib
|
joblib
|
||||||
@ -32,6 +72,10 @@ runCommand "gclient2nix"
|
|||||||
rev = "452fe3be37f78fbecefa1b4b0d359531bcd70d0d";
|
rev = "452fe3be37f78fbecefa1b4b0d359531bcd70d0d";
|
||||||
hash = "sha256-8IiJOm0FLa/u1Vd96tb33Ruj4IUTCeYgBpTk88znhPw=";
|
hash = "sha256-8IiJOm0FLa/u1Vd96tb33Ruj4IUTCeYgBpTk88znhPw=";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
passthru = {
|
||||||
|
inherit fetchers importGclientDeps gclientUnpackHook;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
''
|
''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user