summaryrefslogtreecommitdiff
path: root/pkgs/by-name/gc/gclient2nix/package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/gc/gclient2nix/package.nix')
-rw-r--r--pkgs/by-name/gc/gclient2nix/package.nix84
1 files changed, 84 insertions, 0 deletions
diff --git a/pkgs/by-name/gc/gclient2nix/package.nix b/pkgs/by-name/gc/gclient2nix/package.nix
new file mode 100644
index 000000000000..7d55d0e234a8
--- /dev/null
+++ b/pkgs/by-name/gc/gclient2nix/package.nix
@@ -0,0 +1,84 @@
+{
+ lib,
+ python3,
+ runCommand,
+ makeWrapper,
+ fetchgit,
+ nurl,
+ writers,
+ callPackage,
+ fetchFromGitiles,
+ fetchFromGitHub,
+}:
+
+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 (
+ ps: with ps; [
+ joblib
+ platformdirs
+ click
+ click-log
+ ]
+ );
+
+in
+
+runCommand "gclient2nix"
+ {
+ nativeBuildInputs = [ makeWrapper ];
+ buildInputs = [ python ];
+
+ # substitutions
+ depot_tools_checkout = fetchgit {
+ url = "https://chromium.googlesource.com/chromium/tools/depot_tools";
+ rev = "452fe3be37f78fbecefa1b4b0d359531bcd70d0d";
+ hash = "sha256-8IiJOm0FLa/u1Vd96tb33Ruj4IUTCeYgBpTk88znhPw=";
+ };
+
+ passthru = {
+ inherit fetchers importGclientDeps gclientUnpackHook;
+ };
+ }
+ ''
+ mkdir -p $out/bin
+ substituteAll ${./gclient2nix.py} $out/bin/gclient2nix
+ chmod u+x $out/bin/gclient2nix
+ patchShebangs $out/bin/gclient2nix
+ wrapProgram $out/bin/gclient2nix --set PATH "${lib.makeBinPath [ nurl ]}"
+ ''