diff options
Diffstat (limited to 'pkgs/build-support/dart')
3 files changed, 24 insertions, 4 deletions
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 ee610f673d2..3e901995237 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 9deb99648c0..e523b60797e 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 @@ -159,7 +160,7 @@ let configurePhase = '' runHook preConfigure - dart pub get --offline + doPubGet dart pub get --offline runHook postConfigure ''; @@ -168,14 +169,28 @@ let dart pub deps --json | jq .packages > $out runHook postBuild ''; - } // buildDrvInheritArgs); + } // (removeAttrs buildDrvInheritArgs [ "name" "pname" ])); + + # 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 37ef74aa62d..689e0e8c5b5 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" "$@" +} |