···11{ stdenvNoCC
22, lib
33, makeSetupHook
44+, writeShellScriptBin
45, dart
56, git
67, cacert
···170171 '';
171172 } // buildDrvInheritArgs);
172173174174+ # As of Dart 3.0.0, Pub checks the revision of cached Git-sourced packages.
175175+ # Git must be wrapped to return a positive result, as the real .git directory is wiped
176176+ # to produce a deteministic dependency derivation output.
177177+ # https://github.com/dart-lang/pub/pull/3791/files#diff-1639c4669c428c26e68cfebd5039a33f87ba568795f2c058c303ca8528f62b77R631
178178+ gitSourceWrapper = writeShellScriptBin "git" ''
179179+ args=("$@")
180180+ if [[ "''${args[0]}" == "rev-list" && "''${args[1]}" == "--max-count=1" ]]; then
181181+ revision="''${args[''${#args[@]}-1]}"
182182+ echo "$revision"
183183+ else
184184+ ${git}/bin/git "''${args[@]}"
185185+ fi
186186+ '';
187187+173188 hook = (makeSetupHook {
174189 # The setup hook should not be part of the fixed-output derivation.
175190 # Updates to the hook script should not change vendor hashes, and it won't
176191 # work at all anyway due to https://github.com/NixOS/nix/issues/6660.
177192 name = "${name}-dart-deps-setup-hook";
178178- substitutions = { inherit deps; };
193193+ substitutions = { inherit gitSourceWrapper deps; };
179194 propagatedBuildInputs = [ dart git ];
180195 passthru = {
181196 files = deps.outPath;
···3939 exit 1
4040 fi
4141}
4242+4343+# Performs the given pub get command with an appropriate environment.
4444+doPubGet() {
4545+ PATH="@gitSourceWrapper@/bin:$PATH" "$@"
4646+}