about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorhacker1024 <hacker1024@users.sourceforge.net>2023-10-23 15:43:01 +1100
committerMaciej Krüger <mkg20001@gmail.com>2023-12-21 11:46:13 +0100
commit0d82a3864a86eb12cb6fdf38914014f47c260ab5 (patch)
tree76ed5d229f8b28a48b0b6c19646b7c251ccb694d /pkgs/build-support
parente99f59010ce621520e6bdbb092f547f143fbd254 (diff)
downloadnixlib-0d82a3864a86eb12cb6fdf38914014f47c260ab5.tar
nixlib-0d82a3864a86eb12cb6fdf38914014f47c260ab5.tar.gz
nixlib-0d82a3864a86eb12cb6fdf38914014f47c260ab5.tar.bz2
nixlib-0d82a3864a86eb12cb6fdf38914014f47c260ab5.tar.lz
nixlib-0d82a3864a86eb12cb6fdf38914014f47c260ab5.tar.xz
nixlib-0d82a3864a86eb12cb6fdf38914014f47c260ab5.tar.zst
nixlib-0d82a3864a86eb12cb6fdf38914014f47c260ab5.zip
fetchDartDeps: Add a package_config.json derivation
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/dart/fetch-dart-deps/default.nix28
1 files changed, 28 insertions, 0 deletions
diff --git a/pkgs/build-support/dart/fetch-dart-deps/default.nix b/pkgs/build-support/dart/fetch-dart-deps/default.nix
index fd3594df9950..66050f9fdf35 100644
--- a/pkgs/build-support/dart/fetch-dart-deps/default.nix
+++ b/pkgs/build-support/dart/fetch-dart-deps/default.nix
@@ -185,6 +185,33 @@ let
     dontInstall = true;
   };
 
+  packageConfigDrv = mkDepsDrv {
+    name = "${name}-package-config.json";
+
+    nativeBuildInputs = [ jq ];
+
+    buildPhase = ''
+      runHook preBuild
+
+      # Canonicalise the package_config.json, and replace references to the
+      # reconstructed package cache with the original FOD.
+      #
+      # The reconstructed package cache is not reproducible. The intended
+      # use-case of this derivation is for use with tools that use a
+      # package_config.json to load assets from packages, and not for use with
+      # Pub directly, which requires the setup performed by the hook before
+      # usage.
+      jq -S '
+        .packages[] |= . + { rootUri: .rootUri | gsub("'"$PUB_CACHE"'"; "${hook.deps}/cache/.pub-cache") }
+      | .generated |= "1970-01-01T00:00:00Z"
+      ' .dart_tool/package_config.json > $out
+
+      runHook postBuild
+    '';
+
+    dontInstall = true;
+  };
+
   # As of Dart 3.0.0, Pub checks the revision of cached Git-sourced packages.
   # Git must be wrapped to return a positive result, as the real .git directory is wiped
   # to produce a deteministic dependency derivation output.
@@ -210,6 +237,7 @@ let
       inherit deps;
       files = deps.outPath;
       depsListFile = depsListDrv.outPath;
+      packageConfig = packageConfigDrv;
     };
   }) ./setup-hook.sh;
 in