diff --git a/pkgs/build-support/dart/build-dart-application/hooks/dart-config-hook.sh b/pkgs/build-support/dart/build-dart-application/hooks/dart-config-hook.sh index ee610f673d2b..3e901995237d 100644 --- a/pkgs/build-support/dart/build-dart-application/hooks/dart-config-hook.sh +++ b/pkgs/build-support/dart/build-dart-application/hooks/dart-config-hook.sh @@ -4,7 +4,7 @@ dartConfigHook() { echo "Executing dartConfigHook" echo "Installing dependencies" - eval "$pubGetScript" --offline + eval doPubGet "$pubGetScript" --offline echo "Finished dartConfigHook" } diff --git a/pkgs/build-support/dart/fetch-dart-deps/default.nix b/pkgs/build-support/dart/fetch-dart-deps/default.nix index 9deb99648c08..8c45722109bb 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/default.nix +++ b/pkgs/build-support/dart/fetch-dart-deps/default.nix @@ -1,6 +1,7 @@ { stdenvNoCC , lib , makeSetupHook +, writeShellScriptBin , dart , git , cacert @@ -170,12 +171,26 @@ let ''; } // buildDrvInheritArgs); + # 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. + # https://github.com/dart-lang/pub/pull/3791/files#diff-1639c4669c428c26e68cfebd5039a33f87ba568795f2c058c303ca8528f62b77R631 + gitSourceWrapper = writeShellScriptBin "git" '' + args=("$@") + if [[ "''${args[0]}" == "rev-list" && "''${args[1]}" == "--max-count=1" ]]; then + revision="''${args[''${#args[@]}-1]}" + echo "$revision" + else + ${git}/bin/git "''${args[@]}" + fi + ''; + hook = (makeSetupHook { # The setup hook should not be part of the fixed-output derivation. # Updates to the hook script should not change vendor hashes, and it won't # work at all anyway due to https://github.com/NixOS/nix/issues/6660. name = "${name}-dart-deps-setup-hook"; - substitutions = { inherit deps; }; + substitutions = { inherit gitSourceWrapper deps; }; propagatedBuildInputs = [ dart git ]; passthru = { files = deps.outPath; diff --git a/pkgs/build-support/dart/fetch-dart-deps/setup-hook.sh b/pkgs/build-support/dart/fetch-dart-deps/setup-hook.sh index 37ef74aa62dd..689e0e8c5b5f 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/setup-hook.sh +++ b/pkgs/build-support/dart/fetch-dart-deps/setup-hook.sh @@ -39,3 +39,8 @@ _setupPubCache() { exit 1 fi } + +# Performs the given pub get command with an appropriate environment. +doPubGet() { + PATH="@gitSourceWrapper@/bin:$PATH" "$@" +} diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 04f9fe4f404c..ecca6b081f25 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -76,7 +76,7 @@ let mkdir -p build/flutter_assets/fonts - flutter packages get --offline -v + doPubGet flutter pub get --offline -v flutter build linux -v --release --split-debug-info="$debug" ${builtins.concatStringsSep " " (map (flag: "\"${flag}\"") finalAttrs.flutterBuildFlags)} runHook postBuild diff --git a/pkgs/misc/dart-sass-embedded/default.nix b/pkgs/misc/dart-sass-embedded/default.nix index c190dfaa5079..30ea1395dad3 100644 --- a/pkgs/misc/dart-sass-embedded/default.nix +++ b/pkgs/misc/dart-sass-embedded/default.nix @@ -41,7 +41,7 @@ stdenvNoCC.mkDerivation (finalAttrs: { configurePhase = '' runHook preConfigure - dart pub get --offline + doPubGet dart pub get --offline mkdir build ln -s ${embedded-protocol} build/embedded-protocol runHook postConfigure