lol

gclient2nix: add importGclientDeps & gclientUnpackHook

Yureka 0e730af4 082d26cd

+72
+28
pkgs/by-name/gc/gclient2nix/gclient-unpack-hook.sh
··· 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 6 path, 7 7 fetchgit, 8 8 nurl, 9 + writers, 10 + callPackage, 11 + fetchFromGitiles, 12 + fetchFromGitHub, 9 13 }: 10 14 11 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 + 12 52 python = python3.withPackages ( 13 53 ps: with ps; [ 14 54 joblib ··· 31 71 url = "https://chromium.googlesource.com/chromium/tools/depot_tools"; 32 72 rev = "452fe3be37f78fbecefa1b4b0d359531bcd70d0d"; 33 73 hash = "sha256-8IiJOm0FLa/u1Vd96tb33Ruj4IUTCeYgBpTk88znhPw="; 74 + }; 75 + 76 + passthru = { 77 + inherit fetchers importGclientDeps gclientUnpackHook; 34 78 }; 35 79 } 36 80 ''