diff options
author | hacker1024 <hacker1024@users.sourceforge.net> | 2023-04-22 16:42:22 +1000 |
---|---|---|
committer | hacker1024 <hacker1024@users.sourceforge.net> | 2023-04-23 00:12:45 +1000 |
commit | 9f05297dc8875baeeeb8160b60f120affc259f2c (patch) | |
tree | 7ea6e2706fb0cbf38d32e7f60214ae72ba548291 /pkgs/build-support | |
parent | 37e93f7c3b9c98eef13733f2a558194db2d1b0f6 (diff) | |
download | nixpkgs-9f05297dc8875baeeeb8160b60f120affc259f2c.tar nixpkgs-9f05297dc8875baeeeb8160b60f120affc259f2c.tar.gz nixpkgs-9f05297dc8875baeeeb8160b60f120affc259f2c.tar.bz2 nixpkgs-9f05297dc8875baeeeb8160b60f120affc259f2c.tar.lz nixpkgs-9f05297dc8875baeeeb8160b60f120affc259f2c.tar.xz nixpkgs-9f05297dc8875baeeeb8160b60f120affc259f2c.tar.zst nixpkgs-9f05297dc8875baeeeb8160b60f120affc259f2c.zip |
flutter.buildFlutterApplication: Manually supply the dependency list
This removes the need for IFD.
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/dart/fetch-dart-deps/default.nix | 41 | ||||
-rw-r--r-- | pkgs/build-support/dart/list-dart-deps/default.nix | 28 | ||||
-rw-r--r-- | pkgs/build-support/flutter/default.nix | 21 |
3 files changed, 51 insertions, 39 deletions
diff --git a/pkgs/build-support/dart/fetch-dart-deps/default.nix b/pkgs/build-support/dart/fetch-dart-deps/default.nix index a3ab2c2c73a..9deb99648c0 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/default.nix +++ b/pkgs/build-support/dart/fetch-dart-deps/default.nix @@ -4,6 +4,7 @@ , dart , git , cacert +, jq }: { @@ -151,13 +152,35 @@ let outputHashMode = "recursive"; outputHash = if vendorHash != "" then vendorHash else lib.fakeSha256; } // (removeAttrs drvArgs [ "name" "pname" ])); + + depsListDrv = stdenvNoCC.mkDerivation ({ + name = "${name}-dart-deps-list.json"; + nativeBuildInputs = [ hook dart jq ]; + + configurePhase = '' + runHook preConfigure + dart pub get --offline + runHook postConfigure + ''; + + buildPhase = '' + runHook preBuild + dart pub deps --json | jq .packages > $out + runHook postBuild + ''; + } // buildDrvInheritArgs); + + 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; }; + propagatedBuildInputs = [ dart git ]; + passthru = { + files = deps.outPath; + depsListFile = depsListDrv.outPath; + }; + }) ./setup-hook.sh; in -(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; }; - propagatedBuildInputs = [ dart git ]; - passthru.files = deps.outPath; -}) ./setup-hook.sh +hook diff --git a/pkgs/build-support/dart/list-dart-deps/default.nix b/pkgs/build-support/dart/list-dart-deps/default.nix deleted file mode 100644 index 5cafd7773d4..00000000000 --- a/pkgs/build-support/dart/list-dart-deps/default.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ stdenv -, dart -, jq -}: -deps: - -builtins.fromJSON (builtins.readFile (stdenv.mkDerivation { - name = "${deps.name}-list.json"; - nativeBuildInputs = [ deps dart jq ]; - - unpackPhase = '' - runHook preUnpack - ln -s "${deps.files}"/pubspec/* . - runHook postUnpack - ''; - - configurePhase = '' - runHook preConfigure - dart pub get --offline - runHook postConfigure - ''; - - buildPhase = '' - runHook preBuild - dart pub deps --json | jq .packages > $out - runHook postBuild - ''; -})) diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 70428736c32..622a19c32bd 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -5,6 +5,7 @@ , llvmPackages_13 , cacert , flutter +, jq }: # absolutely no mac support for now @@ -13,9 +14,11 @@ , flutterBuildFlags ? [ ] , runtimeDependencies ? [ ] , customPackageOverrides ? { } +, depsListFile ? null , vendorHash , pubspecLockFile ? null , nativeBuildInputs ? [ ] +, preUnpack ? "" , postFixup ? "" , ... }@args: @@ -41,8 +44,19 @@ let makeWrapper deps flutter + jq ] ++ nativeBuildInputs; + preUnpack = '' + if ! { [ '${lib.boolToString (depsListFile != null)}' = 'true' ] ${lib.optionalString (depsListFile != null) "&& cmp -s <(jq -Sc . '${depsListFile}') <(jq -Sc . '${finalAttrs.passthru.depsListFile}')"}; }; then + echo 1>&2 -e '\nThe dependency list file was either not given or differs from the expected result.' \ + '\nPlease copy the contents of ${finalAttrs.passthru.depsListFile} to a new file to pass to the depsListFile argument.' + exit 1 + fi + + ${preUnpack} + ''; + configurePhase = '' runHook preConfigure @@ -106,11 +120,14 @@ let ${postFixup} ''; + + passthru = { + inherit (deps) depsListFile; + }; }); packageOverrideRepository = (callPackage ../../development/compilers/flutter/package-overrides { }) // customPackageOverrides; - packages = callPackage ../dart/list-dart-deps { dart = flutter; } deps; - productPackages = builtins.filter (package: package.kind != "dev") packages; + productPackages = builtins.filter (package: package.kind != "dev") (if depsListFile == null then [ ] else (builtins.fromJSON (builtins.readFile depsListFile))); in builtins.foldl' (prev: package: |