From 32ac87459e003f6f323c4f3e0087c92a931abb70 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 14 Nov 2022 00:08:58 +1100 Subject: flutter: Add dependencies for Linux desktop compilation --- pkgs/development/compilers/flutter/flutter.nix | 117 +++++++++++++++++++------ 1 file changed, 89 insertions(+), 28 deletions(-) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index c9b8a21134915..9d53f4ba3a47e 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -3,18 +3,31 @@ , patches , dart , src +, supportsLinuxDesktop ? true }: { bash , buildFHSUserEnv , cacert , git -, runCommand +, runCommandLocal +, writeShellScript +, makeWrapper , stdenv , lib , alsa-lib +, atk +, cairo +, clang +, cmake , dbus , expat +, gdk-pixbuf +, glib +, gtk3 +, harfbuzz +, libepoxy +, libGL , libpulseaudio , libuuid , libX11 @@ -22,16 +35,19 @@ , libXcomposite , libXcursor , libXdamage +, libXext , libXfixes +, libXi , libXrender , libXtst -, libXi -, libXext -, libGL +, ninja , nspr , nss +, pango +, pkg-config , systemd , which +, xorgproto , callPackage }: let @@ -100,18 +116,34 @@ let # Wrap flutter inside an fhs user env to allow execution of binary, # like adb from $ANDROID_HOME or java from android-studio. + # + # Also provide libraries at hardcoded locations for Linux desktop target + # compilation and execution. fhsEnv = buildFHSUserEnv { name = "${drvName}-fhs-env"; - multiPkgs = pkgs: [ - # Flutter only use these certificates - (runCommand "fedoracert" { } '' - mkdir -p $out/etc/pki/tls/ - ln -s ${cacert}/etc/ssl/certs $out/etc/pki/tls/certs - '') - pkgs.zlib - ]; + multiPkgs = pkgs: + with pkgs; ([ + # Flutter only use these certificates + (runCommandLocal "fedoracert" { } '' + mkdir -p $out/etc/pki/tls/ + ln -s ${cacert}/etc/ssl/certs $out/etc/pki/tls/certs + '') + zlib + ] ++ pkgs.lib.lists.optionals supportsLinuxDesktop [ + atk + cairo + gdk-pixbuf + glib + gtk3 + harfbuzz + libepoxy + pango + xorg.libX11 + xorg.libX11.dev + xorg.xorgproto + ]); targetPkgs = pkgs: - with pkgs; [ + with pkgs; ([ bash curl dart @@ -143,22 +175,39 @@ let nspr nss systemd - ]; + ]); + profile = '' + export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/share/pkgconfig" + ''; }; in let self = (self: -runCommand drvName +runCommandLocal drvName { - startScript = '' - #!${bash}/bin/bash + flutterWithCorrectedCache = writeShellScript "flutter_corrected_cache" '' export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"} - export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1 - ${fhsEnv}/bin/${drvName}-fhs-env ${flutter}/bin/flutter --no-version-check "$@" + ${flutter}/bin/flutter "$@" ''; - preferLocalBuild = true; - allowSubstitutes = false; + buildInputs = [ + makeWrapper + pkg-config + ] ++ lib.lists.optionals supportsLinuxDesktop (let + # https://discourse.nixos.org/t/handling-transitive-c-dependencies/5942/3 + deps = pkg: (pkg.buildInputs or []) ++ (pkg.propagatedBuildInputs or []); + collect = pkg: lib.unique ([ pkg ] ++ deps pkg ++ lib.concatMap collect (deps pkg)); + in + collect atk.dev ++ + collect cairo.dev ++ + collect gdk-pixbuf.dev ++ + collect glib.dev ++ + collect gtk3.dev ++ + collect harfbuzz.dev ++ + collect libepoxy.dev ++ + collect pango.dev ++ + collect libX11.dev ++ + collect xorgproto); passthru = { unwrapped = flutter; inherit dart; @@ -178,13 +227,25 @@ runCommand drvName maintainers = with maintainers; [ babariviere ericdallo ]; }; } '' - mkdir -p $out/bin - - mkdir -p $out/bin/cache/ - ln -sf ${dart} $out/bin/cache/dart-sdk - - echo -n "$startScript" > $out/bin/${pname} - chmod +x $out/bin/${pname} + mkdir -p $out/bin + + mkdir -p $out/bin/cache/ + ln -sf ${dart} $out/bin/cache/dart-sdk + + mkdir -p $out/libexec + makeWrapper "$flutterWithCorrectedCache" $out/libexec/flutter_launcher \ + --set-default ANDROID_EMULATOR_USE_SYSTEM_LIBS 1 \ + --prefix PATH : ${lib.makeBinPath (lib.lists.optionals supportsLinuxDesktop [ + pkg-config + cmake + ninja + clang + ])} \ + --prefix PKG_CONFIG_PATH : "$PKG_CONFIG_PATH_FOR_TARGET" \ + --add-flags --no-version-check + + makeWrapper ${fhsEnv}/bin/${drvName}-fhs-env $out/bin/${pname} \ + --add-flags $out/libexec/flutter_launcher '') self; in self -- cgit 1.4.1 From 7fd5a33393a196d12769d5d10cd5972ac2d68d93 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 14 Nov 2022 00:22:10 +1100 Subject: flutter: Move runtime libraries out of FHS using LD_LIBRARY_PATH --- pkgs/development/compilers/flutter/flutter.nix | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index 9d53f4ba3a47e..680ea6d948881 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -130,15 +130,6 @@ let '') zlib ] ++ pkgs.lib.lists.optionals supportsLinuxDesktop [ - atk - cairo - gdk-pixbuf - glib - gtk3 - harfbuzz - libepoxy - pango - xorg.libX11 xorg.libX11.dev xorg.xorgproto ]); @@ -242,6 +233,17 @@ runCommandLocal drvName clang ])} \ --prefix PKG_CONFIG_PATH : "$PKG_CONFIG_PATH_FOR_TARGET" \ + --suffix LD_LIBRARY_PATH : ${lib.makeLibraryPath (lib.lists.optionals supportsLinuxDesktop [ + atk + cairo + gdk-pixbuf + glib + gtk3 + harfbuzz + libepoxy + pango + libX11 + ])} \ --add-flags --no-version-check makeWrapper ${fhsEnv}/bin/${drvName}-fhs-env $out/bin/${pname} \ -- cgit 1.4.1 From c6b044c101523efbe699373fdf449fdd60390cf4 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 14 Nov 2022 11:24:38 +1100 Subject: flutter: Use RPATH and CFLAGS to remove Linux desktop compilation and runtime FHS dependency --- pkgs/development/compilers/flutter/flutter.nix | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index 680ea6d948881..c8fc23492bacf 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -116,9 +116,6 @@ let # Wrap flutter inside an fhs user env to allow execution of binary, # like adb from $ANDROID_HOME or java from android-studio. - # - # Also provide libraries at hardcoded locations for Linux desktop target - # compilation and execution. fhsEnv = buildFHSUserEnv { name = "${drvName}-fhs-env"; multiPkgs = pkgs: @@ -129,9 +126,6 @@ let ln -s ${cacert}/etc/ssl/certs $out/etc/pki/tls/certs '') zlib - ] ++ pkgs.lib.lists.optionals supportsLinuxDesktop [ - xorg.libX11.dev - xorg.xorgproto ]); targetPkgs = pkgs: with pkgs; ([ @@ -167,9 +161,6 @@ let nss systemd ]); - profile = '' - export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/share/pkgconfig" - ''; }; in @@ -233,7 +224,8 @@ runCommandLocal drvName clang ])} \ --prefix PKG_CONFIG_PATH : "$PKG_CONFIG_PATH_FOR_TARGET" \ - --suffix LD_LIBRARY_PATH : ${lib.makeLibraryPath (lib.lists.optionals supportsLinuxDesktop [ + --prefix CXXFLAGS "''\t" '${lib.optionalString supportsLinuxDesktop "-isystem ${libX11.dev}/include -isystem ${xorgproto}/include"}' \ + --prefix LDFLAGS "''\t" '${lib.optionalString supportsLinuxDesktop "-rpath ${lib.makeLibraryPath [ atk cairo gdk-pixbuf @@ -243,7 +235,12 @@ runCommandLocal drvName libepoxy pango libX11 - ])} \ + ]}"}' \ + --suffix LD_LIBRARY_PATH : '${lib.optionalString supportsLinuxDesktop (lib.makeLibraryPath [ + # The prebuilt flutter_linux_gtk library shipped in the Flutter SDK does not have an appropriate RUNPATH. + # Its dependencies must be added here. + libepoxy + ])}' \ --add-flags --no-version-check makeWrapper ${fhsEnv}/bin/${drvName}-fhs-env $out/bin/${pname} \ -- cgit 1.4.1 From ea48c7c9b68add8b1b7f8a8926d9fec3df12301f Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 14 Nov 2022 13:11:49 +1100 Subject: flutter: Modularize unwrapped, wrapped, and FHS components --- pkgs/development/compilers/flutter/default.nix | 10 +- pkgs/development/compilers/flutter/fhs.nix | 71 +++++++ pkgs/development/compilers/flutter/flutter.nix | 257 +++++-------------------- pkgs/development/compilers/flutter/wrapper.nix | 89 +++++++++ pkgs/top-level/all-packages.nix | 8 +- 5 files changed, 219 insertions(+), 216 deletions(-) create mode 100644 pkgs/development/compilers/flutter/fhs.nix create mode 100644 pkgs/development/compilers/flutter/wrapper.nix diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix index 676ef78e3b349..50752b01ec7b7 100644 --- a/pkgs/development/compilers/flutter/default.nix +++ b/pkgs/development/compilers/flutter/default.nix @@ -1,11 +1,13 @@ { callPackage, fetchurl, dart }: let mkFlutter = opts: callPackage (import ./flutter.nix opts) { }; + wrapFlutter = flutter: callPackage (import ./wrapper.nix) { flutter = flutter; }; + mkFlutterFHS = flutter: callPackage (import ./fhs.nix) { flutter = flutter; }; getPatches = dir: let files = builtins.attrNames (builtins.readDir dir); in map (f: dir + ("/" + f)) files; - flutterDrv = { version, pname, dartVersion, hash, dartHash, patches }: mkFlutter { - inherit version pname patches; + flutterDrv = { version, dartVersion, hash, dartHash, patches }: mkFlutter { + inherit version patches; dart = dart.override { version = dartVersion; sources = { @@ -26,9 +28,8 @@ let }; in { - inherit mkFlutter; + inherit mkFlutter wrapFlutter mkFlutterFHS flutterDrv; stable = flutterDrv { - pname = "flutter"; version = "3.3.3"; dartVersion = "2.18.2"; hash = "sha256-MTZeWQUp4/TcPzYIT6eqIKSPUPvn2Mp/thOQzNgpTXg="; @@ -40,7 +41,6 @@ in }; v2 = flutterDrv { - pname = "flutter"; version = "2.10.5"; dartVersion = "2.16.2"; hash = "sha256-DTZwxlMUYk8NS1SaWUJolXjD+JnRW73Ps5CdRHDGnt0="; diff --git a/pkgs/development/compilers/flutter/fhs.nix b/pkgs/development/compilers/flutter/fhs.nix new file mode 100644 index 0000000000000..025d94665b5ad --- /dev/null +++ b/pkgs/development/compilers/flutter/fhs.nix @@ -0,0 +1,71 @@ +{ lib +, stdenv +, flutter +, buildFHSUserEnv +, runCommandLocal +, supportsAndroidEmulator ? stdenv.isLinux +}: + +# Wrap flutter inside an fhs user env to allow execution of binary, +# like adb from $ANDROID_HOME or java from android-studio. +buildFHSUserEnv { + name = flutter.name; + + multiPkgs = pkgs: with pkgs; ([ + # Flutter only use these certificates + (runCommandLocal "fedoracert" { } '' + mkdir -p $out/etc/pki/tls/ + ln -s ${cacert}/etc/ssl/certs $out/etc/pki/tls/certs + '') + zlib + ]); + + targetPkgs = pkgs: with pkgs; ([ + flutter + + # General ecosystem dependencies + bash + curl + git + unzip + which + xz + + # flutter test requires this lib + libGLU + ] ++ lib.optional supportsAndroidEmulator [ + # for android emulator + alsa-lib + dbus + expat + libpulseaudio + libuuid + xorg.libX11 + xorg.libxcb + xorg.libXcomposite + xorg.libXcursor + xorg.libXdamage + xorg.libXext + xorg.libXfixes + xorg.libXi + xorg.libXrender + xorg.libXtst + libGL + nspr + nss + systemd + ]); + + runScript = "flutter"; + + passthru = { + inherit flutter; + }; + + meta = flutter.meta // { + longDescription = '' + ${flutter.meta.longDescription} + Wrapped in a FHS environment to improve compatibility with internal tools and tools in the ecosystem. + ''; + }; +} diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index c8fc23492bacf..1cbbe66509eb5 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -1,202 +1,80 @@ -{ pname -, version +{ version , patches , dart , src -, supportsLinuxDesktop ? true }: -{ bash -, buildFHSUserEnv -, cacert +{ lib , git -, runCommandLocal -, writeShellScript -, makeWrapper , stdenv -, lib -, alsa-lib -, atk -, cairo -, clang -, cmake -, dbus -, expat -, gdk-pixbuf -, glib -, gtk3 -, harfbuzz -, libepoxy -, libGL -, libpulseaudio -, libuuid -, libX11 -, libxcb -, libXcomposite -, libXcursor -, libXdamage -, libXext -, libXfixes -, libXi -, libXrender -, libXtst -, ninja -, nspr -, nss -, pango -, pkg-config -, systemd , which -, xorgproto -, callPackage }: -let - drvName = "flutter-${version}"; - flutter = stdenv.mkDerivation { - name = "${drvName}-unwrapped"; - buildInputs = [ git ]; +stdenv.mkDerivation { + name = "$flutter-${version}-unwrapped"; - inherit src patches version; + buildInputs = [ git ]; - postPatch = '' - patchShebangs --build ./bin/ - ''; + inherit src patches version; - buildPhase = '' - export FLUTTER_ROOT="$(pwd)" - export FLUTTER_TOOLS_DIR="$FLUTTER_ROOT/packages/flutter_tools" - export SCRIPT_PATH="$FLUTTER_TOOLS_DIR/bin/flutter_tools.dart" + postPatch = '' + patchShebangs --build ./bin/ + ''; - export SNAPSHOT_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.snapshot" - export STAMP_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.stamp" + buildPhase = '' + export FLUTTER_ROOT="$(pwd)" + export FLUTTER_TOOLS_DIR="$FLUTTER_ROOT/packages/flutter_tools" + export SCRIPT_PATH="$FLUTTER_TOOLS_DIR/bin/flutter_tools.dart" - export DART_SDK_PATH="${dart}" + export SNAPSHOT_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.snapshot" + export STAMP_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.stamp" - HOME=../.. # required for pub upgrade --offline, ~/.pub-cache - # path is relative otherwise it's replaced by /build/flutter + export DART_SDK_PATH="${dart}" - pushd "$FLUTTER_TOOLS_DIR" - ${dart}/bin/dart pub get --offline - popd + HOME=../.. # required for pub upgrade --offline, ~/.pub-cache + # path is relative otherwise it's replaced by /build/flutter - local revision="$(cd "$FLUTTER_ROOT"; git rev-parse HEAD)" - ${dart}/bin/dart --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.dart_tool/package_config.json" "$SCRIPT_PATH" - echo "$revision" > "$STAMP_PATH" - echo -n "${version}" > version + pushd "$FLUTTER_TOOLS_DIR" + ${dart}/bin/dart pub get --offline + popd - rm -r bin/cache/{artifacts,dart-sdk,downloads} - rm bin/cache/*.stamp - ''; + local revision="$(cd "$FLUTTER_ROOT"; git rev-parse HEAD)" + ${dart}/bin/dart --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.dart_tool/package_config.json" "$SCRIPT_PATH" + echo "$revision" > "$STAMP_PATH" + echo -n "${version}" > version - installPhase = '' - runHook preInstall + rm -r bin/cache/{artifacts,dart-sdk,downloads} + rm bin/cache/*.stamp + ''; - mkdir -p $out - cp -r . $out - mkdir -p $out/bin/cache/ - ln -sf ${dart} $out/bin/cache/dart-sdk + installPhase = '' + runHook preInstall - runHook postInstall - ''; - - doInstallCheck = true; - installCheckInputs = [ which ]; - installCheckPhase = '' - runHook preInstallCheck + mkdir -p $out + cp -r . $out + mkdir -p $out/bin/cache/ + ln -sf ${dart} $out/bin/cache/dart-sdk - export HOME="$(mktemp -d)" - $out/bin/flutter config --android-studio-dir $HOME - $out/bin/flutter config --android-sdk $HOME - $out/bin/flutter --version | fgrep -q '${version}' + runHook postInstall + ''; - runHook postInstallCheck - ''; - }; + doInstallCheck = true; + installCheckInputs = [ which ]; + installCheckPhase = '' + runHook preInstallCheck - # Wrap flutter inside an fhs user env to allow execution of binary, - # like adb from $ANDROID_HOME or java from android-studio. - fhsEnv = buildFHSUserEnv { - name = "${drvName}-fhs-env"; - multiPkgs = pkgs: - with pkgs; ([ - # Flutter only use these certificates - (runCommandLocal "fedoracert" { } '' - mkdir -p $out/etc/pki/tls/ - ln -s ${cacert}/etc/ssl/certs $out/etc/pki/tls/certs - '') - zlib - ]); - targetPkgs = pkgs: - with pkgs; ([ - bash - curl - dart - git - unzip - which - xz - - # flutter test requires this lib - libGLU - - # for android emulator - alsa-lib - dbus - expat - libpulseaudio - libuuid - libX11 - libxcb - libXcomposite - libXcursor - libXdamage - libXext - libXfixes - libXi - libXrender - libXtst - libGL - nspr - nss - systemd - ]); - }; + export HOME="$(mktemp -d)" + $out/bin/flutter config --android-studio-dir $HOME + $out/bin/flutter config --android-sdk $HOME + $out/bin/flutter --version | fgrep -q '${version}' -in -let -self = (self: -runCommandLocal drvName -{ - flutterWithCorrectedCache = writeShellScript "flutter_corrected_cache" '' - export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"} - ${flutter}/bin/flutter "$@" + runHook postInstallCheck ''; - buildInputs = [ - makeWrapper - pkg-config - ] ++ lib.lists.optionals supportsLinuxDesktop (let - # https://discourse.nixos.org/t/handling-transitive-c-dependencies/5942/3 - deps = pkg: (pkg.buildInputs or []) ++ (pkg.propagatedBuildInputs or []); - collect = pkg: lib.unique ([ pkg ] ++ deps pkg ++ lib.concatMap collect (deps pkg)); - in - collect atk.dev ++ - collect cairo.dev ++ - collect gdk-pixbuf.dev ++ - collect glib.dev ++ - collect gtk3.dev ++ - collect harfbuzz.dev ++ - collect libepoxy.dev ++ - collect pango.dev ++ - collect libX11.dev ++ - collect xorgproto); + passthru = { - unwrapped = flutter; inherit dart; - mkFlutterApp = callPackage ../../../build-support/flutter { - flutter = self; - }; }; + meta = with lib; { description = "Flutter is Google's SDK for building mobile, web and desktop with Dart"; longDescription = '' @@ -208,43 +86,4 @@ runCommandLocal drvName platforms = [ "x86_64-linux" "aarch64-linux" ]; maintainers = with maintainers; [ babariviere ericdallo ]; }; -} '' - mkdir -p $out/bin - - mkdir -p $out/bin/cache/ - ln -sf ${dart} $out/bin/cache/dart-sdk - - mkdir -p $out/libexec - makeWrapper "$flutterWithCorrectedCache" $out/libexec/flutter_launcher \ - --set-default ANDROID_EMULATOR_USE_SYSTEM_LIBS 1 \ - --prefix PATH : ${lib.makeBinPath (lib.lists.optionals supportsLinuxDesktop [ - pkg-config - cmake - ninja - clang - ])} \ - --prefix PKG_CONFIG_PATH : "$PKG_CONFIG_PATH_FOR_TARGET" \ - --prefix CXXFLAGS "''\t" '${lib.optionalString supportsLinuxDesktop "-isystem ${libX11.dev}/include -isystem ${xorgproto}/include"}' \ - --prefix LDFLAGS "''\t" '${lib.optionalString supportsLinuxDesktop "-rpath ${lib.makeLibraryPath [ - atk - cairo - gdk-pixbuf - glib - gtk3 - harfbuzz - libepoxy - pango - libX11 - ]}"}' \ - --suffix LD_LIBRARY_PATH : '${lib.optionalString supportsLinuxDesktop (lib.makeLibraryPath [ - # The prebuilt flutter_linux_gtk library shipped in the Flutter SDK does not have an appropriate RUNPATH. - # Its dependencies must be added here. - libepoxy - ])}' \ - --add-flags --no-version-check - - makeWrapper ${fhsEnv}/bin/${drvName}-fhs-env $out/bin/${pname} \ - --add-flags $out/libexec/flutter_launcher -'') self; -in -self +} diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix new file mode 100644 index 0000000000000..05a64f170287b --- /dev/null +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -0,0 +1,89 @@ +{ lib +, flutter +, supportsLinuxDesktop ? true +, makeWrapper +, runCommandLocal +, writeShellScript +, pkg-config +, atk +, cairo +, gdk-pixbuf +, glib +, gtk3 +, harfbuzz +, libepoxy +, pango +, libX11 +, xorgproto +, cmake +, ninja +, clang +}: + +runCommandLocal "flutter" +{ + flutterWithCorrectedCache = writeShellScript "flutter_corrected_cache" '' + export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"} + ${flutter}/bin/flutter "$@" + ''; + + buildInputs = [ + makeWrapper + pkg-config + ] ++ lib.lists.optionals supportsLinuxDesktop ( + let + # https://discourse.nixos.org/t/handling-transitive-c-dependencies/5942/3 + deps = pkg: (pkg.buildInputs or [ ]) ++ (pkg.propagatedBuildInputs or [ ]); + collect = pkg: lib.unique ([ pkg ] ++ deps pkg ++ lib.concatMap collect (deps pkg)); + in + collect atk.dev ++ + collect cairo.dev ++ + collect gdk-pixbuf.dev ++ + collect glib.dev ++ + collect gtk3.dev ++ + collect harfbuzz.dev ++ + collect libepoxy.dev ++ + collect pango.dev ++ + collect libX11.dev ++ + collect xorgproto + ); + + passthru = flutter.passthru // { + unwrapped = flutter; + }; + + inherit (flutter) meta; +} '' + mkdir -p $out/bin + + mkdir -p $out/bin/cache/ + ln -sf ${flutter.dart} $out/bin/cache/dart-sdk + + makeWrapper "$flutterWithCorrectedCache" $out/bin/flutter \ + --set-default ANDROID_EMULATOR_USE_SYSTEM_LIBS 1 \ + --prefix PATH : ${lib.makeBinPath (lib.lists.optionals supportsLinuxDesktop [ + pkg-config + cmake + ninja + clang + ])} \ + --prefix PKG_CONFIG_PATH : "$PKG_CONFIG_PATH_FOR_TARGET" \ + --prefix CXXFLAGS "''\t" '${lib.optionalString supportsLinuxDesktop "-isystem ${libX11.dev}/include -isystem ${xorgproto}/include"}' \ + --prefix LDFLAGS "''\t" '${lib.optionalString supportsLinuxDesktop "-rpath ${lib.makeLibraryPath [ + atk + cairo + gdk-pixbuf + glib + gtk3 + harfbuzz + libepoxy + pango + libX11 + ]}"}' \ + --suffix LD_LIBRARY_PATH : '${lib.optionalString supportsLinuxDesktop (lib.makeLibraryPath [ + # The prebuilt flutter_linux_gtk library shipped in the Flutter SDK does not have an appropriate RUNPATH. + # Its dependencies must be added here. + libepoxy + ])}' \ + --add-flags --no-version-check +'' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e493af7aa0ac6..91e81acf393ab 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -13699,8 +13699,12 @@ with pkgs; flutterPackages = recurseIntoAttrs (callPackage ../development/compilers/flutter { }); - flutter = flutterPackages.stable; - flutter2 = flutterPackages.v2; + flutter-unwrapped = flutterPackages.stable; + flutter2-unwrapped = flutterPackages.v2; + flutter-wrapped = flutterPackages.wrapFlutter flutter-unwrapped; + flutter2-wrapped = flutterPackages.wrapFlutter flutter2-unwrapped; + flutter = flutterPackages.mkFlutterFHS flutter-wrapped; + flutter2 = flutterPackages.mkFlutterFHS flutter2-wrapped; fnm = callPackage ../development/tools/fnm { inherit (darwin.apple_sdk.frameworks) DiskArbitration Foundation Security; -- cgit 1.4.1 From e2adc5d8997a8a63cd3e69d9ac21b94a34c7f536 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 14 Nov 2022 13:28:45 +1100 Subject: flutter: Only enable Linux desktop support by default on Linux --- pkgs/development/compilers/flutter/wrapper.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index 05a64f170287b..e20bc04975129 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -1,6 +1,7 @@ { lib +, stdenv , flutter -, supportsLinuxDesktop ? true +, supportsLinuxDesktop ? stdenv.isLinux , makeWrapper , runCommandLocal , writeShellScript -- cgit 1.4.1 From e4df8739b7dc5d2b327669aa3edeff6f2be32c05 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 14 Nov 2022 21:17:36 +1100 Subject: flutter: Implement mkFlutter function using barebones FHS environment --- pkgs/development/compilers/flutter/fhs.nix | 117 +++++++++++++++-------------- 1 file changed, 62 insertions(+), 55 deletions(-) diff --git a/pkgs/development/compilers/flutter/fhs.nix b/pkgs/development/compilers/flutter/fhs.nix index 025d94665b5ad..bbba89843e8d7 100644 --- a/pkgs/development/compilers/flutter/fhs.nix +++ b/pkgs/development/compilers/flutter/fhs.nix @@ -1,71 +1,78 @@ { lib , stdenv +, callPackage , flutter , buildFHSUserEnv , runCommandLocal , supportsAndroidEmulator ? stdenv.isLinux }: -# Wrap flutter inside an fhs user env to allow execution of binary, -# like adb from $ANDROID_HOME or java from android-studio. -buildFHSUserEnv { - name = flutter.name; +let + # Wrap flutter inside an fhs user env to allow execution of binary, + # like adb from $ANDROID_HOME or java from android-studio. + self = buildFHSUserEnv { + name = flutter.name; - multiPkgs = pkgs: with pkgs; ([ - # Flutter only use these certificates - (runCommandLocal "fedoracert" { } '' - mkdir -p $out/etc/pki/tls/ - ln -s ${cacert}/etc/ssl/certs $out/etc/pki/tls/certs - '') - zlib - ]); + multiPkgs = pkgs: with pkgs; ([ + # Flutter only use these certificates + (runCommandLocal "fedoracert" { } '' + mkdir -p $out/etc/pki/tls/ + ln -s ${cacert}/etc/ssl/certs $out/etc/pki/tls/certs + '') + zlib + ]); - targetPkgs = pkgs: with pkgs; ([ - flutter + targetPkgs = pkgs: with pkgs; ([ + flutter - # General ecosystem dependencies - bash - curl - git - unzip - which - xz + # General ecosystem dependencies + bash + curl + git + unzip + which + xz - # flutter test requires this lib - libGLU - ] ++ lib.optional supportsAndroidEmulator [ - # for android emulator - alsa-lib - dbus - expat - libpulseaudio - libuuid - xorg.libX11 - xorg.libxcb - xorg.libXcomposite - xorg.libXcursor - xorg.libXdamage - xorg.libXext - xorg.libXfixes - xorg.libXi - xorg.libXrender - xorg.libXtst - libGL - nspr - nss - systemd - ]); + # flutter test requires this lib + libGLU + ] ++ lib.optional supportsAndroidEmulator [ + # for android emulator + alsa-lib + dbus + expat + libpulseaudio + libuuid + xorg.libX11 + xorg.libxcb + xorg.libXcomposite + xorg.libXcursor + xorg.libXdamage + xorg.libXext + xorg.libXfixes + xorg.libXi + xorg.libXrender + xorg.libXtst + libGL + nspr + nss + systemd + ]); - runScript = "flutter"; + runScript = "flutter"; - passthru = { - inherit flutter; - }; + passthru = flutter.passthru // { + wrapped = flutter; + mkFlutterApp = callPackage ../../../build-support/flutter { + flutter = callPackage ./fhs.nix { supportsAndroidEmulator = false; }; + }; + }; - meta = flutter.meta // { - longDescription = '' - ${flutter.meta.longDescription} - Wrapped in a FHS environment to improve compatibility with internal tools and tools in the ecosystem. - ''; + meta = flutter.meta // { + longDescription = '' + ${flutter.meta.longDescription} + Wrapped in a FHS environment to improve compatibility with internal tools and tools in the ecosystem. + ''; + }; }; -} +in +self -- cgit 1.4.1 From b180cb467bbf3b4ec8f8f488647753081f3af72a Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 14 Nov 2022 21:20:34 +1100 Subject: flutter.mkFlutterApp: Use wrapped Flutter package during build This ensures that all runtime dependencies are supplied. --- pkgs/build-support/flutter/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 691b2c5c6e600..64017e2bd657e 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -45,7 +45,7 @@ let getAttrsOrNull = names: attrs: lib.genAttrs names (name: if attrs ? ${name} then attrs.${name} else null); flutterDeps = [ # flutter deps - flutter.unwrapped + flutter.wrapped bash curl flutter.dart -- cgit 1.4.1 From 43d1e2ebf49cfb1b96c9ec82c0de3dd6b2b3935c Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 14 Nov 2022 21:21:22 +1100 Subject: flutter.mkFlutterApp: Don't use .packages This file is deprecated, unused, and not generated in newer Flutter versions. --- pkgs/build-support/flutter/default.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 64017e2bd657e..cd10acb4a01b3 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -88,7 +88,7 @@ let # so we can use lock, diff yaml cp "pubspec.yaml" "$RES" cp "pubspec.lock" "$RES" - mv .dart_tool .flutter-plugins .flutter-plugins-dependencies .packages "$RES/f" + mv .dart_tool .flutter-plugins .flutter-plugins-dependencies "$RES/f" # replace paths with placeholders find "$RES" -type f -exec sed -i \ @@ -119,7 +119,6 @@ let find "$RES/.pub-cache" -iname "*.json" -exec sed -r 's|.*_fetchedAt.*| "_fetchedAt": "'"$DART_DATE"'",|g' -i {} + replace_line_matching "$RES/f/.dart_tool/package_config.json" '"generated"' '"generated": "'"$DART_DATE"'",' replace_line_matching "$RES/f/.flutter-plugins-dependencies" '"date_created"' '"date_created": "'"$DART_DATE"'",' - remove_line_matching "$RES/f/.packages" "Generated by pub" # nuke refs find "$RES" -type f -exec nuke-refs {} + -- cgit 1.4.1 From 9c6c81dc4914cc40db32f2ebd351b80f0f9e6576 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 17 Nov 2022 01:26:25 +1100 Subject: flutter: Add fake SDK derivation --- pkgs/development/compilers/flutter/default.nix | 3 ++- pkgs/development/compilers/flutter/fake-sdk.nix | 15 +++++++++++++++ pkgs/development/compilers/flutter/fhs.nix | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/compilers/flutter/fake-sdk.nix diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix index 50752b01ec7b7..ab91e946cbbd7 100644 --- a/pkgs/development/compilers/flutter/default.nix +++ b/pkgs/development/compilers/flutter/default.nix @@ -3,6 +3,7 @@ let mkFlutter = opts: callPackage (import ./flutter.nix opts) { }; wrapFlutter = flutter: callPackage (import ./wrapper.nix) { flutter = flutter; }; mkFlutterFHS = flutter: callPackage (import ./fhs.nix) { flutter = flutter; }; + mkFakeSdk = flutter: callPackage (import ./fake-sdk.nix) { flutter = flutter; }; getPatches = dir: let files = builtins.attrNames (builtins.readDir dir); in map (f: dir + ("/" + f)) files; @@ -28,7 +29,7 @@ let }; in { - inherit mkFlutter wrapFlutter mkFlutterFHS flutterDrv; + inherit mkFlutter wrapFlutter mkFlutterFHS mkFakeSdk flutterDrv; stable = flutterDrv { version = "3.3.3"; dartVersion = "2.18.2"; diff --git a/pkgs/development/compilers/flutter/fake-sdk.nix b/pkgs/development/compilers/flutter/fake-sdk.nix new file mode 100644 index 0000000000000..e540cf1fa1c4f --- /dev/null +++ b/pkgs/development/compilers/flutter/fake-sdk.nix @@ -0,0 +1,15 @@ +{ flutter, symlinkJoin }: + +symlinkJoin { + name = "flutter-fake-${flutter.name}"; + paths = [ flutter flutter.unwrapped ]; + + inherit (flutter) passthru; + + meta = flutter.meta // { + longDescription = '' + ${flutter.meta.longDescription} + Modified binaries are linked into the original SDK directory for use with tools that use the whole SDK. + ''; + }; +} diff --git a/pkgs/development/compilers/flutter/fhs.nix b/pkgs/development/compilers/flutter/fhs.nix index bbba89843e8d7..9488e2724a77e 100644 --- a/pkgs/development/compilers/flutter/fhs.nix +++ b/pkgs/development/compilers/flutter/fhs.nix @@ -65,6 +65,7 @@ let mkFlutterApp = callPackage ../../../build-support/flutter { flutter = callPackage ./fhs.nix { supportsAndroidEmulator = false; }; }; + fakeSdk = callPackage ./fake-sdk.nix { flutter = self; }; }; meta = flutter.meta // { -- cgit 1.4.1 From fd46552867e2ce5fdb27a1c8fb27deea227c9050 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Wed, 8 Feb 2023 15:27:18 +1100 Subject: flutter: Add libdeflate to build environment --- .../compilers/flutter/packages/libdeflate/default.nix | 17 +++++++++++++++++ pkgs/development/compilers/flutter/wrapper.nix | 2 ++ 2 files changed, 19 insertions(+) create mode 100644 pkgs/development/compilers/flutter/packages/libdeflate/default.nix diff --git a/pkgs/development/compilers/flutter/packages/libdeflate/default.nix b/pkgs/development/compilers/flutter/packages/libdeflate/default.nix new file mode 100644 index 0000000000000..c0b3cabbc9d68 --- /dev/null +++ b/pkgs/development/compilers/flutter/packages/libdeflate/default.nix @@ -0,0 +1,17 @@ +{ stdenv, fetchFromGitHub, cmake }: + +stdenv.mkDerivation rec { + pname = "libdeflate"; + version = "1.17"; + + src = fetchFromGitHub { + owner = "ebiggers"; + repo = pname; + rev = "v${version}"; + hash = "sha256-tKs8feGbeodOID8FPIUc/1LfBz1p0oN1Jfkv2OnA2qc="; + }; + + nativeBuildInputs = [ cmake ]; + + outputs = [ "bin" "dev" "out" ]; +} diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index e20bc04975129..38ac1243e8aab 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -1,5 +1,6 @@ { lib , stdenv +, callPackage , flutter , supportsLinuxDesktop ? stdenv.isLinux , makeWrapper @@ -46,6 +47,7 @@ runCommandLocal "flutter" collect libepoxy.dev ++ collect pango.dev ++ collect libX11.dev ++ + collect (callPackage ./packages/libdeflate { }).dev ++ collect xorgproto ); -- cgit 1.4.1 From 1d547baee0f502f91a67153ee3a9355d0eb31c61 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Wed, 8 Feb 2023 16:11:26 +1100 Subject: flutter: Do not rely on pkg-config setup hook to build search path --- pkgs/development/compilers/flutter/wrapper.nix | 46 +++++++++++++------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index 38ac1243e8aab..c6f9b324147cf 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -29,27 +29,7 @@ runCommandLocal "flutter" ${flutter}/bin/flutter "$@" ''; - buildInputs = [ - makeWrapper - pkg-config - ] ++ lib.lists.optionals supportsLinuxDesktop ( - let - # https://discourse.nixos.org/t/handling-transitive-c-dependencies/5942/3 - deps = pkg: (pkg.buildInputs or [ ]) ++ (pkg.propagatedBuildInputs or [ ]); - collect = pkg: lib.unique ([ pkg ] ++ deps pkg ++ lib.concatMap collect (deps pkg)); - in - collect atk.dev ++ - collect cairo.dev ++ - collect gdk-pixbuf.dev ++ - collect glib.dev ++ - collect gtk3.dev ++ - collect harfbuzz.dev ++ - collect libepoxy.dev ++ - collect pango.dev ++ - collect libX11.dev ++ - collect (callPackage ./packages/libdeflate { }).dev ++ - collect xorgproto - ); + buildInputs = [ makeWrapper ]; passthru = flutter.passthru // { unwrapped = flutter; @@ -64,13 +44,33 @@ runCommandLocal "flutter" makeWrapper "$flutterWithCorrectedCache" $out/bin/flutter \ --set-default ANDROID_EMULATOR_USE_SYSTEM_LIBS 1 \ - --prefix PATH : ${lib.makeBinPath (lib.lists.optionals supportsLinuxDesktop [ + --prefix PATH : ${lib.makeBinPath (lib.optionals supportsLinuxDesktop [ pkg-config cmake ninja clang ])} \ - --prefix PKG_CONFIG_PATH : "$PKG_CONFIG_PATH_FOR_TARGET" \ + --prefix PKG_CONFIG_PATH : "${ + let + # https://discourse.nixos.org/t/handling-transitive-c-dependencies/5942/3 + deps = pkg: builtins.filter lib.isDerivation ((pkg.buildInputs or [ ]) ++ (pkg.propagatedBuildInputs or [ ])); + collect = pkg: lib.unique ([ pkg ] ++ deps pkg ++ builtins.concatMap collect (deps pkg)); + libraries = builtins.concatMap (pkg: collect (lib.getOutput "dev" pkg)) (lib.optionals supportsLinuxDesktop[ + atk + cairo + gdk-pixbuf + glib + gtk3 + harfbuzz + libepoxy + pango + libX11 + (callPackage ./packages/libdeflate { }) + xorgproto + ]); + pkgconfigLib = builtins.filter (library: builtins.pathExists "${library}/lib/pkgconfig") libraries; + pkgconfigShare = builtins.filter (library: builtins.pathExists "${library}/share/pkgconfig") libraries; + in "${lib.makeSearchPathOutput "dev" "lib/pkgconfig" pkgconfigLib}:${lib.makeSearchPathOutput "dev" "share/pkgconfig" pkgconfigShare}"}" \ --prefix CXXFLAGS "''\t" '${lib.optionalString supportsLinuxDesktop "-isystem ${libX11.dev}/include -isystem ${xorgproto}/include"}' \ --prefix LDFLAGS "''\t" '${lib.optionalString supportsLinuxDesktop "-rpath ${lib.makeLibraryPath [ atk -- cgit 1.4.1 From 240d9bdf436a460dab587a0ff391d5029c1f8fb4 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Fri, 17 Feb 2023 22:48:41 +1100 Subject: flutter: Properly set linker flags in wrapper --- pkgs/development/compilers/flutter/wrapper.nix | 61 ++++++++++++-------------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index c6f9b324147cf..834702d4eac50 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -22,6 +22,26 @@ , clang }: +let + linuxDesktopRuntimeDeps = [ + atk + cairo + gdk-pixbuf + glib + gtk3 + harfbuzz + libepoxy + pango + libX11 + (callPackage ./packages/libdeflate { }) + ]; + + linuxDesktopBuildDeps = let + # https://discourse.nixos.org/t/handling-transitive-c-dependencies/5942/3 + deps = pkg: builtins.filter lib.isDerivation ((pkg.buildInputs or [ ]) ++ (pkg.propagatedBuildInputs or [ ])); + collect = pkg: lib.unique ([ pkg ] ++ deps pkg ++ builtins.concatMap collect (deps pkg)); + in builtins.concatMap collect linuxDesktopRuntimeDeps; +in runCommandLocal "flutter" { flutterWithCorrectedCache = writeShellScript "flutter_corrected_cache" '' @@ -44,45 +64,20 @@ runCommandLocal "flutter" makeWrapper "$flutterWithCorrectedCache" $out/bin/flutter \ --set-default ANDROID_EMULATOR_USE_SYSTEM_LIBS 1 \ - --prefix PATH : ${lib.makeBinPath (lib.optionals supportsLinuxDesktop [ + --prefix PATH : '${lib.makeBinPath (lib.optionals supportsLinuxDesktop [ pkg-config cmake ninja clang - ])} \ - --prefix PKG_CONFIG_PATH : "${ + ])}' \ + --prefix PKG_CONFIG_PATH : '${ let - # https://discourse.nixos.org/t/handling-transitive-c-dependencies/5942/3 - deps = pkg: builtins.filter lib.isDerivation ((pkg.buildInputs or [ ]) ++ (pkg.propagatedBuildInputs or [ ])); - collect = pkg: lib.unique ([ pkg ] ++ deps pkg ++ builtins.concatMap collect (deps pkg)); - libraries = builtins.concatMap (pkg: collect (lib.getOutput "dev" pkg)) (lib.optionals supportsLinuxDesktop[ - atk - cairo - gdk-pixbuf - glib - gtk3 - harfbuzz - libepoxy - pango - libX11 - (callPackage ./packages/libdeflate { }) - xorgproto - ]); - pkgconfigLib = builtins.filter (library: builtins.pathExists "${library}/lib/pkgconfig") libraries; - pkgconfigShare = builtins.filter (library: builtins.pathExists "${library}/share/pkgconfig") libraries; - in "${lib.makeSearchPathOutput "dev" "lib/pkgconfig" pkgconfigLib}:${lib.makeSearchPathOutput "dev" "share/pkgconfig" pkgconfigShare}"}" \ + makePkgConfigSearchPath = pkgs: builtins.concatStringsSep ":" (builtins.filter builtins.pathExists (builtins.concatMap (pkg: map (dir: "${lib.getOutput "dev" pkg}/${dir}/pkgconfig") [ "lib" "share" ]) pkgs)); + in makePkgConfigSearchPath linuxDesktopBuildDeps}' \ --prefix CXXFLAGS "''\t" '${lib.optionalString supportsLinuxDesktop "-isystem ${libX11.dev}/include -isystem ${xorgproto}/include"}' \ - --prefix LDFLAGS "''\t" '${lib.optionalString supportsLinuxDesktop "-rpath ${lib.makeLibraryPath [ - atk - cairo - gdk-pixbuf - glib - gtk3 - harfbuzz - libepoxy - pango - libX11 - ]}"}' \ + ${let linkerFlags = map (pkg: "-rpath,${lib.getOutput "lib" pkg}/lib") (lib.optionals supportsLinuxDesktop linuxDesktopRuntimeDeps); in '' + --prefix LDFLAGS "''\t" '${builtins.concatStringsSep " " (map (flag: "-Wl,${flag}") linkerFlags)}' \ + ''} \ --suffix LD_LIBRARY_PATH : '${lib.optionalString supportsLinuxDesktop (lib.makeLibraryPath [ # The prebuilt flutter_linux_gtk library shipped in the Flutter SDK does not have an appropriate RUNPATH. # Its dependencies must be added here. -- cgit 1.4.1 From aa33cb995640cf2dcc4ff8751125fa92f4c742d1 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Fri, 17 Feb 2023 23:49:10 +1100 Subject: flutter: Reorganize the wrapper code --- pkgs/development/compilers/flutter/wrapper.nix | 83 ++++++++++++++++---------- 1 file changed, 50 insertions(+), 33 deletions(-) diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index 834702d4eac50..63651069d8237 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -23,7 +23,15 @@ }: let - linuxDesktopRuntimeDeps = [ + # By default, Flutter stores downloaded files (such as the Pub cache) in the SDK directory. + # Wrap it to ensure that it does not do that, preferring home directories instead. + immutableFlutter = writeShellScript "flutter_immutable" '' + export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"} + ${flutter}/bin/flutter --no-version-check "$@" + ''; + + # Libraries that Flutter apps depend on at runtime. + appRuntimeDeps = lib.optionals supportsLinuxDesktop [ atk cairo gdk-pixbuf @@ -36,19 +44,43 @@ let (callPackage ./packages/libdeflate { }) ]; - linuxDesktopBuildDeps = let - # https://discourse.nixos.org/t/handling-transitive-c-dependencies/5942/3 - deps = pkg: builtins.filter lib.isDerivation ((pkg.buildInputs or [ ]) ++ (pkg.propagatedBuildInputs or [ ])); - collect = pkg: lib.unique ([ pkg ] ++ deps pkg ++ builtins.concatMap collect (deps pkg)); - in builtins.concatMap collect linuxDesktopRuntimeDeps; + # Development packages required for compilation. + appBuildDeps = + let + # https://discourse.nixos.org/t/handling-transitive-c-dependencies/5942/3 + deps = pkg: builtins.filter lib.isDerivation ((pkg.buildInputs or [ ]) ++ (pkg.propagatedBuildInputs or [ ])); + collect = pkg: lib.unique ([ pkg ] ++ deps pkg ++ builtins.concatMap collect (deps pkg)); + in + builtins.concatMap collect appRuntimeDeps; + + # Some header files are not properly located by the Flutter SDK. + # They must be manually included. + appStaticBuildDeps = lib.optionals supportsLinuxDesktop [ libX11 xorgproto ]; + + # Some runtime components are prebuilt, and do not know where to find their dependencies. + # Ideally, these prebuilt components would be patched by the SDK derivation, but this + # is tricky as they are tyically downloaded from Google on-demand. + # Building the Engine manually should solve this issue: https://github.com/NixOS/nixpkgs/issues/201574 + appPrebuiltDeps = lib.optionals supportsLinuxDesktop [ + # flutter_linux_gtk.so + libepoxy + ]; + + # Tools used by the Flutter SDK to compile applications. + buildTools = lib.optionals supportsLinuxDesktop [ + pkg-config + cmake + ninja + clang + ]; + + # Nix-specific compiler configuration. + pkgConfigDirectories = builtins.filter builtins.pathExists (builtins.concatMap (pkg: map (dir: "${lib.getOutput "dev" pkg}/${dir}/pkgconfig") [ "lib" "share" ]) appBuildDeps); + cppFlags = map (pkg: "-isystem ${lib.getOutput "dev" pkg}/include") appStaticBuildDeps; + linkerFlags = map (pkg: "-rpath,${lib.getOutput "lib" pkg}/lib") appRuntimeDeps; in runCommandLocal "flutter" { - flutterWithCorrectedCache = writeShellScript "flutter_corrected_cache" '' - export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"} - ${flutter}/bin/flutter "$@" - ''; - buildInputs = [ makeWrapper ]; passthru = flutter.passthru // { @@ -62,26 +94,11 @@ runCommandLocal "flutter" mkdir -p $out/bin/cache/ ln -sf ${flutter.dart} $out/bin/cache/dart-sdk - makeWrapper "$flutterWithCorrectedCache" $out/bin/flutter \ - --set-default ANDROID_EMULATOR_USE_SYSTEM_LIBS 1 \ - --prefix PATH : '${lib.makeBinPath (lib.optionals supportsLinuxDesktop [ - pkg-config - cmake - ninja - clang - ])}' \ - --prefix PKG_CONFIG_PATH : '${ - let - makePkgConfigSearchPath = pkgs: builtins.concatStringsSep ":" (builtins.filter builtins.pathExists (builtins.concatMap (pkg: map (dir: "${lib.getOutput "dev" pkg}/${dir}/pkgconfig") [ "lib" "share" ]) pkgs)); - in makePkgConfigSearchPath linuxDesktopBuildDeps}' \ - --prefix CXXFLAGS "''\t" '${lib.optionalString supportsLinuxDesktop "-isystem ${libX11.dev}/include -isystem ${xorgproto}/include"}' \ - ${let linkerFlags = map (pkg: "-rpath,${lib.getOutput "lib" pkg}/lib") (lib.optionals supportsLinuxDesktop linuxDesktopRuntimeDeps); in '' - --prefix LDFLAGS "''\t" '${builtins.concatStringsSep " " (map (flag: "-Wl,${flag}") linkerFlags)}' \ - ''} \ - --suffix LD_LIBRARY_PATH : '${lib.optionalString supportsLinuxDesktop (lib.makeLibraryPath [ - # The prebuilt flutter_linux_gtk library shipped in the Flutter SDK does not have an appropriate RUNPATH. - # Its dependencies must be added here. - libepoxy - ])}' \ - --add-flags --no-version-check + makeWrapper '${immutableFlutter}' $out/bin/flutter \ + --set-default ANDROID_EMULATOR_USE_SYSTEM_LIBS 1 \ + --prefix PATH : '${lib.makeBinPath buildTools}' \ + --prefix PKG_CONFIG_PATH : '${builtins.concatStringsSep ":" pkgConfigDirectories}' \ + --prefix CXXFLAGS "''\t" '${builtins.concatStringsSep " " cppFlags}' \ + --prefix LDFLAGS "''\t" '${builtins.concatStringsSep " " (map (flag: "-Wl,${flag}") linkerFlags)}' \ + --suffix LD_LIBRARY_PATH : '${lib.makeLibraryPath appPrebuiltDeps}' '' -- cgit 1.4.1 From 341fa709ffca3d4c850e64bbbaec5d2a93c234fb Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sat, 18 Feb 2023 00:43:17 +1100 Subject: flutter: Redesign wrapping architecture The following principles are now in place: - All wrappers will include SDK file symlinks. There is not much of a reason to not do so, and removing the option to omit it makes it easier to understand what each wrapper does. - There is no longer a way to get the previous derivation from a wrapper. This could yield unexpected results based on the wrapping order. Instead, "sdk", "unwrapped", and "noFHS" passthru attributes are provided where appropriate. --- pkgs/development/compilers/flutter/default.nix | 3 +- pkgs/development/compilers/flutter/fake-sdk.nix | 15 -- pkgs/development/compilers/flutter/fhs.nix | 126 ++++++++-------- pkgs/development/compilers/flutter/flutter.nix | 164 +++++++++++---------- pkgs/development/compilers/flutter/sdk-symlink.nix | 24 +++ pkgs/development/compilers/flutter/wrapper.nix | 8 +- 6 files changed, 179 insertions(+), 161 deletions(-) delete mode 100644 pkgs/development/compilers/flutter/fake-sdk.nix create mode 100644 pkgs/development/compilers/flutter/sdk-symlink.nix diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix index ab91e946cbbd7..50752b01ec7b7 100644 --- a/pkgs/development/compilers/flutter/default.nix +++ b/pkgs/development/compilers/flutter/default.nix @@ -3,7 +3,6 @@ let mkFlutter = opts: callPackage (import ./flutter.nix opts) { }; wrapFlutter = flutter: callPackage (import ./wrapper.nix) { flutter = flutter; }; mkFlutterFHS = flutter: callPackage (import ./fhs.nix) { flutter = flutter; }; - mkFakeSdk = flutter: callPackage (import ./fake-sdk.nix) { flutter = flutter; }; getPatches = dir: let files = builtins.attrNames (builtins.readDir dir); in map (f: dir + ("/" + f)) files; @@ -29,7 +28,7 @@ let }; in { - inherit mkFlutter wrapFlutter mkFlutterFHS mkFakeSdk flutterDrv; + inherit mkFlutter wrapFlutter mkFlutterFHS flutterDrv; stable = flutterDrv { version = "3.3.3"; dartVersion = "2.18.2"; diff --git a/pkgs/development/compilers/flutter/fake-sdk.nix b/pkgs/development/compilers/flutter/fake-sdk.nix deleted file mode 100644 index e540cf1fa1c4f..0000000000000 --- a/pkgs/development/compilers/flutter/fake-sdk.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ flutter, symlinkJoin }: - -symlinkJoin { - name = "flutter-fake-${flutter.name}"; - paths = [ flutter flutter.unwrapped ]; - - inherit (flutter) passthru; - - meta = flutter.meta // { - longDescription = '' - ${flutter.meta.longDescription} - Modified binaries are linked into the original SDK directory for use with tools that use the whole SDK. - ''; - }; -} diff --git a/pkgs/development/compilers/flutter/fhs.nix b/pkgs/development/compilers/flutter/fhs.nix index 9488e2724a77e..e89bddc977266 100644 --- a/pkgs/development/compilers/flutter/fhs.nix +++ b/pkgs/development/compilers/flutter/fhs.nix @@ -7,73 +7,77 @@ , supportsAndroidEmulator ? stdenv.isLinux }: -let - # Wrap flutter inside an fhs user env to allow execution of binary, - # like adb from $ANDROID_HOME or java from android-studio. - self = buildFHSUserEnv { - name = flutter.name; - multiPkgs = pkgs: with pkgs; ([ - # Flutter only use these certificates - (runCommandLocal "fedoracert" { } '' - mkdir -p $out/etc/pki/tls/ - ln -s ${cacert}/etc/ssl/certs $out/etc/pki/tls/certs - '') - zlib - ]); +# Wrap flutter inside an fhs user env to allow execution of binary, +# like adb from $ANDROID_HOME or java from android-studio. +(callPackage ./sdk-symlink.nix { }) (buildFHSUserEnv rec { + name = "${flutter.name}-fhs"; - targetPkgs = pkgs: with pkgs; ([ - flutter + multiPkgs = pkgs: with pkgs; ([ + # Flutter only use these certificates + (runCommandLocal "fedoracert" { } '' + mkdir -p $out/etc/pki/tls/ + ln -s ${cacert}/etc/ssl/certs $out/etc/pki/tls/certs + '') + zlib + ]); - # General ecosystem dependencies - bash - curl - git - unzip - which - xz + targetPkgs = pkgs: with pkgs; ([ + flutter - # flutter test requires this lib - libGLU - ] ++ lib.optional supportsAndroidEmulator [ - # for android emulator - alsa-lib - dbus - expat - libpulseaudio - libuuid - xorg.libX11 - xorg.libxcb - xorg.libXcomposite - xorg.libXcursor - xorg.libXdamage - xorg.libXext - xorg.libXfixes - xorg.libXi - xorg.libXrender - xorg.libXtst - libGL - nspr - nss - systemd - ]); + # General ecosystem dependencies + bash + curl + git + unzip + which + xz - runScript = "flutter"; + # flutter test requires this lib + libGLU + ] ++ lib.optional supportsAndroidEmulator [ + # for android emulator + alsa-lib + dbus + expat + libpulseaudio + libuuid + xorg.libX11 + xorg.libxcb + xorg.libXcomposite + xorg.libXcursor + xorg.libXdamage + xorg.libXext + xorg.libXfixes + xorg.libXi + xorg.libXrender + xorg.libXtst + libGL + nspr + nss + systemd + ]); - passthru = flutter.passthru // { - wrapped = flutter; - mkFlutterApp = callPackage ../../../build-support/flutter { - flutter = callPackage ./fhs.nix { supportsAndroidEmulator = false; }; - }; - fakeSdk = callPackage ./fake-sdk.nix { flutter = self; }; - }; + runScript = "flutter"; + + extraInstallCommands = '' + # By default, the derivation name is used as the binary name. + # This is not the desired behaviour in this case. + # https://github.com/NixOS/nixpkgs/blob/cb4536bf3606a7b6b54b69afe22ccd82e2906d92/pkgs/build-support/build-fhs-userenv/default.nix#L43 + mv $out/bin/${name} $out/bin/flutter + ''; - meta = flutter.meta // { - longDescription = '' - ${flutter.meta.longDescription} - Wrapped in a FHS environment to improve compatibility with internal tools and tools in the ecosystem. - ''; + passthru = flutter.passthru // { + nonFHS = flutter; + mkFlutterApp = callPackage ../../../build-support/flutter { + flutter = callPackage ./fhs.nix { supportsAndroidEmulator = false; }; }; }; -in -self + + meta = flutter.meta // { + longDescription = '' + ${flutter.meta.longDescription} + Wrapped in a FHS environment to improve compatibility with internal tools and tools in the ecosystem. + ''; + }; +}) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index 1cbbe66509eb5..6df6fe2ba13e1 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -10,80 +10,90 @@ , which }: -stdenv.mkDerivation { - name = "$flutter-${version}-unwrapped"; - - buildInputs = [ git ]; - - inherit src patches version; - - postPatch = '' - patchShebangs --build ./bin/ - ''; - - buildPhase = '' - export FLUTTER_ROOT="$(pwd)" - export FLUTTER_TOOLS_DIR="$FLUTTER_ROOT/packages/flutter_tools" - export SCRIPT_PATH="$FLUTTER_TOOLS_DIR/bin/flutter_tools.dart" - - export SNAPSHOT_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.snapshot" - export STAMP_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.stamp" - - export DART_SDK_PATH="${dart}" - - HOME=../.. # required for pub upgrade --offline, ~/.pub-cache - # path is relative otherwise it's replaced by /build/flutter - - pushd "$FLUTTER_TOOLS_DIR" - ${dart}/bin/dart pub get --offline - popd - - local revision="$(cd "$FLUTTER_ROOT"; git rev-parse HEAD)" - ${dart}/bin/dart --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.dart_tool/package_config.json" "$SCRIPT_PATH" - echo "$revision" > "$STAMP_PATH" - echo -n "${version}" > version - - rm -r bin/cache/{artifacts,dart-sdk,downloads} - rm bin/cache/*.stamp - ''; - - installPhase = '' - runHook preInstall - - mkdir -p $out - cp -r . $out - mkdir -p $out/bin/cache/ - ln -sf ${dart} $out/bin/cache/dart-sdk - - runHook postInstall - ''; - - doInstallCheck = true; - installCheckInputs = [ which ]; - installCheckPhase = '' - runHook preInstallCheck - - export HOME="$(mktemp -d)" - $out/bin/flutter config --android-studio-dir $HOME - $out/bin/flutter config --android-sdk $HOME - $out/bin/flutter --version | fgrep -q '${version}' - - runHook postInstallCheck - ''; - - passthru = { - inherit dart; - }; - - meta = with lib; { - description = "Flutter is Google's SDK for building mobile, web and desktop with Dart"; - longDescription = '' - Flutter is Google’s UI toolkit for building beautiful, - natively compiled applications for mobile, web, and desktop from a single codebase. - ''; - homepage = "https://flutter.dev"; - license = licenses.bsd3; - platforms = [ "x86_64-linux" "aarch64-linux" ]; - maintainers = with maintainers; [ babariviere ericdallo ]; - }; -} +let + self = + stdenv.mkDerivation { + name = "$flutter-${version}-unwrapped"; + + buildInputs = [ git ]; + + inherit src patches version; + + postPatch = '' + patchShebangs --build ./bin/ + ''; + + buildPhase = '' + export FLUTTER_ROOT="$(pwd)" + export FLUTTER_TOOLS_DIR="$FLUTTER_ROOT/packages/flutter_tools" + export SCRIPT_PATH="$FLUTTER_TOOLS_DIR/bin/flutter_tools.dart" + + export SNAPSHOT_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.snapshot" + export STAMP_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.stamp" + + export DART_SDK_PATH="${dart}" + + HOME=../.. # required for pub upgrade --offline, ~/.pub-cache + # path is relative otherwise it's replaced by /build/flutter + + pushd "$FLUTTER_TOOLS_DIR" + ${dart}/bin/dart pub get --offline + popd + + local revision="$(cd "$FLUTTER_ROOT"; git rev-parse HEAD)" + ${dart}/bin/dart --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.dart_tool/package_config.json" "$SCRIPT_PATH" + echo "$revision" > "$STAMP_PATH" + echo -n "${version}" > version + + rm -r bin/cache/{artifacts,dart-sdk,downloads} + rm bin/cache/*.stamp + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out + cp -r . $out + mkdir -p $out/bin/cache/ + ln -sf ${dart} $out/bin/cache/dart-sdk + + runHook postInstall + ''; + + doInstallCheck = true; + installCheckInputs = [ which ]; + installCheckPhase = '' + runHook preInstallCheck + + export HOME="$(mktemp -d)" + $out/bin/flutter config --android-studio-dir $HOME + $out/bin/flutter config --android-sdk $HOME + $out/bin/flutter --version | fgrep -q '${version}' + + runHook postInstallCheck + ''; + + passthru = { + inherit dart; + + # The derivation containing the original Flutter SDK files. + # When other derivations wrap this one, any unmodified files + # found here should be included as-is, for tooling compatibility. + sdk = self; + }; + + meta = with lib; { + description = "Flutter is Google's SDK for building mobile, web and desktop with Dart"; + longDescription = '' + Flutter is Google’s UI toolkit for building beautiful, + natively compiled applications for mobile, web, and desktop from a single codebase. + ''; + homepage = "https://flutter.dev"; + license = licenses.bsd3; + platforms = [ "x86_64-linux" "aarch64-linux" ]; + maintainers = with maintainers; [ babariviere ericdallo ]; + }; + } + ; +in +self diff --git a/pkgs/development/compilers/flutter/sdk-symlink.nix b/pkgs/development/compilers/flutter/sdk-symlink.nix new file mode 100644 index 0000000000000..6fb4f5edc0eeb --- /dev/null +++ b/pkgs/development/compilers/flutter/sdk-symlink.nix @@ -0,0 +1,24 @@ +{ symlinkJoin }: flutter: + +let + self = + symlinkJoin { + name = "${flutter.name}-sdk-links"; + paths = [ flutter flutter.sdk ]; + + passthru = flutter.passthru // { + # Update the SDK attribute. + # This allows any modified SDK files to be included + # in future invocations. + sdk = self; + }; + + meta = flutter.meta // { + longDescription = '' + ${flutter.meta.longDescription} + Modified binaries are linked into the original SDK directory for use with tools that use the whole SDK. + ''; + }; + }; +in +self diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index 63651069d8237..7b6fd464e35a4 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -79,7 +79,7 @@ let cppFlags = map (pkg: "-isystem ${lib.getOutput "dev" pkg}/include") appStaticBuildDeps; linkerFlags = map (pkg: "-rpath,${lib.getOutput "lib" pkg}/lib") appRuntimeDeps; in -runCommandLocal "flutter" +(callPackage ./sdk-symlink.nix { }) (runCommandLocal "flutter-wrapped" { buildInputs = [ makeWrapper ]; @@ -90,10 +90,6 @@ runCommandLocal "flutter" inherit (flutter) meta; } '' mkdir -p $out/bin - - mkdir -p $out/bin/cache/ - ln -sf ${flutter.dart} $out/bin/cache/dart-sdk - makeWrapper '${immutableFlutter}' $out/bin/flutter \ --set-default ANDROID_EMULATOR_USE_SYSTEM_LIBS 1 \ --prefix PATH : '${lib.makeBinPath buildTools}' \ @@ -101,4 +97,4 @@ runCommandLocal "flutter" --prefix CXXFLAGS "''\t" '${builtins.concatStringsSep " " cppFlags}' \ --prefix LDFLAGS "''\t" '${builtins.concatStringsSep " " (map (flag: "-Wl,${flag}") linkerFlags)}' \ --suffix LD_LIBRARY_PATH : '${lib.makeLibraryPath appPrebuiltDeps}' -'' +'') -- cgit 1.4.1 From 7840f2055a183e93ac69e73b5fc63fcfa9c47a18 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 00:09:42 +1000 Subject: flutter: Create the flutter derivation with callPackage alone --- pkgs/development/compilers/flutter/default.nix | 6 +++--- pkgs/development/compilers/flutter/flutter.nix | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix index 50752b01ec7b7..0b44460fe0485 100644 --- a/pkgs/development/compilers/flutter/default.nix +++ b/pkgs/development/compilers/flutter/default.nix @@ -1,8 +1,8 @@ { callPackage, fetchurl, dart }: let - mkFlutter = opts: callPackage (import ./flutter.nix opts) { }; - wrapFlutter = flutter: callPackage (import ./wrapper.nix) { flutter = flutter; }; - mkFlutterFHS = flutter: callPackage (import ./fhs.nix) { flutter = flutter; }; + mkFlutter = { version, patches, dart, src }: callPackage ./flutter.nix { inherit version patches dart src; }; + wrapFlutter = flutter: callPackage ./wrapper.nix { inherit flutter; }; + mkFlutterFHS = flutter: callPackage ./fhs.nix { inherit flutter; }; getPatches = dir: let files = builtins.attrNames (builtins.readDir dir); in map (f: dir + ("/" + f)) files; diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index 6df6fe2ba13e1..bd59edb8516c9 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -2,9 +2,8 @@ , patches , dart , src -}: -{ lib +, lib , git , stdenv , which -- cgit 1.4.1 From cda91ab26974f5848ec919142855872695b1f994 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 02:40:44 +1000 Subject: flutter: Add cache output and preload pub cache when necessary Co-authored-by: FlafyDev Co-authored-by: gilice Co-authored-by: hacker1024 --- pkgs/development/compilers/flutter/flutter.nix | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index bd59edb8516c9..8192184108fcc 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -13,10 +13,11 @@ let self = stdenv.mkDerivation { name = "$flutter-${version}-unwrapped"; + inherit src patches version; - buildInputs = [ git ]; + outputs = [ "out" "cache" ]; - inherit src patches version; + buildInputs = [ git ]; postPatch = '' patchShebangs --build ./bin/ @@ -32,8 +33,23 @@ let export DART_SDK_PATH="${dart}" - HOME=../.. # required for pub upgrade --offline, ~/.pub-cache - # path is relative otherwise it's replaced by /build/flutter + # The Flutter tool compilation requires dependencies to be cached, as there is no Internet access. + # Dart expects package caches to be mutable, and does not support composing cache directories. + # The packages cached during the build therefore cannot be easily used. They are provided through + # the derivation's "cache" output, though, in case they are needed. + # + # Note that non-cached packages will normally be fetched from the Internet when they are needed, so Flutter + # will function without an existing package cache as long as it has an Internet connection. + export PUB_CACHE="$cache" + + if [ -d .pub-preload-cache ]; then + ${dart}/bin/dart pub cache preload .pub-preload-cache/* + elif [ -d .pub-cache ]; then + mv .pub-cache "$PUB_CACHE" + else + echo 'ERROR: Failed to locate the Dart package cache required to build the Flutter tool.' + exit 1 + fi pushd "$FLUTTER_TOOLS_DIR" ${dart}/bin/dart pub get --offline -- cgit 1.4.1 From 65708c3360e6b2a01f42d2784f36983908e2c706 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 14:53:17 +1000 Subject: flutter: Don't delete SDK artifacts Co-authored-by: FlafyDev Co-authored-by: gilice Co-authored-by: hacker1024 --- pkgs/development/compilers/flutter/flutter.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index 8192184108fcc..de6f293067655 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -60,8 +60,7 @@ let echo "$revision" > "$STAMP_PATH" echo -n "${version}" > version - rm -r bin/cache/{artifacts,dart-sdk,downloads} - rm bin/cache/*.stamp + rm -r bin/cache/dart-sdk ''; installPhase = '' -- cgit 1.4.1 From 94a34aadf6d3f7a78cad181a555d4d162a7e7914 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 16:14:22 +1000 Subject: flutter: Use autoPatchelfHook for SDK artifacts This allows SDK artifacts (including build tools and libraries) to use the right interpreter and library locations, abolishing the need for a FHS or post-build patches. `autoPatchelf` has been used through `autoPatchelfHook`, instead of the `autoPatchelf` command on just the artifact directory, due to the latter method not patching interpreter paths (https://discourse.nixos.org/t/trying-to-use-autopatchelf/24003). Co-authored-by: FlafyDev Co-authored-by: gilice Co-authored-by: hacker1024 --- pkgs/development/compilers/flutter/flutter.nix | 18 ++++++++++++++++-- pkgs/development/compilers/flutter/wrapper.nix | 3 +-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index de6f293067655..dd76600edb5f1 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -4,12 +4,25 @@ , src , lib -, git , stdenv +, autoPatchelfHook +, git , which +, atk +, glib +, gtk3 +, libepoxy }: let + # Libraries that Flutter artifacts depend on at runtime. + artifactRuntimeDeps = [ + atk + glib + gtk3 + libepoxy + ]; + self = stdenv.mkDerivation { name = "$flutter-${version}-unwrapped"; @@ -17,7 +30,8 @@ let outputs = [ "out" "cache" ]; - buildInputs = [ git ]; + nativeBuildInputs = [ autoPatchelfHook ]; + buildInputs = [ git ] ++ artifactRuntimeDeps; postPatch = '' patchShebangs --build ./bin/ diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index 7b6fd464e35a4..7d7747217ad09 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -95,6 +95,5 @@ in --prefix PATH : '${lib.makeBinPath buildTools}' \ --prefix PKG_CONFIG_PATH : '${builtins.concatStringsSep ":" pkgConfigDirectories}' \ --prefix CXXFLAGS "''\t" '${builtins.concatStringsSep " " cppFlags}' \ - --prefix LDFLAGS "''\t" '${builtins.concatStringsSep " " (map (flag: "-Wl,${flag}") linkerFlags)}' \ - --suffix LD_LIBRARY_PATH : '${lib.makeLibraryPath appPrebuiltDeps}' + --prefix LDFLAGS "''\t" '${builtins.concatStringsSep " " (map (flag: "-Wl,${flag}") linkerFlags)}' '') -- cgit 1.4.1 From 9e33e35589ac026ba535c8d8e68a6e66beeac048 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 16:15:08 +1000 Subject: flutter: Add zlib to the linker search path --- pkgs/development/compilers/flutter/wrapper.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index 7d7747217ad09..b9341bdb1b16c 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -17,6 +17,7 @@ , pango , libX11 , xorgproto +, zlib , cmake , ninja , clang @@ -53,9 +54,9 @@ let in builtins.concatMap collect appRuntimeDeps; - # Some header files are not properly located by the Flutter SDK. + # Some header files and libraries are not properly located by the Flutter SDK. # They must be manually included. - appStaticBuildDeps = lib.optionals supportsLinuxDesktop [ libX11 xorgproto ]; + appStaticBuildDeps = lib.optionals supportsLinuxDesktop [ libX11 xorgproto zlib ]; # Some runtime components are prebuilt, and do not know where to find their dependencies. # Ideally, these prebuilt components would be patched by the SDK derivation, but this @@ -94,6 +95,7 @@ in --set-default ANDROID_EMULATOR_USE_SYSTEM_LIBS 1 \ --prefix PATH : '${lib.makeBinPath buildTools}' \ --prefix PKG_CONFIG_PATH : '${builtins.concatStringsSep ":" pkgConfigDirectories}' \ + --prefix LIBRARY_PATH : '${lib.makeLibraryPath appStaticBuildDeps}' \ --prefix CXXFLAGS "''\t" '${builtins.concatStringsSep " " cppFlags}' \ --prefix LDFLAGS "''\t" '${builtins.concatStringsSep " " (map (flag: "-Wl,${flag}") linkerFlags)}' '') -- cgit 1.4.1 From e5529593957fae3006388b08826651ec9993af1e Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 16:37:12 +1000 Subject: flutter: Remove the FHS wrapper Now that Flutter artifacts are patched, there is no need for a FHS at runtime or any stage of the build process. Those relying on it for the Android SDK should look at https://github.com/tadfisher/android-nixpkgs. --- pkgs/development/compilers/flutter/default.nix | 3 +- pkgs/development/compilers/flutter/fhs.nix | 83 -------------------------- pkgs/top-level/all-packages.nix | 6 +- 3 files changed, 3 insertions(+), 89 deletions(-) delete mode 100644 pkgs/development/compilers/flutter/fhs.nix diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix index 0b44460fe0485..6c34ef440243a 100644 --- a/pkgs/development/compilers/flutter/default.nix +++ b/pkgs/development/compilers/flutter/default.nix @@ -2,7 +2,6 @@ let mkFlutter = { version, patches, dart, src }: callPackage ./flutter.nix { inherit version patches dart src; }; wrapFlutter = flutter: callPackage ./wrapper.nix { inherit flutter; }; - mkFlutterFHS = flutter: callPackage ./fhs.nix { inherit flutter; }; getPatches = dir: let files = builtins.attrNames (builtins.readDir dir); in map (f: dir + ("/" + f)) files; @@ -28,7 +27,7 @@ let }; in { - inherit mkFlutter wrapFlutter mkFlutterFHS flutterDrv; + inherit mkFlutter wrapFlutter flutterDrv; stable = flutterDrv { version = "3.3.3"; dartVersion = "2.18.2"; diff --git a/pkgs/development/compilers/flutter/fhs.nix b/pkgs/development/compilers/flutter/fhs.nix deleted file mode 100644 index e89bddc977266..0000000000000 --- a/pkgs/development/compilers/flutter/fhs.nix +++ /dev/null @@ -1,83 +0,0 @@ -{ lib -, stdenv -, callPackage -, flutter -, buildFHSUserEnv -, runCommandLocal -, supportsAndroidEmulator ? stdenv.isLinux -}: - - -# Wrap flutter inside an fhs user env to allow execution of binary, -# like adb from $ANDROID_HOME or java from android-studio. -(callPackage ./sdk-symlink.nix { }) (buildFHSUserEnv rec { - name = "${flutter.name}-fhs"; - - multiPkgs = pkgs: with pkgs; ([ - # Flutter only use these certificates - (runCommandLocal "fedoracert" { } '' - mkdir -p $out/etc/pki/tls/ - ln -s ${cacert}/etc/ssl/certs $out/etc/pki/tls/certs - '') - zlib - ]); - - targetPkgs = pkgs: with pkgs; ([ - flutter - - # General ecosystem dependencies - bash - curl - git - unzip - which - xz - - # flutter test requires this lib - libGLU - ] ++ lib.optional supportsAndroidEmulator [ - # for android emulator - alsa-lib - dbus - expat - libpulseaudio - libuuid - xorg.libX11 - xorg.libxcb - xorg.libXcomposite - xorg.libXcursor - xorg.libXdamage - xorg.libXext - xorg.libXfixes - xorg.libXi - xorg.libXrender - xorg.libXtst - libGL - nspr - nss - systemd - ]); - - runScript = "flutter"; - - extraInstallCommands = '' - # By default, the derivation name is used as the binary name. - # This is not the desired behaviour in this case. - # https://github.com/NixOS/nixpkgs/blob/cb4536bf3606a7b6b54b69afe22ccd82e2906d92/pkgs/build-support/build-fhs-userenv/default.nix#L43 - mv $out/bin/${name} $out/bin/flutter - ''; - - passthru = flutter.passthru // { - nonFHS = flutter; - mkFlutterApp = callPackage ../../../build-support/flutter { - flutter = callPackage ./fhs.nix { supportsAndroidEmulator = false; }; - }; - }; - - meta = flutter.meta // { - longDescription = '' - ${flutter.meta.longDescription} - Wrapped in a FHS environment to improve compatibility with internal tools and tools in the ecosystem. - ''; - }; -}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 91e81acf393ab..12fbbf2bfbe09 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -13701,10 +13701,8 @@ with pkgs; recurseIntoAttrs (callPackage ../development/compilers/flutter { }); flutter-unwrapped = flutterPackages.stable; flutter2-unwrapped = flutterPackages.v2; - flutter-wrapped = flutterPackages.wrapFlutter flutter-unwrapped; - flutter2-wrapped = flutterPackages.wrapFlutter flutter2-unwrapped; - flutter = flutterPackages.mkFlutterFHS flutter-wrapped; - flutter2 = flutterPackages.mkFlutterFHS flutter2-wrapped; + flutter = flutterPackages.wrapFlutter flutter-unwrapped; + flutter2 = flutterPackages.wrapFlutter flutter2-unwrapped; fnm = callPackage ../development/tools/fnm { inherit (darwin.apple_sdk.frameworks) DiskArbitration Foundation Security; -- cgit 1.4.1 From d6ce0dafcfccbd2c93c3af9428671384deeb05b8 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 16:53:48 +1000 Subject: flutter: Don't use an external artifact cache The internal artifacts should be used, as they have been patched to use Nix libraries. Co-authored-by: FlafyDev Co-authored-by: gilice Co-authored-by: hacker1024 --- .../flutter/patches/flutter2/move-cache.patch | 41 +----- .../flutter/patches/flutter3/move-cache.patch | 161 --------------------- 2 files changed, 3 insertions(+), 199 deletions(-) diff --git a/pkgs/development/compilers/flutter/patches/flutter2/move-cache.patch b/pkgs/development/compilers/flutter/patches/flutter2/move-cache.patch index a81d2def242c9..efab81d2fc0ed 100644 --- a/pkgs/development/compilers/flutter/patches/flutter2/move-cache.patch +++ b/pkgs/development/compilers/flutter/patches/flutter2/move-cache.patch @@ -1,31 +1,5 @@ -diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart -index ed42baea29..12941f733a 100644 ---- a/packages/flutter_tools/lib/src/asset.dart -+++ b/packages/flutter_tools/lib/src/asset.dart -@@ -11,11 +11,11 @@ import 'base/file_system.dart'; - import 'base/logger.dart'; - import 'base/platform.dart'; - import 'build_info.dart'; --import 'cache.dart'; - import 'convert.dart'; - import 'dart/package_map.dart'; - import 'devfs.dart'; - import 'flutter_manifest.dart'; -+import 'globals.dart' as globals; - import 'license_collector.dart'; - import 'project.dart'; - -@@ -504,7 +504,7 @@ class ManifestAssetBundle implements AssetBundle { - } - final Uri entryUri = _fileSystem.path.toUri(asset); - result.add(_Asset( -- baseDir: _fileSystem.path.join(Cache.flutterRoot!, 'bin', 'cache', 'artifacts', 'material_fonts'), -+ baseDir: _fileSystem.path.join(globals.fsUtils.homeDirPath!, '.cache', 'flutter', 'artifacts', 'material_fonts'), - relativeUri: Uri(path: entryUri.pathSegments.last), - entryUri: entryUri, - package: null, diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart -index defc86cc20..7fdf14d112 100644 +index dd80b1e46e..8e54517765 100644 --- a/packages/flutter_tools/lib/src/cache.dart +++ b/packages/flutter_tools/lib/src/cache.dart @@ -22,6 +22,7 @@ import 'base/user_messages.dart'; @@ -36,7 +10,7 @@ index defc86cc20..7fdf14d112 100644 const String kFlutterRootEnvironmentVariableName = 'FLUTTER_ROOT'; // should point to //flutter/ (root of flutter/flutter repo) const String kFlutterEngineEnvironmentVariableName = 'FLUTTER_ENGINE'; // should point to //engine/src/ (root of flutter/engine repo) -@@ -322,8 +323,13 @@ class Cache { +@@ -318,8 +319,13 @@ class Cache { return; } assert(_lock == null); @@ -51,7 +25,7 @@ index defc86cc20..7fdf14d112 100644 try { _lock = lockFile.openSync(mode: FileMode.write); } on FileSystemException catch (e) { -@@ -382,8 +388,7 @@ class Cache { +@@ -378,8 +384,7 @@ class Cache { String get devToolsVersion { if (_devToolsVersion == null) { @@ -61,12 +35,3 @@ index defc86cc20..7fdf14d112 100644 if (!devToolsDir.existsSync()) { throw Exception('Could not find directory at ${devToolsDir.path}'); } -@@ -536,7 +541,7 @@ class Cache { - if (_rootOverride != null) { - return _fileSystem.directory(_fileSystem.path.join(_rootOverride!.path, 'bin', 'cache')); - } else { -- return _fileSystem.directory(_fileSystem.path.join(flutterRoot!, 'bin', 'cache')); -+ return _fileSystem.directory(_fileSystem.path.join(globals.fsUtils.homeDirPath!, '.cache', 'flutter')); - } - } - diff --git a/pkgs/development/compilers/flutter/patches/flutter3/move-cache.patch b/pkgs/development/compilers/flutter/patches/flutter3/move-cache.patch index 008c5959e5b9b..efab81d2fc0ed 100644 --- a/pkgs/development/compilers/flutter/patches/flutter3/move-cache.patch +++ b/pkgs/development/compilers/flutter/patches/flutter3/move-cache.patch @@ -1,26 +1,3 @@ -diff --git a/packages/flutter_tools/lib/src/artifacts.dart b/packages/flutter_tools/lib/src/artifacts.dart -diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart -index 9dd7272fbe..642c8e48e4 100644 ---- a/packages/flutter_tools/lib/src/asset.dart -+++ b/packages/flutter_tools/lib/src/asset.dart -@@ -16,6 +16,7 @@ import 'convert.dart'; - import 'dart/package_map.dart'; - import 'devfs.dart'; - import 'flutter_manifest.dart'; -+import 'globals.dart' as globals; - import 'license_collector.dart'; - import 'project.dart'; - -@@ -530,8 +531,7 @@ class ManifestAssetBundle implements AssetBundle { - final Uri entryUri = _fileSystem.path.toUri(asset); - result.add(_Asset( - baseDir: _fileSystem.path.join( -- Cache.flutterRoot!, -- 'bin', 'cache', 'artifacts', 'material_fonts', -+ globals.fsUtils.homeDirPath!, '.cache', 'flutter', 'artifacts', 'material_fonts', - ), - relativeUri: Uri(path: entryUri.pathSegments.last), - entryUri: entryUri, diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart index dd80b1e46e..8e54517765 100644 --- a/packages/flutter_tools/lib/src/cache.dart @@ -58,141 +35,3 @@ index dd80b1e46e..8e54517765 100644 if (!devToolsDir.existsSync()) { throw Exception('Could not find directory at ${devToolsDir.path}'); } -@@ -532,7 +537,7 @@ class Cache { - if (_rootOverride != null) { - return _fileSystem.directory(_fileSystem.path.join(_rootOverride!.path, 'bin', 'cache')); - } else { -- return _fileSystem.directory(_fileSystem.path.join(flutterRoot!, 'bin', 'cache')); -+ return _fileSystem.directory(_fileSystem.path.join(globals.fsUtils.homeDirPath!, '.cache', 'flutter')); - } - } - -index c539d67156..4e0a64f7a9 100644 ---- a/packages/flutter_tools/lib/src/artifacts.dart -+++ b/packages/flutter_tools/lib/src/artifacts.dart -@@ -346,10 +346,10 @@ class CachedArtifacts implements Artifacts { - ) { - switch (artifact) { - case HostArtifact.engineDartSdkPath: -- final String path = _dartSdkPath(_cache); -+ final String path = _dartSdkPath(_fileSystem); - return _fileSystem.directory(path); - case HostArtifact.engineDartBinary: -- final String path = _fileSystem.path.join(_dartSdkPath(_cache), 'bin', _hostArtifactToFileName(artifact, _platform)); -+ final String path = _fileSystem.path.join(_dartSdkPath(_fileSystem), 'bin', _hostArtifactToFileName(artifact, _platform)); - return _fileSystem.file(path); - case HostArtifact.flutterWebSdk: - final String path = _getFlutterWebSdkPath(); -@@ -398,7 +398,7 @@ class CachedArtifacts implements Artifacts { - case HostArtifact.dart2jsSnapshot: - case HostArtifact.dartdevcSnapshot: - case HostArtifact.kernelWorkerSnapshot: -- final String path = _fileSystem.path.join(_dartSdkPath(_cache), 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform)); -+ final String path = _fileSystem.path.join(_dartSdkPath(_fileSystem), 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform)); - return _fileSystem.file(path); - case HostArtifact.iosDeploy: - final String artifactFileName = _hostArtifactToFileName(artifact, _platform); -@@ -465,11 +465,13 @@ class CachedArtifacts implements Artifacts { - String _getAndroidArtifactPath(Artifact artifact, TargetPlatform platform, BuildMode mode) { - final String engineDir = _getEngineArtifactsPath(platform, mode)!; - switch (artifact) { -+ case Artifact.frontendServerSnapshotForEngineDartSdk: -+ assert(mode != BuildMode.debug, 'Artifact $artifact only available in non-debug mode.'); -+ return _fileSystem.path.join(engineDir, _artifactToFileName(artifact)); - case Artifact.genSnapshot: - assert(mode != BuildMode.debug, 'Artifact $artifact only available in non-debug mode.'); - final String hostPlatform = getNameForHostPlatform(getCurrentHostPlatform()); - return _fileSystem.path.join(engineDir, hostPlatform, _artifactToFileName(artifact)); -- case Artifact.frontendServerSnapshotForEngineDartSdk: - case Artifact.constFinder: - case Artifact.flutterFramework: - case Artifact.flutterMacOSFramework: -@@ -497,13 +499,13 @@ class CachedArtifacts implements Artifacts { - switch (artifact) { - case Artifact.genSnapshot: - case Artifact.flutterXcframework: -+ case Artifact.frontendServerSnapshotForEngineDartSdk: - final String artifactFileName = _artifactToFileName(artifact)!; - final String engineDir = _getEngineArtifactsPath(platform, mode)!; - return _fileSystem.path.join(engineDir, artifactFileName); - case Artifact.flutterFramework: - final String engineDir = _getEngineArtifactsPath(platform, mode)!; - return _getIosEngineArtifactPath(engineDir, environmentType, _fileSystem); -- case Artifact.frontendServerSnapshotForEngineDartSdk: - case Artifact.constFinder: - case Artifact.flutterMacOSFramework: - case Artifact.flutterPatchedSdkPath: -@@ -586,14 +588,10 @@ class CachedArtifacts implements Artifacts { - // For script snapshots any gen_snapshot binary will do. Returning gen_snapshot for - // android_arm in profile mode because it is available on all supported host platforms. - return _getAndroidArtifactPath(artifact, TargetPlatform.android_arm, BuildMode.profile); -- case Artifact.frontendServerSnapshotForEngineDartSdk: -- return _fileSystem.path.join( -- _dartSdkPath(_cache), 'bin', 'snapshots', -- _artifactToFileName(artifact), -- ); - case Artifact.flutterTester: - case Artifact.vmSnapshotData: - case Artifact.isolateSnapshotData: -+ case Artifact.frontendServerSnapshotForEngineDartSdk: - case Artifact.icuData: - final String engineArtifactsPath = _cache.getArtifactDirectory('engine').path; - final String platformDirName = _enginePlatformDirectoryName(platform); -@@ -776,7 +774,7 @@ class CachedLocalEngineArtifacts implements LocalEngineArtifacts { - final String path = _fileSystem.path.join(_hostEngineOutPath, 'dart-sdk', 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform)); - return _fileSystem.file(path); - case HostArtifact.dartdevcSnapshot: -- final String path = _fileSystem.path.join(_dartSdkPath(_cache), 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform)); -+ final String path = _fileSystem.path.join(_dartSdkPath(_fileSystem), 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform)); - return _fileSystem.file(path); - case HostArtifact.kernelWorkerSnapshot: - final String path = _fileSystem.path.join(_hostEngineOutPath, 'dart-sdk', 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform)); -@@ -901,9 +899,7 @@ class CachedLocalEngineArtifacts implements LocalEngineArtifacts { - case Artifact.windowsCppClientWrapper: - return _fileSystem.path.join(_hostEngineOutPath, artifactFileName); - case Artifact.frontendServerSnapshotForEngineDartSdk: -- return _fileSystem.path.join( -- _hostEngineOutPath, 'dart-sdk', 'bin', 'snapshots', artifactFileName, -- ); -+ return _fileSystem.path.join(_hostEngineOutPath, 'gen', artifactFileName); - } - } - -@@ -1011,8 +1007,8 @@ class OverrideArtifacts implements Artifacts { - } - - /// Locate the Dart SDK. --String _dartSdkPath(Cache cache) { -- return cache.getRoot().childDirectory('dart-sdk').path; -+String _dartSdkPath(FileSystem fileSystem) { -+ return fileSystem.path.join(Cache.flutterRoot!, 'bin', 'cache', 'dart-sdk'); - } - - class _TestArtifacts implements Artifacts { -diff --git a/packages/flutter_tools/test/general.shard/artifacts_test.dart b/packages/flutter_tools/test/general.shard/artifacts_test.dart -index aed3eb9285..81b8362648 100644 ---- a/packages/flutter_tools/test/general.shard/artifacts_test.dart -+++ b/packages/flutter_tools/test/general.shard/artifacts_test.dart -@@ -141,10 +141,6 @@ void main() { - artifacts.getArtifactPath(Artifact.flutterTester, platform: TargetPlatform.linux_arm64), - fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'linux-arm64', 'flutter_tester'), - ); -- expect( -- artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), -- fileSystem.path.join('root', 'bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'frontend_server.dart.snapshot') -- ); - }); - - testWithoutContext('precompiled web artifact paths are correct', () { -@@ -310,11 +306,6 @@ void main() { - artifacts.getHostArtifact(HostArtifact.engineDartSdkPath).path, - fileSystem.path.join('/out', 'host_debug_unopt', 'dart-sdk'), - ); -- expect( -- artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), -- fileSystem.path.join('/out', 'host_debug_unopt', 'dart-sdk', 'bin', -- 'snapshots', 'frontend_server.dart.snapshot') -- ); - expect( - artifacts.getHostArtifact(HostArtifact.impellerc).path, - fileSystem.path.join('/out', 'host_debug_unopt', 'impellerc'), -- cgit 1.4.1 From 9497627b15ce079b0fb89fff46220bfbdfd3b510 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 16:54:19 +1000 Subject: flutter: Don't try to update the immutable artifact cache Co-authored-by: FlafyDev Co-authored-by: gilice Co-authored-by: hacker1024 --- .../flutter/patches/flutter2/disable-auto-update.patch | 13 +++++++++++++ .../flutter/patches/flutter3/disable-auto-update.patch | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/pkgs/development/compilers/flutter/patches/flutter2/disable-auto-update.patch b/pkgs/development/compilers/flutter/patches/flutter2/disable-auto-update.patch index e799f6e1550b5..33805b7a54d25 100644 --- a/pkgs/development/compilers/flutter/patches/flutter2/disable-auto-update.patch +++ b/pkgs/development/compilers/flutter/patches/flutter2/disable-auto-update.patch @@ -34,3 +34,16 @@ index 396756808e..d324a6df59 100644 // See if the user specified a specific device. globals.deviceManager?.specifiedDeviceId = topLevelResults['device-id'] as String?; + +diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart +index defc86cc20..6c0824c965 100644 +--- a/packages/flutter_tools/lib/src/cache.dart ++++ b/packages/flutter_tools/lib/src/cache.dart +@@ -666,6 +666,7 @@ class Cache { + + /// Update the cache to contain all `requiredArtifacts`. + Future updateAll(Set requiredArtifacts) async { ++ return; + if (!_lockEnabled) { + return; + } diff --git a/pkgs/development/compilers/flutter/patches/flutter3/disable-auto-update.patch b/pkgs/development/compilers/flutter/patches/flutter3/disable-auto-update.patch index 21b676a2af390..8746190461343 100644 --- a/pkgs/development/compilers/flutter/patches/flutter3/disable-auto-update.patch +++ b/pkgs/development/compilers/flutter/patches/flutter3/disable-auto-update.patch @@ -34,3 +34,16 @@ index 738fef987d..03a152e64f 100644 // See if the user specified a specific device. globals.deviceManager?.specifiedDeviceId = topLevelResults['device-id'] as String?; + +diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart +index dd80b1e46e..8e54517765 100644 +--- a/packages/flutter_tools/lib/src/cache.dart ++++ b/packages/flutter_tools/lib/src/cache.dart +@@ -668,6 +668,7 @@ + + /// Update the cache to contain all `requiredArtifacts`. + Future updateAll(Set requiredArtifacts, {bool offline = false}) async { ++ return; + if (!_lockEnabled) { + return; + } -- cgit 1.4.1 From 7f01352e6513ea425d8ed026445f24f7234a8502 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 17:08:58 +1000 Subject: flutter: Don't preserve prebuilt SDK asset file permissions See: https://github.com/flutter/flutter/issues/119961 Co-authored-by: FlafyDev Co-authored-by: gilice Co-authored-by: hacker1024 --- .../flutter/patches/flutter2/copy-without-perms.patch | 17 +++++++++++++++++ .../flutter/patches/flutter3/copy-without-perms.patch | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 pkgs/development/compilers/flutter/patches/flutter2/copy-without-perms.patch create mode 100644 pkgs/development/compilers/flutter/patches/flutter3/copy-without-perms.patch diff --git a/pkgs/development/compilers/flutter/patches/flutter2/copy-without-perms.patch b/pkgs/development/compilers/flutter/patches/flutter2/copy-without-perms.patch new file mode 100644 index 0000000000000..f262f04bc9454 --- /dev/null +++ b/pkgs/development/compilers/flutter/patches/flutter2/copy-without-perms.patch @@ -0,0 +1,17 @@ +diff --git a/packages/flutter_tools/lib/src/build_system/targets/assets.dart b/packages/flutter_tools/lib/src/build_system/targets/assets.dart +index 68a4cd0257..1e212b9b0d 100644 +--- a/packages/flutter_tools/lib/src/build_system/targets/assets.dart ++++ b/packages/flutter_tools/lib/src/build_system/targets/assets.dart +@@ -101,7 +101,11 @@ Future copyAssets(Environment environment, Directory outputDirectory, { + outputPath: file.path, + relativePath: entry.key, + )) { +- await (content.file as File).copy(file.path); ++ // Not using File.copy because it preserves permissions. ++ final sourceFile = content.file as File; ++ final destinationFile = file; ++ ++ await destinationFile.writeAsBytes(await sourceFile.readAsBytes(), flush: true); + } + } else { + await file.writeAsBytes(await entry.value.contentsAsBytes()); diff --git a/pkgs/development/compilers/flutter/patches/flutter3/copy-without-perms.patch b/pkgs/development/compilers/flutter/patches/flutter3/copy-without-perms.patch new file mode 100644 index 0000000000000..281b3840891fb --- /dev/null +++ b/pkgs/development/compilers/flutter/patches/flutter3/copy-without-perms.patch @@ -0,0 +1,17 @@ +diff --git a/packages/flutter_tools/lib/src/build_system/targets/assets.dart b/packages/flutter_tools/lib/src/build_system/targets/assets.dart +index 5f458bd53e..7a6c59f98d 100644 +--- a/packages/flutter_tools/lib/src/build_system/targets/assets.dart ++++ b/packages/flutter_tools/lib/src/build_system/targets/assets.dart +@@ -128,7 +128,11 @@ Future copyAssets( + break; + } + if (doCopy) { +- await (content.file as File).copy(file.path); ++ // Not using File.copy because it preserves permissions. ++ final sourceFile = content.file as File; ++ final destinationFile = file; ++ ++ await destinationFile.writeAsBytes(await sourceFile.readAsBytes(), flush: true); + } + } else { + await file.writeAsBytes(await entry.value.contentsAsBytes()); -- cgit 1.4.1 From aa9079c678a76354c829d4821e35776db67084ba Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 17:27:10 +1000 Subject: flutter: Remove prebuilt dependencies from the wrapper These are no longer needed now that the artifacts are patched. --- pkgs/development/compilers/flutter/wrapper.nix | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index b9341bdb1b16c..270eb2cd175ad 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -58,15 +58,6 @@ let # They must be manually included. appStaticBuildDeps = lib.optionals supportsLinuxDesktop [ libX11 xorgproto zlib ]; - # Some runtime components are prebuilt, and do not know where to find their dependencies. - # Ideally, these prebuilt components would be patched by the SDK derivation, but this - # is tricky as they are tyically downloaded from Google on-demand. - # Building the Engine manually should solve this issue: https://github.com/NixOS/nixpkgs/issues/201574 - appPrebuiltDeps = lib.optionals supportsLinuxDesktop [ - # flutter_linux_gtk.so - libepoxy - ]; - # Tools used by the Flutter SDK to compile applications. buildTools = lib.optionals supportsLinuxDesktop [ pkg-config -- cgit 1.4.1 From 0f2848638fef6e708b9488ee7badb3899fa3ab27 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 17:46:14 +1000 Subject: flutter: 3.3.3 -> 3.7.11 --- pkgs/development/compilers/flutter/default.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix index 6c34ef440243a..01106aaeefc66 100644 --- a/pkgs/development/compilers/flutter/default.nix +++ b/pkgs/development/compilers/flutter/default.nix @@ -29,12 +29,12 @@ in { inherit mkFlutter wrapFlutter flutterDrv; stable = flutterDrv { - version = "3.3.3"; - dartVersion = "2.18.2"; - hash = "sha256-MTZeWQUp4/TcPzYIT6eqIKSPUPvn2Mp/thOQzNgpTXg="; + version = "3.7.11"; + dartVersion = "2.19.6"; + hash = "sha256-/vtjoPB4Hn8RtP09uMdUYtDS7lzQvskdrNszEYlpOBc="; dartHash = { - x86_64-linux = "sha256-C3+YjecXLvSmJrLwi9H7TgD9Np0AArRWx3EdBrfQpTU"; - aarch64-linux = "sha256-zyIK1i5/9P2C+sjzdArhFwpVO4P+It+/X50l+n9gekI="; + x86_64-linux = "sha256-D9/yXmrLo9YJQVWn40FjT43jR36Gwv2krUcjLBrfcE8="; + aarch64-linux = "sha256-aRO3wLO3i8FB03LNRz2iF3Hlc3Kxq0XJd84VUMj/C5w="; }; patches = getPatches ./patches/flutter3; }; -- cgit 1.4.1 From 5777f1a122a07e0b63d1eb2dcdb17a7b7d31d196 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 17:49:33 +1000 Subject: flutter: Don't check executable locations in doctor Flutter 3.5.0 adds a check to make sure that the Flutter and Dart tool executables are inside the SDK directory. This does not play nicely with the wrapping and linking techniques used to package it. It is also impossible for there to be an issue related to binary locations, as everything is set up properly in the derivation. --- .../patches/flutter3/dont-validate-executable-location.patch | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 pkgs/development/compilers/flutter/patches/flutter3/dont-validate-executable-location.patch diff --git a/pkgs/development/compilers/flutter/patches/flutter3/dont-validate-executable-location.patch b/pkgs/development/compilers/flutter/patches/flutter3/dont-validate-executable-location.patch new file mode 100644 index 0000000000000..5f391265ce153 --- /dev/null +++ b/pkgs/development/compilers/flutter/patches/flutter3/dont-validate-executable-location.patch @@ -0,0 +1,12 @@ +diff --git a/packages/flutter_tools/lib/src/doctor.dart b/packages/flutter_tools/lib/src/doctor.dart +index 651dc6cf36..236eb370e1 100644 +--- a/packages/flutter_tools/lib/src/doctor.dart ++++ b/packages/flutter_tools/lib/src/doctor.dart +@@ -515,7 +515,6 @@ class FlutterValidator extends DoctorValidator { + final String flutterRoot = _flutterRoot(); + messages.add(_getFlutterVersionMessage(frameworkVersion, versionChannel, flutterRoot)); + +- _validateRequiredBinaries(flutterRoot).forEach(messages.add); + messages.add(_getFlutterUpstreamMessage(version)); + if (gitUrl != null) { + messages.add(ValidationMessage(_userMessages.flutterGitUrl(gitUrl))); -- cgit 1.4.1 From 88b308c1323897b2747cf4593fbaf9cd9aa95f36 Mon Sep 17 00:00:00 2001 From: gilice <104317939+gilice@users.noreply.github.com> Date: Tue, 4 Apr 2023 16:41:05 +0200 Subject: maintainers: add FlafyDev --- maintainers/maintainer-list.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 2d1903458b403..d9649b0a10891 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -5102,6 +5102,12 @@ github = "fkautz"; githubId = 135706; }; + FlafyDev = { + name = "Flafy Arazi"; + email = "flafyarazi@gmail.com"; + github = "FlafyDev"; + githubId = 44374434; + }; Flakebi = { email = "flakebi@t-online.de"; github = "Flakebi"; -- cgit 1.4.1 From bc6e36afdcdba1a58814de7ea87306e2c8b4f8c1 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Wed, 16 Nov 2022 14:14:31 +1100 Subject: maintainers: add hacker1024 --- maintainers/maintainer-list.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index d9649b0a10891..c6604b163d815 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -5913,6 +5913,12 @@ fingerprint = "F7D3 7890 228A 9074 40E1 FD48 46B9 228E 814A 2AAC"; }]; }; + hacker1024 = { + name = "hacker1024"; + email = "hacker1024@users.sourceforge.net"; + github = "hacker1024"; + githubId = 20849728; + }; hagl = { email = "harald@glie.be"; github = "hagl"; -- cgit 1.4.1 From 4df7d07ab1d829c16e4aa36a012b161825b717d9 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 19:29:42 +1000 Subject: flutter: Remove stray dollar sign from name string --- pkgs/development/compilers/flutter/flutter.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index af2cda1b712ab..7500f057078e1 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -25,7 +25,7 @@ let self = stdenv.mkDerivation { - name = "$flutter-${version}-unwrapped"; + name = "flutter-${version}-unwrapped"; inherit src patches version; outputs = [ "out" "cache" ]; -- cgit 1.4.1 From f3aac6e61e6711908073d5eeb6adf2d445f81ccf Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 19:46:45 +1000 Subject: flutter: Add FlafyDev, gilice, and hacker1024 as maintainers --- pkgs/development/compilers/flutter/flutter.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index 7500f057078e1..8471f2f0da8b7 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -119,7 +119,7 @@ let homepage = "https://flutter.dev"; license = licenses.bsd3; platforms = [ "x86_64-linux" "aarch64-linux" ]; - maintainers = with maintainers; [ babariviere ericdallo ]; + maintainers = with maintainers; [ babariviere ericdallo FlafyDev gilice hacker1024 ]; }; } ; -- cgit 1.4.1 From 4196ddbeb5f1c1f6134a2dfef771c9777be87e86 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 21:55:50 +1000 Subject: flutter: Add git and which to PATH --- pkgs/development/compilers/flutter/wrapper.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index 270eb2cd175ad..a8018525332c4 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -6,6 +6,8 @@ , makeWrapper , runCommandLocal , writeShellScript +, git +, which , pkg-config , atk , cairo @@ -31,6 +33,9 @@ let ${flutter}/bin/flutter --no-version-check "$@" ''; + # Tools that the Flutter tool depends on. + tools = [ git which ]; + # Libraries that Flutter apps depend on at runtime. appRuntimeDeps = lib.optionals supportsLinuxDesktop [ atk @@ -84,7 +89,7 @@ in mkdir -p $out/bin makeWrapper '${immutableFlutter}' $out/bin/flutter \ --set-default ANDROID_EMULATOR_USE_SYSTEM_LIBS 1 \ - --prefix PATH : '${lib.makeBinPath buildTools}' \ + --prefix PATH : '${lib.makeBinPath (tools ++ buildTools)}' \ --prefix PKG_CONFIG_PATH : '${builtins.concatStringsSep ":" pkgConfigDirectories}' \ --prefix LIBRARY_PATH : '${lib.makeLibraryPath appStaticBuildDeps}' \ --prefix CXXFLAGS "''\t" '${builtins.concatStringsSep " " cppFlags}' \ -- cgit 1.4.1 From 6d50bcc4876261de18720e6a867ae959d31018d1 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 22:00:24 +1000 Subject: mkFlutterApp: Deduplicate build environment setup The build environment is now set up by the Flutter wrapper, and does not need to be done in mkFlutterApp. --- pkgs/build-support/flutter/default.nix | 102 +++++---------------------------- 1 file changed, 14 insertions(+), 88 deletions(-) diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 307e2d08c5fcc..253d9044c18ce 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -1,36 +1,10 @@ -{ flutter -, lib -, llvmPackages_13 -, cmake -, ninja -, pkg-config -, wrapGAppsHook -, autoPatchelfHook -, util-linux -, libselinux -, libsepol -, libthai -, libdatrie -, libxkbcommon -, at-spi2-core -, libsecret -, jsoncpp -, xorg -, dbus -, gtk3 -, glib -, pcre -, libepoxy +{ lib , stdenvNoCC -, cacert -, git -, dart +, autoPatchelfHook , nukeReferences -, bash -, curl -, unzip -, which -, xz +, llvmPackages_13 +, cacert +, flutter }: # absolutely no mac support for now @@ -42,23 +16,13 @@ let placeholder_flutter = pl "FLUTTER"; fetchAttrs = [ "src" "sourceRoot" "setSourceRoot" "unpackPhase" "patches" ]; getAttrsOrNull = names: attrs: lib.genAttrs names (name: if attrs ? ${name} then attrs.${name} else null); - flutterDeps = [ - # flutter deps - flutter.wrapped - bash - curl - flutter.dart - git - unzip - which - xz - ]; self = (self: llvmPackages_13.stdenv.mkDerivation (args // { deps = stdenvNoCC.mkDerivation (lib.recursiveUpdate (getAttrsOrNull fetchAttrs args) { name = "${self.name}-deps-flutter-v${flutter.unwrapped.version}-${stdenvNoCC.targetPlatform.system}.tar.gz"; - nativeBuildInputs = flutterDeps ++ [ + nativeBuildInputs = [ + flutter nukeReferences ]; @@ -69,10 +33,7 @@ let . ${../fetchgit/deterministic-git} TMP=$(mktemp -d) - export HOME="$TMP" - export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"} - export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1 flutter config --no-analytics &>/dev/null # mute first-run flutter config --enable-linux-desktop @@ -151,44 +112,11 @@ let }); - nativeBuildInputs = flutterDeps ++ [ - # flutter dev tools - cmake - ninja - pkg-config - wrapGAppsHook - # flutter likes dynamic linking - autoPatchelfHook - ] ++ lib.optionals (args ? nativeBuildInputs) args.nativeBuildInputs; - - buildInputs = [ - # cmake deps - gtk3 - glib - pcre - util-linux - # also required by cmake, not sure if really needed or dep of all packages - libselinux - libsepol - libthai - libdatrie - xorg.libXdmcp - xorg.libXtst - libxkbcommon - dbus - at-spi2-core - libsecret - jsoncpp - # build deps - xorg.libX11 - # directly required by build - libepoxy - ] ++ lib.optionals (args ? buildInputs) args.buildInputs; - - # TODO: do we need this? - NIX_LDFLAGS = "-rpath ${lib.makeLibraryPath self.buildInputs}"; - env.NIX_CFLAGS_COMPILE = "-I${xorg.libX11}/include"; - LD_LIBRARY_PATH = lib.makeLibraryPath self.buildInputs; + nativeBuildInputs = [ flutter autoPatchelfHook ] ++ lib.optionals (args ? nativeBuildInputs) args.nativeBuildInputs; + + buildInputs = lib.optionals (args ? buildInputs) args.buildInputs; + + dontAutoPatchelf = true; configurePhase = '' runHook preConfigure @@ -207,7 +135,7 @@ let # after extracting update paths to point to real paths find "$depsFolder" -type f -exec sed -i \ -e s,${placeholder_deps},$depsFolder,g \ - -e s,${placeholder_flutter},${flutter.unwrapped},g \ + -e s,${placeholder_flutter},${flutter},g \ {} + # ensure we're using a lockfile for the right package version @@ -223,9 +151,7 @@ let mv -v $(find $depsFolder/f -type f) . # prepare - export HOME=$depsFolder - export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"} - export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1 + export HOME="$depsFolder" # binaries need to be patched autoPatchelf -- "$depsFolder" -- cgit 1.4.1 From 04e7ced7e2ff2013dc6b6fa777e05c76352c0f24 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 22:01:42 +1000 Subject: mkFlutterApp: Don't fetch prebuilt artifacts Artifacts are now supplied by the Flutter SDK derivation. In addition, they are no longer a factor in the dependency hash calculation. --- pkgs/build-support/flutter/default.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 253d9044c18ce..6d756ea188a06 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -38,7 +38,6 @@ let flutter config --no-analytics &>/dev/null # mute first-run flutter config --enable-linux-desktop flutter packages get - flutter build linux || true # so it downloads tools ${lib.optionalString (args ? flutterExtraFetchCommands) args.flutterExtraFetchCommands} RES="$TMP" -- cgit 1.4.1 From c59ce54f1d19be4f1f69652b46de72116b1928ed Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 22:02:50 +1000 Subject: flutter: Add mkFlutterApp as a passthru attribute --- pkgs/development/compilers/flutter/flutter.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index 8471f2f0da8b7..007c10998b307 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -4,6 +4,7 @@ , src , lib +, callPackage , stdenv , autoPatchelfHook , git @@ -108,6 +109,9 @@ let # When other derivations wrap this one, any unmodified files # found here should be included as-is, for tooling compatibility. sdk = self; + mkFlutterApp = callPackage ../../../build-support/flutter { + flutter = callPackage ./wrapper.nix { flutter = self; }; + }; }; meta = with lib; { -- cgit 1.4.1 From 13bbb361325433e0c8d23ec4b4db74a7eef1961b Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 22:52:40 +1000 Subject: flutter: Move makeWrapper to nativeBuildInputs in wrapper --- pkgs/development/compilers/flutter/wrapper.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index a8018525332c4..35514c9cf9306 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -78,7 +78,7 @@ let in (callPackage ./sdk-symlink.nix { }) (runCommandLocal "flutter-wrapped" { - buildInputs = [ makeWrapper ]; + nativeBuildInputs = [ makeWrapper ]; passthru = flutter.passthru // { unwrapped = flutter; -- cgit 1.4.1 From cedcb0b7729390eb6dc3c32734a58485d2b090ea Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Thu, 13 Apr 2023 23:19:16 +1000 Subject: flutter: Rename "self" to "unwrapped" in main derivation --- pkgs/development/compilers/flutter/flutter.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index 007c10998b307..e332af2e35602 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -24,7 +24,7 @@ let libepoxy ]; - self = + unwrapped = stdenv.mkDerivation { name = "flutter-${version}-unwrapped"; inherit src patches version; @@ -108,9 +108,9 @@ let # The derivation containing the original Flutter SDK files. # When other derivations wrap this one, any unmodified files # found here should be included as-is, for tooling compatibility. - sdk = self; + sdk = unwrapped; mkFlutterApp = callPackage ../../../build-support/flutter { - flutter = callPackage ./wrapper.nix { flutter = self; }; + flutter = callPackage ./wrapper.nix { flutter = unwrapped; }; }; }; @@ -128,4 +128,4 @@ let } ; in -self +unwrapped -- cgit 1.4.1 From 8f9aa6b18befaa6bd6f5cb1a328a9528bc4bd761 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Fri, 14 Apr 2023 01:41:58 +1000 Subject: flutter.mkFlutterApp: Don't use autoPatchelf on package cache While this may be beneficial for packages that ship native binaries, this causes issues due to Flutter packages that have inappropriately uploaded build artifacts (such as those from example subprojects) to pub.dev. --- pkgs/build-support/flutter/default.nix | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 6d756ea188a06..379953b6dfc92 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -1,6 +1,5 @@ { lib , stdenvNoCC -, autoPatchelfHook , nukeReferences , llvmPackages_13 , cacert @@ -111,12 +110,10 @@ let }); - nativeBuildInputs = [ flutter autoPatchelfHook ] ++ lib.optionals (args ? nativeBuildInputs) args.nativeBuildInputs; + nativeBuildInputs = [ flutter ] ++ lib.optionals (args ? nativeBuildInputs) args.nativeBuildInputs; buildInputs = lib.optionals (args ? buildInputs) args.buildInputs; - dontAutoPatchelf = true; - configurePhase = '' runHook preConfigure @@ -152,8 +149,6 @@ let # prepare export HOME="$depsFolder" - # binaries need to be patched - autoPatchelf -- "$depsFolder" runHook postConfigure ''; @@ -187,9 +182,6 @@ let ln -s $f $out/bin/$(basename $f) done - # this confuses autopatchelf hook otherwise - rm -rf "$depsFolder" - # make *.so executable find $out/app -iname "*.so" -type f -exec chmod +x {} + -- cgit 1.4.1 From f7e3c19cc8b34f17bd822bf328687b913c1534ad Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Fri, 14 Apr 2023 01:49:09 +1000 Subject: flutter.mkFlutterApp: Don't vendor arbitrary configuration files --- .../applications/misc/yubioath-flutter/default.nix | 12 +++------ pkgs/build-support/flutter/default.nix | 30 ++++++++++------------ .../linux/firmware/firmware-updater/default.nix | 6 +---- 3 files changed, 18 insertions(+), 30 deletions(-) diff --git a/pkgs/applications/misc/yubioath-flutter/default.nix b/pkgs/applications/misc/yubioath-flutter/default.nix index dde9f3b69862d..f1e0094468a74 100644 --- a/pkgs/applications/misc/yubioath-flutter/default.nix +++ b/pkgs/applications/misc/yubioath-flutter/default.nix @@ -2,18 +2,12 @@ , flutter , python3 , fetchFromGitHub -, stdenv , pcre2 , gnome , makeWrapper , removeReferencesTo }: -let - vendorHashes = { - x86_64-linux = "sha256-Upe0cEDG02RJD50Ht9VNMwkelsJHX8zOuJZssAhMuMY="; - aarch64-linux = "sha256-lKER4+gcyFqnCvgBl/qdVBCbUpocWUnXGLXsX82MSy4="; - }; -in + flutter.mkFlutterApp rec { pname = "yubioath-flutter"; version = "6.1.0"; @@ -27,7 +21,7 @@ flutter.mkFlutterApp rec { passthru.helper = python3.pkgs.callPackage ./helper.nix { inherit src version meta; }; - vendorHash = vendorHashes.${stdenv.system}; + vendorHash = "sha256-1ast8pm9wrt9nqLt5MJ2LkiZivlm9d+qcKrz/d8VVmI="; postPatch = '' substituteInPlace linux/CMakeLists.txt \ @@ -89,6 +83,6 @@ flutter.mkFlutterApp rec { homepage = "https://github.com/Yubico/yubioath-flutter"; license = licenses.asl20; maintainers = with maintainers; [ lukegb ]; - platforms = builtins.attrNames vendorHashes; + platforms = [ "x86_64-linux" "aarch64-linux" ]; }; } diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 379953b6dfc92..d63be4d061a4a 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -86,7 +86,8 @@ let # Build a reproducible tar, per instructions at https://reproducible-builds.org/docs/archives/ tar --owner=0 --group=0 --numeric-owner --format=gnu \ --sort=name --mtime="@$SOURCE_DATE_EPOCH" \ - -czf "$out" -C "$RES" . + -czf "$out" -C "$RES" \ + pubspec.yaml pubspec.lock f .pub-cache ''; GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt"; @@ -120,35 +121,32 @@ let # for some reason fluffychat build breaks without this - seems file gets overriden by some tool cp pubspec.yaml pubspec-backup - # we get this from $depsFolder so disabled for now, but we might need it again once deps are fetched properly - # flutter config --no-analytics >/dev/null 2>/dev/null # mute first-run - # flutter config --enable-linux-desktop + TMP=$(mktemp -d) + export HOME="$TMP" + + flutter config --no-analytics &>/dev/null # mute first-run + flutter config --enable-linux-desktop # extract deps - depsFolder=$(mktemp -d) - tar xzf "$deps" -C "$depsFolder" + tar xzf "$deps" -C "$HOME" # after extracting update paths to point to real paths - find "$depsFolder" -type f -exec sed -i \ - -e s,${placeholder_deps},$depsFolder,g \ + find "$HOME" -type f -exec sed -i \ + -e s,${placeholder_deps},"$HOME",g \ -e s,${placeholder_flutter},${flutter},g \ {} + # ensure we're using a lockfile for the right package version if [ -e pubspec.lock ]; then # FIXME: currently this is broken. in theory this should not break, but flutter has it's own way of doing things. - # diff -u pubspec.lock $depsFolder/pubspec.lock + # diff -u pubspec.lock "$HOME/pubspec.lock" true else - cp -v "$depsFolder/pubspec.lock" . + cp -v "$HOME/pubspec.lock" . fi - diff -u pubspec.yaml $depsFolder/pubspec.yaml - - mv -v $(find $depsFolder/f -type f) . - - # prepare - export HOME="$depsFolder" + diff -u pubspec.yaml "$HOME/pubspec.yaml" + mv -v $(find "$HOME/f" -type f) . runHook postConfigure ''; diff --git a/pkgs/os-specific/linux/firmware/firmware-updater/default.nix b/pkgs/os-specific/linux/firmware/firmware-updater/default.nix index 04fb8b0fe3794..696704d3c4d4f 100644 --- a/pkgs/os-specific/linux/firmware/firmware-updater/default.nix +++ b/pkgs/os-specific/linux/firmware/firmware-updater/default.nix @@ -1,17 +1,13 @@ { lib , flutter2 , fetchFromGitHub -, stdenv }: flutter2.mkFlutterApp { pname = "firmware-updater"; version = "unstable"; - vendorHash = - if stdenv.system == "aarch64-linux" - then "sha256-+ACmcIKXtGtaYBuwc7jY9hEdIS9qxQCbuxRKJQohX5A=" - else "sha256-nPblucEpNCBJYpIqx1My6SWq8CjXYuHDG/uphdcrWjQ="; + vendorHash = "sha256-QPLAMFL/enMfbmUZx6qQSswI/vxeWgjytRdoNxziQ18="; src = fetchFromGitHub { owner = "canonical"; -- cgit 1.4.1 From 30caca083912d28bcb9cd6f62e505a59afc9cf5d Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Fri, 14 Apr 2023 02:16:04 +1000 Subject: flutter.mkFlutterApp: Add Git to nativeBuildInputs The deterministic Git script depends on it. --- pkgs/build-support/flutter/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index d63be4d061a4a..c0065d03226bb 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -4,6 +4,7 @@ , llvmPackages_13 , cacert , flutter +, git }: # absolutely no mac support for now @@ -22,6 +23,7 @@ let nativeBuildInputs = [ flutter + git nukeReferences ]; -- cgit 1.4.1 From 1b2cac51b2941b7e5bee2c10ce10de3f0fb7dc71 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Fri, 14 Apr 2023 14:21:38 +1000 Subject: flutter: Use existing libdeflate derivation --- .../compilers/flutter/packages/libdeflate/default.nix | 17 ----------------- pkgs/development/compilers/flutter/wrapper.nix | 3 ++- 2 files changed, 2 insertions(+), 18 deletions(-) delete mode 100644 pkgs/development/compilers/flutter/packages/libdeflate/default.nix diff --git a/pkgs/development/compilers/flutter/packages/libdeflate/default.nix b/pkgs/development/compilers/flutter/packages/libdeflate/default.nix deleted file mode 100644 index c0b3cabbc9d68..0000000000000 --- a/pkgs/development/compilers/flutter/packages/libdeflate/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ stdenv, fetchFromGitHub, cmake }: - -stdenv.mkDerivation rec { - pname = "libdeflate"; - version = "1.17"; - - src = fetchFromGitHub { - owner = "ebiggers"; - repo = pname; - rev = "v${version}"; - hash = "sha256-tKs8feGbeodOID8FPIUc/1LfBz1p0oN1Jfkv2OnA2qc="; - }; - - nativeBuildInputs = [ cmake ]; - - outputs = [ "bin" "dev" "out" ]; -} diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index 35514c9cf9306..b2e545e4a44d9 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -19,6 +19,7 @@ , pango , libX11 , xorgproto +, libdeflate , zlib , cmake , ninja @@ -47,7 +48,7 @@ let libepoxy pango libX11 - (callPackage ./packages/libdeflate { }) + libdeflate ]; # Development packages required for compilation. -- cgit 1.4.1 From 7e12e3afaa335816baa2eeb1683787fbd22a3372 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Fri, 14 Apr 2023 14:25:33 +1000 Subject: flutter.mkFlutterApp: Remove the target architecture from the dependency derivation name As the dependency tarballs no longer include SDK artifacts, they are not platform dependent. --- pkgs/build-support/flutter/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index c0065d03226bb..58149525b476d 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -19,7 +19,7 @@ let self = (self: llvmPackages_13.stdenv.mkDerivation (args // { deps = stdenvNoCC.mkDerivation (lib.recursiveUpdate (getAttrsOrNull fetchAttrs args) { - name = "${self.name}-deps-flutter-v${flutter.unwrapped.version}-${stdenvNoCC.targetPlatform.system}.tar.gz"; + name = "${self.name}-deps-flutter-v${flutter.unwrapped.version}.tar.gz"; nativeBuildInputs = [ flutter -- cgit 1.4.1 From b16e344fae5aedeed4ce66e8f54bb60e6aacb0f7 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Fri, 14 Apr 2023 15:11:31 +1000 Subject: flutter: Remove --no-version-check from the immutable wrapper This is not technically needed anyway, as the feature is removed in disable-auto-update.patch. Prepending this argument causes issues: - https://github.com/kevmoo/completion.dart/issues/33 - https://github.com/flutter/flutter/issues/124793 --- pkgs/development/compilers/flutter/wrapper.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index b2e545e4a44d9..c2b1ee19cd52e 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -31,7 +31,7 @@ let # Wrap it to ensure that it does not do that, preferring home directories instead. immutableFlutter = writeShellScript "flutter_immutable" '' export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"} - ${flutter}/bin/flutter --no-version-check "$@" + ${flutter}/bin/flutter "$@" ''; # Tools that the Flutter tool depends on. -- cgit 1.4.1 From c3797393b70ce507aa47abb2f742bbb355e2c398 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sat, 15 Apr 2023 01:52:30 +1000 Subject: flutter: Use fetchzip instead of fetchurl for source downloads This allows for speedier re-use of the source archives, and lets files inside be read in Nix. --- pkgs/development/compilers/flutter/default.nix | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix index 0c94fbb53c574..56361bbb6abf2 100644 --- a/pkgs/development/compilers/flutter/default.nix +++ b/pkgs/development/compilers/flutter/default.nix @@ -1,4 +1,4 @@ -{ callPackage, fetchurl, dart }: +{ callPackage, fetchzip, dart }: let mkFlutter = { version, patches, dart, src }: callPackage ./flutter.nix { inherit version patches dart src; }; wrapFlutter = flutter: callPackage ./wrapper.nix { inherit flutter; }; @@ -10,17 +10,17 @@ let dart = dart.override { version = dartVersion; sources = { - "${dartVersion}-x86_64-linux" = fetchurl { + "${dartVersion}-x86_64-linux" = fetchzip { url = "https://storage.googleapis.com/dart-archive/channels/stable/release/${dartVersion}/sdk/dartsdk-linux-x64-release.zip"; sha256 = dartHash.x86_64-linux; }; - "${dartVersion}-aarch64-linux" = fetchurl { + "${dartVersion}-aarch64-linux" = fetchzip { url = "https://storage.googleapis.com/dart-archive/channels/stable/release/${dartVersion}/sdk/dartsdk-linux-arm64-release.zip"; sha256 = dartHash.aarch64-linux; }; }; }; - src = fetchurl { + src = fetchzip { url = "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${version}-stable.tar.xz"; sha256 = hash; }; @@ -33,10 +33,10 @@ in stable = flutterDrv { version = "3.7.11"; dartVersion = "2.19.6"; - hash = "sha256-/vtjoPB4Hn8RtP09uMdUYtDS7lzQvskdrNszEYlpOBc="; + hash = "sha256-H2S8nRpTte6ux34jTkCneGbSMQldrnjH1dI+/pzrcNg="; dartHash = { - x86_64-linux = "sha256-D9/yXmrLo9YJQVWn40FjT43jR36Gwv2krUcjLBrfcE8="; - aarch64-linux = "sha256-aRO3wLO3i8FB03LNRz2iF3Hlc3Kxq0XJd84VUMj/C5w="; + x86_64-linux = "sha256-4ezRuwhQHVCxZg5WbzU/tBUDvZVpfCo6coDE4K0UzXo="; + aarch64-linux = "sha256-pYmClIqOo0sRPOkrcF4xQbo0mHlrr1TkhT1fnNyYNck="; }; patches = flutter3Patches; }; @@ -44,10 +44,10 @@ in v2 = flutterDrv { version = "2.10.5"; dartVersion = "2.16.2"; - hash = "sha256-DTZwxlMUYk8NS1SaWUJolXjD+JnRW73Ps5CdRHDGnt0="; + hash = "sha256-MxaWvlcCfXN8gsC116UMzqb4LgixHL3YjrGWy7WYgW4="; dartHash = { - x86_64-linux = "sha256-egrYd7B4XhkBiHPIFE2zopxKtQ58GqlogAKA/UeiXnI="; - aarch64-linux = "sha256-vmerjXkUAUnI8FjK+62qLqgETmA+BLPEZXFxwYpI+KY="; + x86_64-linux = "sha256-vxKxysg6e3Qxtlp4dLxOZaBtgHGtl7XYd73zFZd9yJc="; + aarch64-linux = "sha256-ZfpR6fj/a9Bsgrg31Z/uIJaCHIWtcQH3VTTVkDJKkwA="; }; patches = flutter2Patches; }; -- cgit 1.4.1 From 62e50080f39560183c57aa184bf03e47a341444c Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sat, 15 Apr 2023 01:59:31 +1000 Subject: flutter: Download engine artifacts individually This brings the following benefits: - Artifacts missing in the SDK tarball (such as prebuilts for linux-aarch64) can be obtained - Artifacts can be patched more granularly (e.g. libflutter_linux_gtk is patchelf-ed for GTK3, and the linux-aarch64 assets have a postPatch to add some missing files) - Minimal Flutter packages can be generated (e.g. mkFlutterApp only needs prebuilts for desktop Linux, and developers that don't care for desktop Linux can exclude the artifacts and dependencies) It also paves the way for including manually built engine facts. --- .../compilers/flutter/engine-artifacts/default.nix | 127 ++++++++++++++++++ .../compilers/flutter/engine-artifacts/hashes.nix | 144 +++++++++++++++++++++ pkgs/development/compilers/flutter/flutter.nix | 99 +++++++++++--- 3 files changed, 350 insertions(+), 20 deletions(-) create mode 100644 pkgs/development/compilers/flutter/engine-artifacts/default.nix create mode 100644 pkgs/development/compilers/flutter/engine-artifacts/hashes.nix diff --git a/pkgs/development/compilers/flutter/engine-artifacts/default.nix b/pkgs/development/compilers/flutter/engine-artifacts/default.nix new file mode 100644 index 0000000000000..30ef16bbeca98 --- /dev/null +++ b/pkgs/development/compilers/flutter/engine-artifacts/default.nix @@ -0,0 +1,127 @@ +{ lib +, stdenv +, hostPlatform +, engineVersion +, fetchzip +, autoPatchelfHook + +, gtk3 +}: + +let + hashes = (import ./hashes.nix).${engineVersion}; + + artifacts = + { + common = { + flutter_patched_sdk = { archive = "flutter_patched_sdk.zip"; }; + flutter_patched_sdk_product = { archive = "flutter_patched_sdk_product.zip"; }; + }; + platform = { + android = + (lib.genAttrs + [ "arm" "arm64" "x64" ] + (arch: + { + base = [ + { archive = "artifacts.zip"; } + ]; + variants = lib.genAttrs [ "profile" "release" ] + (variant: [ + { archive = "artifacts.zip"; } + { archive = "${lib.toLower hostPlatform.uname.system}-x64.zip"; } + ]); + })) // + { + "x86" = { + base = [ + { archive = "artifacts.zip"; } + ]; + variants.jit-release = [ + { archive = "artifacts.zip"; } + ]; + }; + }; + + linux = lib.genAttrs + [ "arm64" "x64" ] + (arch: + let + linux-flutter-gtk = { + archive = "linux-${arch}-flutter-gtk.zip"; + buildInputs = [ gtk3 ]; + }; + in + { + base = [ + ({ archive = "artifacts.zip"; } // lib.optionalAttrs (arch == "arm64") { + # For some reason, the arm64 artifacts are missing shader code. + postPatch = '' + if [ -d shader_lib ]; then + The shader_lib directory has been included in the artifact archive. + This patch should be removed. + fi + ln -s ${lib.findSingle + (pkg: lib.getName pkg == "flutter-artifact-linux-x64-artifacts") + (throw "Could not find the x64 artifact archive.") + (throw "Could not find the correct x64 artifact archive.") + artifactDerivations.platform.linux.x64.base + }/shader_lib . + ''; + }) + { archive = "font-subset.zip"; } + linux-flutter-gtk + ]; + variants = lib.genAttrs [ "debug" "profile" "release" ] (variant: [ + linux-flutter-gtk + ]); + }); + }; + }; + + mkArtifactDerivation = { platform ? null, variant ? null, archive, ... }@args: + let + artifactDirectory = if platform == null then null else "${platform}${lib.optionalString (variant != null) "-${variant}"}"; + archiveBasename = lib.removeSuffix ".${(lib.last (lib.splitString "." archive))}" archive; + in + stdenv.mkDerivation ({ + pname = "flutter-artifact${lib.optionalString (platform != null) "-${artifactDirectory}"}-${archiveBasename}"; + version = engineVersion; + + src = fetchzip { + url = "https://storage.googleapis.com/flutter_infra_release/flutter/${engineVersion}${lib.optionalString (platform != null) "/${artifactDirectory}"}/${archive}"; + stripRoot = false; + hash = (if artifactDirectory == null then hashes else hashes.${artifactDirectory}).${archive}; + }; + + nativeBuildInputs = [ autoPatchelfHook ]; + + installPhase = "cp -r . $out"; + } // args); + + artifactDerivations = { + common = builtins.mapAttrs (name: mkArtifactDerivation) artifacts.common; + platform = + builtins.mapAttrs + (os: architectures: + builtins.mapAttrs + (architecture: variants: { + base = map + (args: mkArtifactDerivation ({ + platform = "${os}-${architecture}"; + } // args)) + variants.base; + variants = builtins.mapAttrs + (variant: variantArtifacts: map + (args: mkArtifactDerivation ({ + platform = "${os}-${architecture}"; + inherit variant; + } // args)) + variantArtifacts) + variants.variants; + }) + architectures) + artifacts.platform; + }; +in +artifactDerivations diff --git a/pkgs/development/compilers/flutter/engine-artifacts/hashes.nix b/pkgs/development/compilers/flutter/engine-artifacts/hashes.nix new file mode 100644 index 0000000000000..e3453748b0538 --- /dev/null +++ b/pkgs/development/compilers/flutter/engine-artifacts/hashes.nix @@ -0,0 +1,144 @@ +{ + "1a65d409c7a1438a34d21b60bf30a6fd5db59314" = { + "flutter_patched_sdk.zip" = "sha256-Pvsjttm5OwpJ/pW4UQXvvEiJYCM5CoZZfVXz5jef37k="; + "flutter_patched_sdk_product.zip" = "sha256-fhj2uUOrLwrzHrM6RNVpPNize5Qu6mLQDcSzLT2TbRA="; + "android-arm" = { + "artifacts.zip" = "sha256-KDMiI6SQoZHfFV5LJJZ7VOGyEKC4UxzRc777j4BbXgM="; + }; + "android-arm-profile" = { + "artifacts.zip" = "sha256-MErLoGJWXg4yJ6b6c5bqP8Nat6O7eYSfM71mMNAAQf4="; + "linux-x64.zip" = "sha256-0TZQ05HR7NRqHzeoHZ/sOrjKiSvCpMUH85YXXzV4URg="; + }; + "android-arm-release" = { + "artifacts.zip" = "sha256-hU4S4FOqUGokByZ47nzOqQ4A9QFshruqrpJvJUBHUho="; + "linux-x64.zip" = "sha256-AqNlqjOht+c2sdW5ReoF66ZJWJl1W4vGKbQ3YyderRY="; + }; + "android-arm64" = { + "artifacts.zip" = "sha256-ApNg3Uu9gyGNsx7sdpTCz1yADVAI5ZuNHgvgiuH9IpQ="; + }; + "android-arm64-profile" = { + "artifacts.zip" = "sha256-D/8+WKPIkOaV3PwkCHiJROFlokm4lWWmtPQb93Yqwr0="; + "linux-x64.zip" = "sha256-S0RHLov6/C22VvGdvZV87Ybaxun8YBrw1gTgNklRcM0="; + }; + "android-arm64-release" = { + "artifacts.zip" = "sha256-OoYqHtwmT+VWJ+G+sMXM5+ux3h1Fnyo9Vj2za9cm5eE="; + "linux-x64.zip" = "sha256-NuXclg1a+Ofw5AWJ1tajpn2jYEZw6DluWxrFVL8rPfg="; + }; + "android-x86" = { + "artifacts.zip" = "sha256-nN66nIrcbJHq2S4oIT5e2NCv7mS5Kw+HBv3ReHs+d3Y="; + }; + "android-x86-jit-release" = { + "artifacts.zip" = "sha256-A8F6K78Ykp1rMsUmjD7B9nFFPAubZnqAqgWSzbNCRwk="; + }; + "android-x64" = { + "artifacts.zip" = "sha256-hrBvnzCj/24h5kat96avlgXi6WhMsos5aPlkgxOYo8Q="; + }; + "android-x64-profile" = { + "artifacts.zip" = "sha256-xzSj/2ah9aQoosaNGkSWFP3bMNJqRSFc0+78XEBHwzM="; + "linux-x64.zip" = "sha256-HfBiz1JWlBQ8KEfmf8uDlVzFlDt3+VF2VeY82tsMjHs="; + }; + "android-x64-release" = { + "artifacts.zip" = "sha256-TcfMeA+8Uf9yRrYdEIsjip0cKmSUm2Ow1tkoE9803XY="; + "linux-x64.zip" = "sha256-D6efb6pj9+xjPnJu3O+ZCmwfatBzasuFZEFRntAiU9U="; + }; + "linux-arm64" = { + "artifacts.zip" = "sha256-xyKVaEFb5gVkVrPzDrOql5BmXGO0FnCSeXOoQ10ZFrw="; + "font-subset.zip" = "sha256-Ulwb6q2SzB4suMJhAM3zAwWOzlEImlu9Ha+w5u4QqIU="; + "linux-arm64-flutter-gtk.zip" = "sha256-SiYOH++py4zeoD3BkNayqy/C9Zz9OiYQ5+u+pDLIpWg="; + }; + "linux-arm64-debug" = { + "linux-arm64-flutter-gtk.zip" = "sha256-SiYOH++py4zeoD3BkNayqy/C9Zz9OiYQ5+u+pDLIpWg="; + }; + "linux-arm64-profile" = { + "linux-arm64-flutter-gtk.zip" = "sha256-xB0eqrBYD7vhOwYUgJwNaBftNZJgdwxA9AUpEfX0iFs="; + }; + "linux-arm64-release" = { + "linux-arm64-flutter-gtk.zip" = "sha256-aHLKV129WIRsLUG6xTMwCKB4eXD3jonqinjI8KSsOus="; + }; + "linux-x64" = { + "artifacts.zip" = "sha256-+zIABFXUpiqn3OMoLcU4NDLxZ1y9z0r46iCTNRHAkz8="; + "font-subset.zip" = "sha256-W4SRPvA4rraVqN1ehbY6MFL7ZIWDHVJhjlLtxyUJJKY="; + "linux-x64-flutter-gtk.zip" = "sha256-boICnuJF4zqGb7kaN5haO/df9hC9KeJidt3uIK06S7M="; + }; + "linux-x64-debug" = { + "linux-x64-flutter-gtk.zip" = "sha256-boICnuJF4zqGb7kaN5haO/df9hC9KeJidt3uIK06S7M="; + }; + "linux-x64-profile" = { + "linux-x64-flutter-gtk.zip" = "sha256-RAsgupVF18IxLaP8tJ7XRQ8y/um46nlpA8fDITPwLqY="; + }; + "linux-x64-release" = { + "linux-x64-flutter-gtk.zip" = "sha256-RAsgupVF18IxLaP8tJ7XRQ8y/um46nlpA8fDITPwLqY="; + }; + }; + "57d3bac3dd5cb5b0e464ab70e7bc8a0d8cf083ab" = { + "flutter_patched_sdk.zip" = "sha256-A/y5Y+Aw0CUhXABbdyQcGCSnSbO7Ask+71m8LZDSjH4="; + "flutter_patched_sdk_product.zip" = "sha256-VPxF4NrTUhFbpztyPnLEiC9Cy0kDDbYvy21kA5ES4HM="; + "android-arm" = { + "artifacts.zip" = "sha256-3igOO+rgFh0fNTIIiiucqSmqC+NKFPG5H1CnIa9bDcM="; + }; + "android-arm-profile" = { + "artifacts.zip" = "sha256-qai254LNrQXJBsaoQgXao6mBpzzcYHh4sUESurSyxNA="; + "linux-x64.zip" = "sha256-hBkntf1fX5w752ly6lVUHm6wEM/4ep9guJGma3SKjxU="; + }; + "android-arm-release" = { + "artifacts.zip" = "sha256-7yuXIJyErb1PZyk56+TtlJY0o1EOwmdAvpVfGGAteuA="; + "linux-x64.zip" = "sha256-v/jBnE662XOX/fOhYbve7ZiQwVu0haIMOD532Vdj9Yw="; + }; + "android-arm64" = { + "artifacts.zip" = "sha256-Llxu8+SkYEtnoiMf01rffPpF/AjrlV+QPuAW850oMzo="; + }; + "android-arm64-profile" = { + "artifacts.zip" = "sha256-su4U80supv8Q+2kE/5FTybiA5NFbKNMHqdB0NHCqrVI="; + "linux-x64.zip" = "sha256-yGt0SztNxYHDwZ1DwzLg5REE8rmMRKNn7GfCQ+GEHBw="; + }; + "android-arm64-release" = { + "artifacts.zip" = "sha256-+p1+SXSEglR3jqWc/jKgmtR9nOGgMRGC+anoTs1kRc8="; + "linux-x64.zip" = "sha256-5UiG5gxOso8NO+7nkb6bjxW8e/Tr7mlvPRUagSRTCNs="; + }; + "android-x86" = { + "artifacts.zip" = "sha256-Cbo17VYWaclyO1RLHkwjbqoFVZ283IgGdN0uDdiWvQs="; + }; + "android-x86-jit-release" = { + "artifacts.zip" = "sha256-gSPm2tClTj2vEYtGKgobD/mebWLNlDp8nEoFX0rhEOk="; + }; + "android-x64" = { + "artifacts.zip" = "sha256-PVb1aKMMTlDT41O2MZRAUjCq8h+m/s2h5qOnEFPd77w="; + }; + "android-x64-profile" = { + "artifacts.zip" = "sha256-gZSSRCDy42AMLMiu/KH7YsDuFVaxRcoyXzUgV8V025Y="; + "linux-x64.zip" = "sha256-9+LCjeI18u/GlPDMIl6Jx6b++lc90fJ5tVBlDR+ctDs="; + }; + "android-x64-release" = { + "artifacts.zip" = "sha256-rsS08VP86/b2S0TEYusCEJBvS4BuevsmV9REAxRgJIc="; + "linux-x64.zip" = "sha256-H4nFCJ+iCUzIwHogYzS+h33eDMaFnz71dcDLSQW1aPg="; + }; + "linux-arm64" = { + "artifacts.zip" = "sha256-kCxsKQQQX6wzhD46bfoflKdz3AYYkoSyavhfyTDuHLU="; + "font-subset.zip" = "sha256-Yk6JsNWe7ftEQU/TsjDUZSFeLzeIbcS63lhl8fsWsdk="; + "linux-arm64-flutter-gtk.zip" = "sha256-girVdkXrTO5tssoi+eKwG9ykstCR/VOx8zWtcAz8AKM="; + }; + "linux-arm64-debug" = { + "linux-arm64-flutter-gtk.zip" = "sha256-girVdkXrTO5tssoi+eKwG9ykstCR/VOx8zWtcAz8AKM="; + }; + "linux-arm64-profile" = { + "linux-arm64-flutter-gtk.zip" = "sha256-VL5cwYaZ1FOJ3TwJzbgvHDQwkU9NrHGnf/tQhZ/dAGg="; + }; + "linux-arm64-release" = { + "linux-arm64-flutter-gtk.zip" = "sha256-27hy7mLFCLkqJbn+5p5eJdYnfBKTyfFe98iUMmKyz4g="; + }; + "linux-x64" = { + "artifacts.zip" = "sha256-JgEX+rKxdcWBBaxyR42eC7qOAvaawF9M2+rfaD4IgeA="; + "font-subset.zip" = "sha256-5EoxBrxSjaLLd+rKrxVYNoUZaejk0qcQ5LVsmqtKc2g="; + "linux-x64-flutter-gtk.zip" = "sha256-MH5HDPoXXi/KpQLQ0U1tQzZ0sbZx1RVhZtQ7L+WhZgk="; + }; + "linux-x64-debug" = { + "linux-x64-flutter-gtk.zip" = "sha256-MH5HDPoXXi/KpQLQ0U1tQzZ0sbZx1RVhZtQ7L+WhZgk="; + }; + "linux-x64-profile" = { + "linux-x64-flutter-gtk.zip" = "sha256-r2hB/AKrB5vNga2fve4tTM4j+Zp9KDqNlTjKQhQvbaI="; + }; + "linux-x64-release" = { + "linux-x64-flutter-gtk.zip" = "sha256-muREs2iUiHCZM+SGN5q3HRRGnejJapKN582Aeog49MI="; + }; + }; +} diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index e332af2e35602..5a4b3ee018d23 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -2,27 +2,75 @@ , patches , dart , src +, includedEngineArtifacts ? { + common = [ + "flutter_patched_sdk" + "flutter_patched_sdk_product" + ]; + platform = { + android = lib.optionalAttrs stdenv.hostPlatform.isx86_64 + ((lib.genAttrs [ "arm" "arm64" "x64" ] (architecture: [ "profile" "release" ])) // { x86 = [ "jit-release" ]; }); + linux = lib.optionals stdenv.hostPlatform.isLinux + (lib.genAttrs ((lib.optional stdenv.hostPlatform.isx86_64 "x64") ++ (lib.optional stdenv.hostPlatform.isAarch64 "arm64")) + (architecture: [ "debug" "profile" "release" ])); + }; + } , lib , callPackage , stdenv -, autoPatchelfHook +, runCommandLocal +, symlinkJoin +, lndir , git , which -, atk -, glib -, gtk3 -, libepoxy -}: +}@args: let - # Libraries that Flutter artifacts depend on at runtime. - artifactRuntimeDeps = [ - atk - glib - gtk3 - libepoxy - ]; + engineArtifactDirectory = + let + engineArtifacts = callPackage ./engine-artifacts { + engineVersion = lib.removeSuffix "\n" (builtins.readFile (src + /bin/internal/engine.version)); + }; + in + runCommandLocal "flutter-engine-artifacts-${version}" { } + ( + let + mkCommonArtifactLinkCommand = { artifact }: + '' + mkdir -p $out/common + ${lndir}/bin/lndir -silent ${artifact} $out/common + ''; + mkPlatformArtifactLinkCommand = { artifact, os, architecture, variant ? null }: + let + artifactDirectory = "${os}-${architecture}${lib.optionalString (variant != null) "-${variant}"}"; + in + '' + mkdir -p $out/${artifactDirectory} + ${lndir}/bin/lndir -silent ${artifact} $out/${artifactDirectory} + ''; + in + '' + ${ + builtins.concatStringsSep "\n" + ((map (name: mkCommonArtifactLinkCommand { + artifact = engineArtifacts.common.${name}; + }) (if includedEngineArtifacts ? common then includedEngineArtifacts.common else [ ])) ++ + (builtins.foldl' (commands: os: commands ++ + (builtins.foldl' (commands: architecture: commands ++ + (builtins.foldl' (commands: variant: commands ++ + (map (artifact: mkPlatformArtifactLinkCommand { + inherit artifact os architecture variant; + }) engineArtifacts.platform.${os}.${architecture}.variants.${variant})) + (map (artifact: mkPlatformArtifactLinkCommand { + inherit artifact os architecture; + }) engineArtifacts.platform.${os}.${architecture}.base) + includedEngineArtifacts.platform.${os}.${architecture})) + [] (builtins.attrNames includedEngineArtifacts.platform.${os}))) + [] (builtins.attrNames (if includedEngineArtifacts ? platform then includedEngineArtifacts.platform else { })))) + } + '' + ); unwrapped = stdenv.mkDerivation { @@ -31,8 +79,7 @@ let outputs = [ "out" "cache" ]; - nativeBuildInputs = [ autoPatchelfHook ]; - buildInputs = [ git ] ++ artifactRuntimeDeps; + buildInputs = [ git ]; postPatch = '' patchShebangs --build ./bin/ @@ -75,7 +122,10 @@ let echo "$revision" > "$STAMP_PATH" echo -n "${version}" > version - rm -r bin/cache/dart-sdk + # Certain prebuilts should be replaced with Nix-built (or at least Nix-patched) equivalents. + rm -r \ + bin/cache/dart-sdk \ + bin/cache/artifacts/engine ''; installPhase = '' @@ -83,8 +133,8 @@ let mkdir -p $out cp -r . $out - mkdir -p $out/bin/cache/ ln -sf ${dart} $out/bin/cache/dart-sdk + ln -sf ${engineArtifactDirectory} $out/bin/cache/artifacts/engine runHook postInstall ''; @@ -110,7 +160,17 @@ let # found here should be included as-is, for tooling compatibility. sdk = unwrapped; mkFlutterApp = callPackage ../../../build-support/flutter { - flutter = callPackage ./wrapper.nix { flutter = unwrapped; }; + # Package a minimal version of Flutter that only uses Linux desktop release artifacts. + flutter = callPackage ./wrapper.nix { + flutter = callPackage ./flutter.nix (args // { + includedEngineArtifacts = { + common = [ "flutter_patched_sdk_product" ]; + platform.linux = lib.optionals stdenv.hostPlatform.isLinux + (lib.genAttrs ((lib.optional stdenv.hostPlatform.isx86_64 "x64") ++ (lib.optional stdenv.hostPlatform.isAarch64 "arm64")) + (architecture: [ "release" ])); + }; + }); + }; }; }; @@ -125,7 +185,6 @@ let platforms = [ "x86_64-linux" "aarch64-linux" ]; maintainers = with maintainers; [ babariviere ericdallo FlafyDev gilice hacker1024 ]; }; - } - ; + }; in unwrapped -- cgit 1.4.1 From fdce3f30c4bde2ed4f7bef3f65f5dfc2a673f0ff Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sat, 15 Apr 2023 03:18:56 +1000 Subject: flutter.mkFlutterApp: Don't hash more unstable files Files and directories such as .dart_tool, .flutter-plugins, .packages and .pub-cache/hosted/*/.cache will be happily regenerated by the SDK in an offline environment. The patches being made to these files and directories to remove non-determinism were flawed: They did not handle cases where files only appeared in one run, or cases where tooling versions had an effect on the output. --- .../applications/misc/yubioath-flutter/default.nix | 2 +- pkgs/build-support/flutter/default.nix | 28 ++++------------------ .../linux/firmware/firmware-updater/default.nix | 2 +- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/pkgs/applications/misc/yubioath-flutter/default.nix b/pkgs/applications/misc/yubioath-flutter/default.nix index f1e0094468a74..3e2f8116a88dc 100644 --- a/pkgs/applications/misc/yubioath-flutter/default.nix +++ b/pkgs/applications/misc/yubioath-flutter/default.nix @@ -21,7 +21,7 @@ flutter.mkFlutterApp rec { passthru.helper = python3.pkgs.callPackage ./helper.nix { inherit src version meta; }; - vendorHash = "sha256-1ast8pm9wrt9nqLt5MJ2LkiZivlm9d+qcKrz/d8VVmI="; + vendorHash = "sha256-/WP6oN5avAILZd3SkC/jmsqNL+BxdQGUjNwsjLF9RB4="; postPatch = '' substituteInPlace linux/CMakeLists.txt \ diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 58149525b476d..f83998f3f9f79 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -43,13 +43,9 @@ let RES="$TMP" - mkdir -p "$RES/f" - # so we can use lock, diff yaml cp "pubspec.yaml" "$RES" cp "pubspec.lock" "$RES" - [[ -e .packages ]] && mv .packages "$RES/f" - mv .dart_tool .flutter-plugins .flutter-plugins-dependencies "$RES/f" # replace paths with placeholders find "$RES" -type f -exec sed -i \ @@ -57,30 +53,16 @@ let -e s,${flutter.unwrapped},${placeholder_flutter},g \ {} + - remove_line_matching() { - replace_line_matching "$1" "$2" "" - } - - replace_line_matching() { - sed "s|.*$2.*|$3|g" -r -i "$1" - } - # nuke nondeterminism - # clientId is random - remove_line_matching "$RES/.flutter" clientId - # deterministic git repos find "$RES" -iname .git -type d | while read -r repoGit; do make_deterministic_repo "$(dirname "$repoGit")" done - # dart _fetchedAt, etc - DART_DATE=$(date --date="@$SOURCE_DATE_EPOCH" -In | sed "s|,|.|g" | sed "s|+.*||g") - find "$RES/.pub-cache" -iname "*.json" -exec sed -r 's|.*_fetchedAt.*| "_fetchedAt": "'"$DART_DATE"'",|g' -i {} + - replace_line_matching "$RES/f/.dart_tool/package_config.json" '"generated"' '"generated": "'"$DART_DATE"'",' - replace_line_matching "$RES/f/.flutter-plugins-dependencies" '"date_created"' '"date_created": "'"$DART_DATE"'",' - [[ -e "$RES/f/.packages" ]] && remove_line_matching "$RES/f/.packages" "Generated by pub" + # Impure Pub files + rm -rf "$RES"/.pub-cache/hosted/*/.cache # Not pinned by pubspec.lock + rm -f "$RES"/.pub-cache/README.md # May change with different Dart versions # nuke refs find "$RES" -type f -exec nuke-refs {} + @@ -89,7 +71,7 @@ let tar --owner=0 --group=0 --numeric-owner --format=gnu \ --sort=name --mtime="@$SOURCE_DATE_EPOCH" \ -czf "$out" -C "$RES" \ - pubspec.yaml pubspec.lock f .pub-cache + pubspec.yaml pubspec.lock .pub-cache ''; GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt"; @@ -148,8 +130,6 @@ let fi diff -u pubspec.yaml "$HOME/pubspec.yaml" - mv -v $(find "$HOME/f" -type f) . - runHook postConfigure ''; diff --git a/pkgs/os-specific/linux/firmware/firmware-updater/default.nix b/pkgs/os-specific/linux/firmware/firmware-updater/default.nix index 696704d3c4d4f..12f5fe13a6a3a 100644 --- a/pkgs/os-specific/linux/firmware/firmware-updater/default.nix +++ b/pkgs/os-specific/linux/firmware/firmware-updater/default.nix @@ -7,7 +7,7 @@ flutter2.mkFlutterApp { pname = "firmware-updater"; version = "unstable"; - vendorHash = "sha256-QPLAMFL/enMfbmUZx6qQSswI/vxeWgjytRdoNxziQ18="; + vendorHash = "sha256-Pj6CU2W5juk4YE8oq+v7Z8CzuSwpyA3YqscoWGDaI4o="; src = fetchFromGitHub { owner = "canonical"; -- cgit 1.4.1 From b187edb802c25abd103aa71eb7f00663e25333d4 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sat, 15 Apr 2023 19:25:01 +1000 Subject: flutter: Pass through the version attribute in the wrapper --- pkgs/development/compilers/flutter/wrapper.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index c2b1ee19cd52e..fe7d95b61809e 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -82,6 +82,7 @@ in nativeBuildInputs = [ makeWrapper ]; passthru = flutter.passthru // { + inherit (flutter) version; unwrapped = flutter; }; -- cgit 1.4.1 From c3a87421ae381ee68cd8f64f0be29616df8bdb25 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sat, 15 Apr 2023 19:52:12 +1000 Subject: flutter: Don't tarball the package cache Co-authored-by: FlafyDev The dependency fixed-output derivation now uses the recursive hash mode to avoid tarballing and copying all the files. https://github.com/NixOS/nix/issues/6660 was ran into during the development of this change. Input references were found in the Git package cache before nukeReferences was used. It turns out that the mirrors in the Git package cache do not actually need to be preserved, as the SDK does not use them during the build process. They are therefore deleted in the dependency derivation and re-created as blank repositories in the main derivation. A description of the Git package cache layout can be found here: https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/source/git.dart#L339 --- .../applications/misc/yubioath-flutter/default.nix | 2 +- pkgs/build-support/flutter/default.nix | 95 ++++++++++++---------- .../linux/firmware/firmware-updater/default.nix | 2 +- 3 files changed, 53 insertions(+), 46 deletions(-) diff --git a/pkgs/applications/misc/yubioath-flutter/default.nix b/pkgs/applications/misc/yubioath-flutter/default.nix index 3e2f8116a88dc..fc1d366fa6015 100644 --- a/pkgs/applications/misc/yubioath-flutter/default.nix +++ b/pkgs/applications/misc/yubioath-flutter/default.nix @@ -21,7 +21,7 @@ flutter.mkFlutterApp rec { passthru.helper = python3.pkgs.callPackage ./helper.nix { inherit src version meta; }; - vendorHash = "sha256-/WP6oN5avAILZd3SkC/jmsqNL+BxdQGUjNwsjLF9RB4="; + vendorHash = "sha256-OU433z6Cz+jNJAjIiPO6cxySyejQ4SpSvuUHJsdT8TA="; postPatch = '' substituteInPlace linux/CMakeLists.txt \ diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index f83998f3f9f79..f40c2736f24ab 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -1,6 +1,5 @@ { lib , stdenvNoCC -, nukeReferences , llvmPackages_13 , cacert , flutter @@ -19,12 +18,11 @@ let self = (self: llvmPackages_13.stdenv.mkDerivation (args // { deps = stdenvNoCC.mkDerivation (lib.recursiveUpdate (getAttrsOrNull fetchAttrs args) { - name = "${self.name}-deps-flutter-v${flutter.unwrapped.version}.tar.gz"; + name = "${self.name}-deps-flutter"; nativeBuildInputs = [ flutter git - nukeReferences ]; # avoid pub phase @@ -36,42 +34,33 @@ let TMP=$(mktemp -d) export HOME="$TMP" + # Configure the package cache + export PUB_CACHE="$out/cache/.pub-cache" + mkdir -p "$PUB_CACHE" + flutter config --no-analytics &>/dev/null # mute first-run flutter config --enable-linux-desktop flutter packages get ${lib.optionalString (args ? flutterExtraFetchCommands) args.flutterExtraFetchCommands} - RES="$TMP" - # so we can use lock, diff yaml - cp "pubspec.yaml" "$RES" - cp "pubspec.lock" "$RES" - - # replace paths with placeholders - find "$RES" -type f -exec sed -i \ - -e s,$TMP,${placeholder_deps},g \ - -e s,${flutter.unwrapped},${placeholder_flutter},g \ - {} + + mkdir -p "$out/pubspec" + cp "pubspec.yaml" "$out/pubspec" + cp "pubspec.lock" "$out/pubspec" # nuke nondeterminism # deterministic git repos - find "$RES" -iname .git -type d | while read -r repoGit; do + find "$PUB_CACHE" -iname .git -type d | while read -r repoGit; do make_deterministic_repo "$(dirname "$repoGit")" done - # Impure Pub files - rm -rf "$RES"/.pub-cache/hosted/*/.cache # Not pinned by pubspec.lock - rm -f "$RES"/.pub-cache/README.md # May change with different Dart versions - - # nuke refs - find "$RES" -type f -exec nuke-refs {} + - - # Build a reproducible tar, per instructions at https://reproducible-builds.org/docs/archives/ - tar --owner=0 --group=0 --numeric-owner --format=gnu \ - --sort=name --mtime="@$SOURCE_DATE_EPOCH" \ - -czf "$out" -C "$RES" \ - pubspec.yaml pubspec.lock .pub-cache + # Impure package cache files + rm -rf "$PUB_CACHE"/hosted/*/.cache # Not pinned by pubspec.lock + rm -f "$PUB_CACHE"/README.md # May change with different Dart versions + rm -rf "$PUB_CACHE"/_temp # https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/system_cache.dart#L131 + rm -rf "$PUB_CACHE"/log # https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/command.dart#L348 + rm -rf "$PUB_CACHE"/git/cache/*/* # Recreate this on the other end. See: https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/source/git.dart#L531 ''; GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt"; @@ -84,51 +73,71 @@ let # unnecesarry dontFixup = true; + # Patching shebangs introduces input references to this fixed-output derivation. + # This triggers a bug in Nix, causing the output path to change unexpectedly. + # https://github.com/NixOS/nix/issues/6660 + dontPatchShebangs = true; + outputHashAlgo = if self ? vendorHash then null else "sha256"; - # outputHashMode = "recursive"; + outputHashMode = "recursive"; outputHash = if self ? vendorHash then self.vendorHash else if self ? vendorSha256 then self.vendorSha256 else lib.fakeSha256; - }); - nativeBuildInputs = [ flutter ] ++ lib.optionals (args ? nativeBuildInputs) args.nativeBuildInputs; + nativeBuildInputs = [ + flutter + git + ] ++ lib.optionals (args ? nativeBuildInputs) args.nativeBuildInputs; buildInputs = lib.optionals (args ? buildInputs) args.buildInputs; configurePhase = '' runHook preConfigure - # for some reason fluffychat build breaks without this - seems file gets overriden by some tool - cp pubspec.yaml pubspec-backup - TMP=$(mktemp -d) export HOME="$TMP" flutter config --no-analytics &>/dev/null # mute first-run flutter config --enable-linux-desktop - # extract deps - tar xzf "$deps" -C "$HOME" + # Configure the package cache + export PUB_CACHE="$TMP/.pub-cache" + mkdir -p "$PUB_CACHE" + + # Link the Git package cache. + mkdir -p "$PUB_CACHE/git" + ln -s "$deps/cache/.pub-cache/git"/* "$PUB_CACHE/git" + + # Recreate the internal Git cache subdirectory. + # See: https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/source/git.dart#L339) + # Blank repositories are created instead of attempting to match the cache mirrors to checkouts. + # This is not an issue, as pub does not need the mirrors in the Flutter build process. + rm "$PUB_CACHE/git/cache" && mkdir "$PUB_CACHE/git/cache" + for mirror in $(ls -A "$deps/cache/.pub-cache/git/cache"); do + git --git-dir="$PUB_CACHE/git/cache/$mirror" init --bare --quiet + done - # after extracting update paths to point to real paths - find "$HOME" -type f -exec sed -i \ - -e s,${placeholder_deps},"$HOME",g \ - -e s,${placeholder_flutter},${flutter},g \ - {} + + # Link the remaining package cache directories. + # At this point, any subdirectories that must be writable must have been taken care of. + for file in $(comm -23 <(ls -A "$deps/cache/.pub-cache") <(ls -A "$PUB_CACHE")); do + ln -s "$deps/cache/.pub-cache/$file" "$PUB_CACHE/$file" + done # ensure we're using a lockfile for the right package version if [ -e pubspec.lock ]; then # FIXME: currently this is broken. in theory this should not break, but flutter has it's own way of doing things. - # diff -u pubspec.lock "$HOME/pubspec.lock" + # diff -u pubspec.lock "$deps/pubspec/pubspec.lock" true else - cp -v "$HOME/pubspec.lock" . + cp -v "$deps/pubspec/pubspec.lock" . + # Sometimes the pubspec.lock will get opened in write mode, even when offline. + chmod u+w pubspec.lock fi - diff -u pubspec.yaml "$HOME/pubspec.yaml" + diff -u pubspec.yaml "$deps/pubspec/pubspec.yaml" runHook postConfigure ''; @@ -136,8 +145,6 @@ let buildPhase = '' runHook preBuild - # for some reason fluffychat build breaks without this - seems file gets overriden by some tool - mv pubspec-backup pubspec.yaml mkdir -p build/flutter_assets/fonts flutter packages get --offline -v diff --git a/pkgs/os-specific/linux/firmware/firmware-updater/default.nix b/pkgs/os-specific/linux/firmware/firmware-updater/default.nix index 12f5fe13a6a3a..267440c32985d 100644 --- a/pkgs/os-specific/linux/firmware/firmware-updater/default.nix +++ b/pkgs/os-specific/linux/firmware/firmware-updater/default.nix @@ -7,7 +7,7 @@ flutter2.mkFlutterApp { pname = "firmware-updater"; version = "unstable"; - vendorHash = "sha256-Pj6CU2W5juk4YE8oq+v7Z8CzuSwpyA3YqscoWGDaI4o="; + vendorHash = "sha256-kKfe+7obb2fihrca+mjCM2+51wNkbPLEPFLpXzK5Wvc="; src = fetchFromGitHub { owner = "canonical"; -- cgit 1.4.1 From f00f918e274bcba8e2265f97cf472bb7fa981d51 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sat, 15 Apr 2023 20:30:46 +1000 Subject: flutter: Remove cached Git package Git directories Pub does not perform any Git operations on the cached package directly, instead cloning it through a mirror. The .git directories are not needed, and are a source of non-determinism. --- pkgs/build-support/flutter/default.nix | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index f40c2736f24ab..2fec501de3ea8 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -29,8 +29,6 @@ let dontBuild = true; installPhase = '' - . ${../fetchgit/deterministic-git} - TMP=$(mktemp -d) export HOME="$TMP" @@ -50,17 +48,18 @@ let # nuke nondeterminism - # deterministic git repos - find "$PUB_CACHE" -iname .git -type d | while read -r repoGit; do - make_deterministic_repo "$(dirname "$repoGit")" - done + # Remove Git directories in the Git package cache - these are rarely used by Pub, + # which instead maintains a corresponsing mirror and clones cached packages through it. + find "$PUB_CACHE" -name .git -type d -prune -exec rm -rf {} + - # Impure package cache files + # Remove continuously updated package metadata caches rm -rf "$PUB_CACHE"/hosted/*/.cache # Not pinned by pubspec.lock + rm -rf "$PUB_CACHE"/git/cache/*/* # Recreate this on the other end. See: https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/source/git.dart#L531 + + # Miscelaneous transient package cache files rm -f "$PUB_CACHE"/README.md # May change with different Dart versions rm -rf "$PUB_CACHE"/_temp # https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/system_cache.dart#L131 rm -rf "$PUB_CACHE"/log # https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/command.dart#L348 - rm -rf "$PUB_CACHE"/git/cache/*/* # Recreate this on the other end. See: https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/source/git.dart#L531 ''; GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt"; -- cgit 1.4.1 From 607a57d48e9f2f61fdb93f4f76310536b0a38273 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sat, 15 Apr 2023 20:57:21 +1000 Subject: flutter.mkFlutterApp: Rename to flutter.buildFlutterApplication This fits more appropriately with other build derivations like buildPythonApplication. --- pkgs/applications/misc/yubioath-flutter/default.nix | 2 +- pkgs/development/compilers/flutter/flutter.nix | 2 +- pkgs/os-specific/linux/firmware/firmware-updater/default.nix | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/misc/yubioath-flutter/default.nix b/pkgs/applications/misc/yubioath-flutter/default.nix index fc1d366fa6015..c0931df476020 100644 --- a/pkgs/applications/misc/yubioath-flutter/default.nix +++ b/pkgs/applications/misc/yubioath-flutter/default.nix @@ -8,7 +8,7 @@ , removeReferencesTo }: -flutter.mkFlutterApp rec { +flutter.buildFlutterApplication rec { pname = "yubioath-flutter"; version = "6.1.0"; diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index 5a4b3ee018d23..a566a543e4184 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -159,7 +159,7 @@ let # When other derivations wrap this one, any unmodified files # found here should be included as-is, for tooling compatibility. sdk = unwrapped; - mkFlutterApp = callPackage ../../../build-support/flutter { + buildFlutterApplication = callPackage ../../../build-support/flutter { # Package a minimal version of Flutter that only uses Linux desktop release artifacts. flutter = callPackage ./wrapper.nix { flutter = callPackage ./flutter.nix (args // { diff --git a/pkgs/os-specific/linux/firmware/firmware-updater/default.nix b/pkgs/os-specific/linux/firmware/firmware-updater/default.nix index 267440c32985d..a15005cf7463c 100644 --- a/pkgs/os-specific/linux/firmware/firmware-updater/default.nix +++ b/pkgs/os-specific/linux/firmware/firmware-updater/default.nix @@ -3,7 +3,7 @@ , fetchFromGitHub }: -flutter2.mkFlutterApp { +flutter2.buildFlutterApplication { pname = "firmware-updater"; version = "unstable"; -- cgit 1.4.1 From 915a6779fc28fe545a3393e2db1fccfc40d40380 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 16 Apr 2023 00:17:41 +1000 Subject: flutter.buildFlutterApplication: Refactor dependency setup as a standalone derivation with an output hook This allows anything that needs to build a Dart application (such as a future `buildDartApplication` function) to use the same setup. --- .../build-support/dart/fetch-dart-deps/default.nix | 133 ++++++++++++++++++++ .../dart/fetch-dart-deps/setup-hook.sh | 42 +++++++ pkgs/build-support/flutter/default.nix | 139 +++------------------ 3 files changed, 195 insertions(+), 119 deletions(-) create mode 100644 pkgs/build-support/dart/fetch-dart-deps/default.nix create mode 100644 pkgs/build-support/dart/fetch-dart-deps/setup-hook.sh diff --git a/pkgs/build-support/dart/fetch-dart-deps/default.nix b/pkgs/build-support/dart/fetch-dart-deps/default.nix new file mode 100644 index 0000000000000..4bb5f257032d4 --- /dev/null +++ b/pkgs/build-support/dart/fetch-dart-deps/default.nix @@ -0,0 +1,133 @@ +{ stdenvNoCC +, lib +, makeSetupHook +, dart +, git +, cacert +}: + +{ + # The output hash of the dependencies for this project. + vendorHash ? "" + # Commands to run once before using Dart or pub. +, sdkSetupScript ? "" + # Commands to run to populate the pub cache. +, pubGetScript ? "dart pub get" + # Arguments used in the derivation that builds the Dart package. + # Passing these is recommended to ensure that the same steps are made to prepare the sources in both this + # derivation and the one that builds the Dart package. +, buildDrvArgs ? { } +, ... +}@args: + +# This is a fixed-output derivation and setup hook that can be used to fetch dependencies for Dart projects. +# It is designed to be placed in the nativeBuildInputs of a derivation that builds a Dart package. +# Providing the buildDrvArgs argument is highly recommended. +let + buildDrvInheritArgNames = [ + "name" + "pname" + "version" + "src" + "sourceRoot" + "setSourceRoot" + "preUnpack" + "unpackPhase" + "unpackCmd" + "postUnpack" + "prePatch" + "patchPhase" + "patches" + "patchFlags" + "postPatch" + ]; + + buildDrvInheritArgs = builtins.foldl' + (attrs: arg: + if buildDrvArgs ? ${arg} + then attrs // { ${arg} = buildDrvArgs.${arg}; } + else attrs) + { } + buildDrvInheritArgNames; + + drvArgs = buildDrvInheritArgs // (removeAttrs args [ "buildDrvArgs" ]); + name = (if drvArgs ? name then drvArgs.name else "${drvArgs.pname}-${drvArgs.version}"); + + deps = + # This + stdenvNoCC.mkDerivation ({ + name = "${name}-dart-deps"; + + nativeBuildInputs = [ + dart + git + ]; + + # avoid pub phase + dontBuild = true; + + configurePhase = '' + # Configure the package cache + export PUB_CACHE="$out/cache/.pub-cache" + mkdir -p "$PUB_CACHE" + + ${sdkSetupScript} + ''; + + installPhase = '' + ${pubGetScript} + + # so we can use lock, diff yaml + mkdir -p "$out/pubspec" + cp "pubspec.yaml" "$out/pubspec" + cp "pubspec.lock" "$out/pubspec" + + # nuke nondeterminism + + # Remove Git directories in the Git package cache - these are rarely used by Pub, + # which instead maintains a corresponsing mirror and clones cached packages through it. + find "$PUB_CACHE" -name .git -type d -prune -exec rm -rf {} + + + # Remove continuously updated package metadata caches + rm -rf "$PUB_CACHE"/hosted/*/.cache # Not pinned by pubspec.lock + rm -rf "$PUB_CACHE"/git/cache/*/* # Recreate this on the other end. See: https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/source/git.dart#L531 + + # Miscelaneous transient package cache files + rm -f "$PUB_CACHE"/README.md # May change with different Dart versions + rm -rf "$PUB_CACHE"/_temp # https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/system_cache.dart#L131 + rm -rf "$PUB_CACHE"/log # https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/command.dart#L348 + ''; + + GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt"; + SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt"; + + impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ + "GIT_PROXY_COMMAND" + "NIX_GIT_SSL_CAINFO" + "SOCKS_SERVER" + ]; + + # Patching shebangs introduces input references to this fixed-output derivation. + # This triggers a bug in Nix, causing the output path to change unexpectedly. + # https://github.com/NixOS/nix/issues/6660 + dontPatchShebangs = true; + + # The following operations are not generally useful for this derivation. + # If a package does contain some native components used at build time, + # please file an issue. + dontStrip = true; + dontMoveSbin = true; + dontPatchELF = true; + + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; + outputHash = if vendorHash != "" then vendorHash else lib.fakeSha256; + } // drvArgs); +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; }; +}) ./setup-hook.sh diff --git a/pkgs/build-support/dart/fetch-dart-deps/setup-hook.sh b/pkgs/build-support/dart/fetch-dart-deps/setup-hook.sh new file mode 100644 index 0000000000000..dcb0cc0622e8d --- /dev/null +++ b/pkgs/build-support/dart/fetch-dart-deps/setup-hook.sh @@ -0,0 +1,42 @@ +preConfigureHooks+=(_setupPubCache) + +_setupPubCache() { + deps="@deps@" + + # Configure the package cache. + export PUB_CACHE="$(mktemp -d)" + mkdir -p "$PUB_CACHE" + + if [ -d "$deps/cache/.pub-cache/git" ]; then + # Link the Git package cache. + mkdir -p "$PUB_CACHE/git" + ln -s "$deps/cache/.pub-cache/git"/* "$PUB_CACHE/git" + + # Recreate the internal Git cache subdirectory. + # See: https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/source/git.dart#L339) + # Blank repositories are created instead of attempting to match the cache mirrors to checkouts. + # This is not an issue, as pub does not need the mirrors in the Flutter build process. + rm "$PUB_CACHE/git/cache" && mkdir "$PUB_CACHE/git/cache" + for mirror in $(ls -A "$deps/cache/.pub-cache/git/cache"); do + git --git-dir="$PUB_CACHE/git/cache/$mirror" init --bare --quiet + done + fi + + # Link the remaining package cache directories. + # At this point, any subdirectories that must be writable must have been taken care of. + for file in $(comm -23 <(ls -A "$deps/cache/.pub-cache") <(ls -A "$PUB_CACHE")); do + ln -s "$deps/cache/.pub-cache/$file" "$PUB_CACHE/$file" + done + + # ensure we're using a lockfile for the right package version + if [ -e pubspec.lock ]; then + # FIXME: currently this is broken. in theory this should not break, but flutter has it's own way of doing things. + # diff -u pubspec.lock "$deps/pubspec/pubspec.lock" + true + else + cp -v "$deps/pubspec/pubspec.lock" . + # Sometimes the pubspec.lock will get opened in write mode, even when offline. + chmod u+w pubspec.lock + fi + diff -u pubspec.yaml "$deps/pubspec/pubspec.yaml" +} diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 2fec501de3ea8..f148c3d046e44 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -1,4 +1,5 @@ { lib +, callPackage , stdenvNoCC , llvmPackages_13 , cacert @@ -8,135 +9,35 @@ # absolutely no mac support for now -args: +{ pubGetScript ? "flutter pub get" +, vendorHash +, nativeBuildInputs ? [ ] +, ... +}@args: let - pl = n: "##FLUTTER_${n}_PLACEHOLDER_MARKER##"; - placeholder_deps = pl "DEPS"; - placeholder_flutter = pl "FLUTTER"; - fetchAttrs = [ "src" "sourceRoot" "setSourceRoot" "unpackPhase" "patches" ]; - getAttrsOrNull = names: attrs: lib.genAttrs names (name: if attrs ? ${name} then attrs.${name} else null); + flutterSetupScript = '' + export HOME="$NIX_BUILD_TOP" + flutter config --no-analytics &>/dev/null # mute first-run + flutter config --enable-linux-desktop >/dev/null + ''; + + deps = callPackage ../dart/fetch-dart-deps { dart = flutter; } { + sdkSetupScript = flutterSetupScript; + inherit pubGetScript vendorHash; + buildDrvArgs = args; + }; self = (self: llvmPackages_13.stdenv.mkDerivation (args // { - deps = stdenvNoCC.mkDerivation (lib.recursiveUpdate (getAttrsOrNull fetchAttrs args) { - name = "${self.name}-deps-flutter"; - - nativeBuildInputs = [ - flutter - git - ]; - - # avoid pub phase - dontBuild = true; - - installPhase = '' - TMP=$(mktemp -d) - export HOME="$TMP" - - # Configure the package cache - export PUB_CACHE="$out/cache/.pub-cache" - mkdir -p "$PUB_CACHE" - - flutter config --no-analytics &>/dev/null # mute first-run - flutter config --enable-linux-desktop - flutter packages get - ${lib.optionalString (args ? flutterExtraFetchCommands) args.flutterExtraFetchCommands} - - # so we can use lock, diff yaml - mkdir -p "$out/pubspec" - cp "pubspec.yaml" "$out/pubspec" - cp "pubspec.lock" "$out/pubspec" - - # nuke nondeterminism - - # Remove Git directories in the Git package cache - these are rarely used by Pub, - # which instead maintains a corresponsing mirror and clones cached packages through it. - find "$PUB_CACHE" -name .git -type d -prune -exec rm -rf {} + - - # Remove continuously updated package metadata caches - rm -rf "$PUB_CACHE"/hosted/*/.cache # Not pinned by pubspec.lock - rm -rf "$PUB_CACHE"/git/cache/*/* # Recreate this on the other end. See: https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/source/git.dart#L531 - - # Miscelaneous transient package cache files - rm -f "$PUB_CACHE"/README.md # May change with different Dart versions - rm -rf "$PUB_CACHE"/_temp # https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/system_cache.dart#L131 - rm -rf "$PUB_CACHE"/log # https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/command.dart#L348 - ''; - - GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt"; - SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt"; - - impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ - "GIT_PROXY_COMMAND" "NIX_GIT_SSL_CAINFO" "SOCKS_SERVER" - ]; - - # unnecesarry - dontFixup = true; - - # Patching shebangs introduces input references to this fixed-output derivation. - # This triggers a bug in Nix, causing the output path to change unexpectedly. - # https://github.com/NixOS/nix/issues/6660 - dontPatchShebangs = true; - - outputHashAlgo = if self ? vendorHash then null else "sha256"; - outputHashMode = "recursive"; - outputHash = if self ? vendorHash then - self.vendorHash - else if self ? vendorSha256 then - self.vendorSha256 - else - lib.fakeSha256; - }); - nativeBuildInputs = [ + deps flutter git - ] ++ lib.optionals (args ? nativeBuildInputs) args.nativeBuildInputs; - - buildInputs = lib.optionals (args ? buildInputs) args.buildInputs; + ] ++ nativeBuildInputs; configurePhase = '' runHook preConfigure - TMP=$(mktemp -d) - export HOME="$TMP" - - flutter config --no-analytics &>/dev/null # mute first-run - flutter config --enable-linux-desktop - - # Configure the package cache - export PUB_CACHE="$TMP/.pub-cache" - mkdir -p "$PUB_CACHE" - - # Link the Git package cache. - mkdir -p "$PUB_CACHE/git" - ln -s "$deps/cache/.pub-cache/git"/* "$PUB_CACHE/git" - - # Recreate the internal Git cache subdirectory. - # See: https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/source/git.dart#L339) - # Blank repositories are created instead of attempting to match the cache mirrors to checkouts. - # This is not an issue, as pub does not need the mirrors in the Flutter build process. - rm "$PUB_CACHE/git/cache" && mkdir "$PUB_CACHE/git/cache" - for mirror in $(ls -A "$deps/cache/.pub-cache/git/cache"); do - git --git-dir="$PUB_CACHE/git/cache/$mirror" init --bare --quiet - done - - # Link the remaining package cache directories. - # At this point, any subdirectories that must be writable must have been taken care of. - for file in $(comm -23 <(ls -A "$deps/cache/.pub-cache") <(ls -A "$PUB_CACHE")); do - ln -s "$deps/cache/.pub-cache/$file" "$PUB_CACHE/$file" - done - - # ensure we're using a lockfile for the right package version - if [ -e pubspec.lock ]; then - # FIXME: currently this is broken. in theory this should not break, but flutter has it's own way of doing things. - # diff -u pubspec.lock "$deps/pubspec/pubspec.lock" - true - else - cp -v "$deps/pubspec/pubspec.lock" . - # Sometimes the pubspec.lock will get opened in write mode, even when offline. - chmod u+w pubspec.lock - fi - diff -u pubspec.yaml "$deps/pubspec/pubspec.yaml" + ${flutterSetupScript} runHook postConfigure ''; -- cgit 1.4.1 From 4e68ee327e38541f0edf4d1d8d757f5ca914a055 Mon Sep 17 00:00:00 2001 From: gilice <104317939+gilice@users.noreply.github.com> Date: Sun, 16 Apr 2023 00:31:12 +1000 Subject: flutter.buildFlutterApplication: Add an explanation when a pubspec mismatch occurs --- pkgs/build-support/dart/fetch-dart-deps/setup-hook.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 dcb0cc0622e8d..eaca3a31e7db9 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/setup-hook.sh +++ b/pkgs/build-support/dart/fetch-dart-deps/setup-hook.sh @@ -38,5 +38,9 @@ _setupPubCache() { # Sometimes the pubspec.lock will get opened in write mode, even when offline. chmod u+w pubspec.lock fi - diff -u pubspec.yaml "$deps/pubspec/pubspec.yaml" + if ! diff -u pubspec.yaml "$deps/pubspec/pubspec.yaml"; then + echo 1>&2 -e 'The pubspec.yaml of the project derivation differs from the one in the dependency derivation.' \ + '\nYou most likely forgot to update the vendorHash while updating the sources.' + exit 1 + fi } -- cgit 1.4.1 From d2ab34122d2f0b103a91d9ab05f327b09d3090b9 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 16 Apr 2023 00:55:55 +1000 Subject: dart.fetch-dart-deps: Remove stray comment from the dependency derivation --- pkgs/build-support/dart/fetch-dart-deps/default.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/build-support/dart/fetch-dart-deps/default.nix b/pkgs/build-support/dart/fetch-dart-deps/default.nix index 4bb5f257032d4..58f108cd68324 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/default.nix +++ b/pkgs/build-support/dart/fetch-dart-deps/default.nix @@ -54,7 +54,6 @@ let name = (if drvArgs ? name then drvArgs.name else "${drvArgs.pname}-${drvArgs.version}"); deps = - # This stdenvNoCC.mkDerivation ({ name = "${name}-dart-deps"; -- cgit 1.4.1 From 88275ca6d6ceeaecfc9c7d1a313c198bb888d287 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 16 Apr 2023 01:49:43 +1000 Subject: flutter.buildFlutterApplication: Allow using a custom pubspec.lock --- .../build-support/dart/fetch-dart-deps/default.nix | 26 ++++++++++++++++++++-- pkgs/build-support/flutter/default.nix | 3 ++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/dart/fetch-dart-deps/default.nix b/pkgs/build-support/dart/fetch-dart-deps/default.nix index 58f108cd68324..cf0d66c287c97 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/default.nix +++ b/pkgs/build-support/dart/fetch-dart-deps/default.nix @@ -13,6 +13,8 @@ , sdkSetupScript ? "" # Commands to run to populate the pub cache. , pubGetScript ? "dart pub get" + # A path to a pubspec.lock file to use instead of the one in the source directory. +, pubspecLockFile ? null # Arguments used in the derivation that builds the Dart package. # Passing these is recommended to ensure that the same steps are made to prepare the sources in both this # derivation and the one that builds the Dart package. @@ -74,12 +76,32 @@ let ''; installPhase = '' - ${pubGetScript} + _pub_get() { + ${pubGetScript} + } # so we can use lock, diff yaml mkdir -p "$out/pubspec" cp "pubspec.yaml" "$out/pubspec" - cp "pubspec.lock" "$out/pubspec" + ${lib.optionalString (pubspecLockFile != null) "install -m644 ${pubspecLockFile} pubspec.lock"} + if ! cp "pubspec.lock" "$out/pubspec"; then + echo 1>&2 -e '\nThe pubspec.lock file is missing. This is a requirement for reproducible builds.' \ + '\nThe following should be done to fix this issue:' \ + '\n 1. If you are building an application, contact the developer(s).' \ + '\n The pubspec.lock file should be provided with the source code.' \ + '\n https://dart.dev/guides/libraries/private-files#pubspeclock' \ + '\n 2. An attempt to generate and print a pubspec.lock file will be made now.' \ + '\n Save it to a file, and provide the path to that file in the pubspecLockFile argument.' \ + '\n This must be updated whenever the application is updated.' \ + '\n' + _pub_get + echo "" + cat 1>&2 pubspec.lock + echo 1>&2 -e '\nA pubspec.lock file has been printed. Please see the informational message above.' + exit 1 + fi + + _pub_get # nuke nondeterminism diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index f148c3d046e44..ac582de3cc0e2 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -11,6 +11,7 @@ { pubGetScript ? "flutter pub get" , vendorHash +, pubspecLockFile ? null , nativeBuildInputs ? [ ] , ... }@args: @@ -23,7 +24,7 @@ let deps = callPackage ../dart/fetch-dart-deps { dart = flutter; } { sdkSetupScript = flutterSetupScript; - inherit pubGetScript vendorHash; + inherit pubGetScript vendorHash pubspecLockFile; buildDrvArgs = args; }; self = -- cgit 1.4.1 From 0e5db63dc3a1ba3b434b993536c508b69e9a63b8 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 16 Apr 2023 02:39:18 +1000 Subject: dart.fetch-dart-deps: Don't delete .git/pub-packages --- pkgs/build-support/dart/fetch-dart-deps/default.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/dart/fetch-dart-deps/default.nix b/pkgs/build-support/dart/fetch-dart-deps/default.nix index cf0d66c287c97..c87714202776d 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/default.nix +++ b/pkgs/build-support/dart/fetch-dart-deps/default.nix @@ -107,7 +107,12 @@ let # Remove Git directories in the Git package cache - these are rarely used by Pub, # which instead maintains a corresponsing mirror and clones cached packages through it. - find "$PUB_CACHE" -name .git -type d -prune -exec rm -rf {} + + # + # An exception is made to keep .git/pub-packages files, which are important. + # https://github.com/dart-lang/pub/blob/c890afa1d65b340fa59308172029680c2f8b0fc6/lib/src/source/git.dart#L621 + if [ -d "$PUB_CACHE"/git ]; then + find "$PUB_CACHE"/git -maxdepth 4 -path "*/.git/*" ! -name "pub-packages" -prune -exec rm -rf {} + + fi # Remove continuously updated package metadata caches rm -rf "$PUB_CACHE"/hosted/*/.cache # Not pinned by pubspec.lock -- cgit 1.4.1 From 65631597c1be82bea68fc7b83aecc604fe5f6b14 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 16 Apr 2023 03:14:29 +1000 Subject: yubioauth-flutter: Update vendor hash for new pubspec.lock handling --- pkgs/applications/misc/yubioath-flutter/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/misc/yubioath-flutter/default.nix b/pkgs/applications/misc/yubioath-flutter/default.nix index c0931df476020..e3ff56e77d487 100644 --- a/pkgs/applications/misc/yubioath-flutter/default.nix +++ b/pkgs/applications/misc/yubioath-flutter/default.nix @@ -21,7 +21,7 @@ flutter.buildFlutterApplication rec { passthru.helper = python3.pkgs.callPackage ./helper.nix { inherit src version meta; }; - vendorHash = "sha256-OU433z6Cz+jNJAjIiPO6cxySyejQ4SpSvuUHJsdT8TA="; + vendorHash = "sha256-WfZiB7MO4wHUg81xm67BMu4zQdC9CfhN5BQol+AI2S8="; postPatch = '' substituteInPlace linux/CMakeLists.txt \ -- cgit 1.4.1 From 396938b6de7a40a1a9d8f0d07e0d0d3206e750f9 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 16 Apr 2023 03:14:59 +1000 Subject: firmware-updater: Add a pubspec.lock --- .../linux/firmware/firmware-updater/default.nix | 1 + .../linux/firmware/firmware-updater/pubspec.lock | 493 +++++++++++++++++++++ 2 files changed, 494 insertions(+) create mode 100644 pkgs/os-specific/linux/firmware/firmware-updater/pubspec.lock diff --git a/pkgs/os-specific/linux/firmware/firmware-updater/default.nix b/pkgs/os-specific/linux/firmware/firmware-updater/default.nix index a15005cf7463c..d6dfa4dbae348 100644 --- a/pkgs/os-specific/linux/firmware/firmware-updater/default.nix +++ b/pkgs/os-specific/linux/firmware/firmware-updater/default.nix @@ -7,6 +7,7 @@ flutter2.buildFlutterApplication { pname = "firmware-updater"; version = "unstable"; + pubspecLockFile = ./pubspec.lock; vendorHash = "sha256-kKfe+7obb2fihrca+mjCM2+51wNkbPLEPFLpXzK5Wvc="; src = fetchFromGitHub { diff --git a/pkgs/os-specific/linux/firmware/firmware-updater/pubspec.lock b/pkgs/os-specific/linux/firmware/firmware-updater/pubspec.lock new file mode 100644 index 0000000000000..c9e9a20444776 --- /dev/null +++ b/pkgs/os-specific/linux/firmware/firmware-updater/pubspec.lock @@ -0,0 +1,493 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.1" + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.2" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + chewie: + dependency: transitive + description: + name: chewie + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.0" + chewie_audio: + dependency: transitive + description: + name: chewie_audio + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + collection: + dependency: "direct main" + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.15.0" + csslib: + dependency: transitive + description: + name: csslib + url: "https://pub.dartlang.org" + source: hosted + version: "0.17.2" + cupertino_icons: + dependency: transitive + description: + name: cupertino_icons + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" + dbus: + dependency: transitive + description: + name: dbus + url: "https://pub.dartlang.org" + source: hosted + version: "0.7.3" + dio: + dependency: "direct main" + description: + name: dio + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.6" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_html: + dependency: "direct main" + description: + name: flutter_html + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.1" + flutter_layout_grid: + dependency: transitive + description: + name: flutter_layout_grid + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.6" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_math_fork: + dependency: transitive + description: + name: flutter_math_fork + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.0" + flutter_svg: + dependency: transitive + description: + name: flutter_svg + url: "https://pub.dartlang.org" + source: hosted + version: "0.23.0+1" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + fwupd: + dependency: "direct main" + description: + name: fwupd + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.2" + html: + dependency: transitive + description: + name: html + url: "https://pub.dartlang.org" + source: hosted + version: "0.15.1" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.2" + intl: + dependency: transitive + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.17.0" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + nested: + dependency: transitive + description: + name: nested + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + numerus: + dependency: transitive + description: + name: numerus + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + path: + dependency: "direct main" + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + path_drawing: + dependency: transitive + description: + name: path_drawing + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.1+1" + path_parsing: + dependency: transitive + description: + name: path_parsing + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.1" + petitparser: + dependency: transitive + description: + name: petitparser + url: "https://pub.dartlang.org" + source: hosted + version: "4.4.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" + provider: + dependency: "direct main" + description: + name: provider + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.5" + quiver: + dependency: transitive + description: + name: quiver + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.8" + tuple: + dependency: transitive + description: + name: tuple + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + video_player: + dependency: transitive + description: + name: video_player + url: "https://pub.dartlang.org" + source: hosted + version: "2.5.1" + video_player_android: + dependency: transitive + description: + name: video_player_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.10" + video_player_avfoundation: + dependency: transitive + description: + name: video_player_avfoundation + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.8" + video_player_platform_interface: + dependency: transitive + description: + name: video_player_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.1" + video_player_web: + dependency: transitive + description: + name: video_player_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.13" + wakelock: + dependency: transitive + description: + name: wakelock + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.2" + wakelock_macos: + dependency: transitive + description: + name: wakelock_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.0" + wakelock_platform_interface: + dependency: transitive + description: + name: wakelock_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0" + wakelock_web: + dependency: transitive + description: + name: wakelock_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.0" + wakelock_windows: + dependency: transitive + description: + name: wakelock_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" + webview_flutter: + dependency: transitive + description: + name: webview_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.0" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.14" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.5" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + url: "https://pub.dartlang.org" + source: hosted + version: "2.7.5" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "2.5.2" + xml: + dependency: transitive + description: + name: xml + url: "https://pub.dartlang.org" + source: hosted + version: "5.3.1" + yaru: + dependency: "direct main" + description: + name: yaru + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.5" + yaru_icons: + dependency: "direct main" + description: + name: yaru_icons + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" + yaru_widgets: + dependency: "direct main" + description: + name: yaru_widgets + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.8" +sdks: + dart: ">=2.15.0 <3.0.0" + flutter: ">=2.10.0" -- cgit 1.4.1 From 5fa3b41041212a468e50b9b36256b3fc74d91ea8 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 16 Apr 2023 03:20:36 +1000 Subject: dart.fetch-dart-deps: Verify the pubspec.lock as well as pubspec.yaml 88275ca6d6ceeaecfc9c7d1a313c198bb888d287 inadvertently stopped the pubspec.lock from changing, as it copied the file before running pub get. pub get can modify the pubspec.lock to update it to newer formats (for example by adding hashes and updating URLs, see an example diff below). We do not need the modifications at any later stage, so we can preserve the original file. boolean_selector: dependency: transitive description: name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" - url: "https://pub.dartlang.org" source: hosted + version: "2.1.1" - version: "2.1.0" --- pkgs/build-support/dart/fetch-dart-deps/setup-hook.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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 eaca3a31e7db9..1a5f86e475c02 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/setup-hook.sh +++ b/pkgs/build-support/dart/fetch-dart-deps/setup-hook.sh @@ -29,18 +29,13 @@ _setupPubCache() { done # ensure we're using a lockfile for the right package version - if [ -e pubspec.lock ]; then - # FIXME: currently this is broken. in theory this should not break, but flutter has it's own way of doing things. - # diff -u pubspec.lock "$deps/pubspec/pubspec.lock" - true - else + if [ ! -e pubspec.lock ]; then cp -v "$deps/pubspec/pubspec.lock" . # Sometimes the pubspec.lock will get opened in write mode, even when offline. chmod u+w pubspec.lock - fi - if ! diff -u pubspec.yaml "$deps/pubspec/pubspec.yaml"; then - echo 1>&2 -e 'The pubspec.yaml of the project derivation differs from the one in the dependency derivation.' \ + elif [ ! { diff -u pubspec.lock "$deps/pubspec/pubspec.lock" && diff -u pubspec.yaml "$deps/pubspec/pubspec.yaml" } ]; then + echo 1>&2 -e 'The pubspec.lock or pubspec.yaml of the project derivation differs from the one in the dependency derivation.' \ '\nYou most likely forgot to update the vendorHash while updating the sources.' - exit 1 + exit 1 fi } -- cgit 1.4.1 From 643b62c8f14c8685c9be273991d9e568ba02b6bf Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 16 Apr 2023 03:21:29 +1000 Subject: dart.fetch-dart-deps: Don't allow overriding the deps derivation name --- pkgs/build-support/dart/fetch-dart-deps/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/build-support/dart/fetch-dart-deps/default.nix b/pkgs/build-support/dart/fetch-dart-deps/default.nix index c87714202776d..fc4954ae9e83b 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/default.nix +++ b/pkgs/build-support/dart/fetch-dart-deps/default.nix @@ -148,7 +148,7 @@ let outputHashAlgo = "sha256"; outputHashMode = "recursive"; outputHash = if vendorHash != "" then vendorHash else lib.fakeSha256; - } // drvArgs); + } // (removeAttrs drvArgs [ "name" "pname" ])); in (makeSetupHook { # The setup hook should not be part of the fixed-output derivation. -- cgit 1.4.1 From 075f50f2d167affaefe3783dc21922a8288f4247 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 16 Apr 2023 03:32:26 +1000 Subject: dart.fetch-dart-deps: Compress the generated pubspec.lock file This is much more practical for users to copy, as it significantly reduces the length of the output. --- pkgs/build-support/dart/fetch-dart-deps/default.nix | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkgs/build-support/dart/fetch-dart-deps/default.nix b/pkgs/build-support/dart/fetch-dart-deps/default.nix index fc4954ae9e83b..acde38fc67e04 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/default.nix +++ b/pkgs/build-support/dart/fetch-dart-deps/default.nix @@ -86,18 +86,20 @@ let ${lib.optionalString (pubspecLockFile != null) "install -m644 ${pubspecLockFile} pubspec.lock"} if ! cp "pubspec.lock" "$out/pubspec"; then echo 1>&2 -e '\nThe pubspec.lock file is missing. This is a requirement for reproducible builds.' \ - '\nThe following should be done to fix this issue:' \ + '\nThe following steps should be taken to fix this issue:' \ '\n 1. If you are building an application, contact the developer(s).' \ '\n The pubspec.lock file should be provided with the source code.' \ '\n https://dart.dev/guides/libraries/private-files#pubspeclock' \ - '\n 2. An attempt to generate and print a pubspec.lock file will be made now.' \ - '\n Save it to a file, and provide the path to that file in the pubspecLockFile argument.' \ + '\n 2. An attempt to generate and print a compressed pubspec.lock file will be made now.' \ + '\n It is compressed with gzip and base64 encoded.' \ + '\n Paste it to a file and extract it with `base64 -d pubspec.lock.in | gzip -d > pubspec.lock`.' \ + '\n Provide the path to the pubspec.lock file in the pubspecLockFile argument.' \ '\n This must be updated whenever the application is updated.' \ '\n' _pub_get echo "" - cat 1>&2 pubspec.lock - echo 1>&2 -e '\nA pubspec.lock file has been printed. Please see the informational message above.' + gzip --to-stdout --best pubspec.lock | base64 1>&2 + echo 1>&2 -e '\nA gzipped pubspec.lock file has been printed. Please see the informational message above.' exit 1 fi -- cgit 1.4.1 From 1f7eab1c3845f873352a997d947673c2beb05f2d Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 16 Apr 2023 03:56:14 +1000 Subject: dart.fetch-dart-deps: Fix invalid syntax in pubspec validation statement --- pkgs/build-support/dart/fetch-dart-deps/setup-hook.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1a5f86e475c02..37ef74aa62ddd 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/setup-hook.sh +++ b/pkgs/build-support/dart/fetch-dart-deps/setup-hook.sh @@ -33,7 +33,7 @@ _setupPubCache() { cp -v "$deps/pubspec/pubspec.lock" . # Sometimes the pubspec.lock will get opened in write mode, even when offline. chmod u+w pubspec.lock - elif [ ! { diff -u pubspec.lock "$deps/pubspec/pubspec.lock" && diff -u pubspec.yaml "$deps/pubspec/pubspec.yaml" } ]; then + elif ! { diff -u pubspec.lock "$deps/pubspec/pubspec.lock" && diff -u pubspec.yaml "$deps/pubspec/pubspec.yaml"; }; then echo 1>&2 -e 'The pubspec.lock or pubspec.yaml of the project derivation differs from the one in the dependency derivation.' \ '\nYou most likely forgot to update the vendorHash while updating the sources.' exit 1 -- cgit 1.4.1 From 5a5435dea652265c52cf12be864d798d8682e29a Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 16 Apr 2023 15:45:09 +1000 Subject: flutter.buildFlutterApplication: Add flutterBuildFlags argument --- pkgs/build-support/flutter/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index ac582de3cc0e2..6b859acba9b97 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -10,6 +10,7 @@ # absolutely no mac support for now { pubGetScript ? "flutter pub get" +, flutterBuildFlags ? [] , vendorHash , pubspecLockFile ? null , nativeBuildInputs ? [ ] @@ -49,7 +50,7 @@ let mkdir -p build/flutter_assets/fonts flutter packages get --offline -v - flutter build linux --release -v + flutter build linux -v --release ${builtins.concatStringsSep " " (map (flag: "\"${flag}\"") flutterBuildFlags)} runHook postBuild ''; -- cgit 1.4.1 From eefb67036f600783ef1284a6b1f635cc9ec6208b Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 16 Apr 2023 15:56:14 +1000 Subject: flutter.buildFlutterApplication: Move debugging symbols into another output This reduces the size of the executable. It works well with Nix - if the user includes the version in their bug report, the exact debugging symbols required can easily be found. --- pkgs/build-support/flutter/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 6b859acba9b97..229d73366d4a0 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -30,6 +30,8 @@ let }; self = (self: llvmPackages_13.stdenv.mkDerivation (args // { + outputs = [ "out" "debug" ]; + nativeBuildInputs = [ deps flutter @@ -50,7 +52,7 @@ let mkdir -p build/flutter_assets/fonts flutter packages get --offline -v - flutter build linux -v --release ${builtins.concatStringsSep " " (map (flag: "\"${flag}\"") flutterBuildFlags)} + flutter build linux -v --release --split-debug-info="$debug" ${builtins.concatStringsSep " " (map (flag: "\"${flag}\"") flutterBuildFlags)} runHook postBuild ''; -- cgit 1.4.1 From bbfc7911d3e5bbc1a4abb59fbc73b3059df4a705 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 16 Apr 2023 19:25:42 +1000 Subject: flutter.buildFlutterApplication: Supply runtime dependencies This wraps Flutter programs with an appropriate LD_LIBRARY_PATH. For some reason, the RUNPATH of the executable is not used to load dynamic libraries in dart:ffi with DynamicLibrary.open(). This could alternatively be fixed with patchelf --add-needed, but this would cause all the libraries to be opened immediately, which is not what application authors expect. The name of the runtimeDependencies argument was chosen to match autoPatchelfHook, which has a similar feature. --- pkgs/build-support/flutter/default.nix | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 229d73366d4a0..f85c7a19ce2e7 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -1,6 +1,7 @@ { lib , callPackage , stdenvNoCC +, makeWrapper , llvmPackages_13 , cacert , flutter @@ -10,10 +11,12 @@ # absolutely no mac support for now { pubGetScript ? "flutter pub get" -, flutterBuildFlags ? [] +, flutterBuildFlags ? [ ] +, runtimeDependencies ? [ ] , vendorHash , pubspecLockFile ? null , nativeBuildInputs ? [ ] +, postFixup ? "" , ... }@args: let @@ -33,6 +36,7 @@ let outputs = [ "out" "debug" ]; nativeBuildInputs = [ + makeWrapper deps flutter git @@ -87,6 +91,20 @@ let runHook postInstall ''; + + postFixup = '' + # Add runtime library dependencies to the LD_LIBRARY_PATH. + # For some reason, the RUNPATH of the executable is not used to load dynamic libraries in dart:ffi with DynamicLibrary.open(). + # + # This could alternatively be fixed with patchelf --add-needed, but this would cause all the libraries to be opened immediately, + # which is not what application authors expect. + for f in "$out"/bin/*; do + wrapProgram "$f" \ + --suffix LD_LIBRARY_PATH : '${lib.makeLibraryPath runtimeDependencies}' + done + + ${postFixup} + ''; })) self; in self -- cgit 1.4.1 From 17cb291df1d84b89e4aba1fc085333038c9736c3 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 16 Apr 2023 19:52:42 +1000 Subject: flutter: Allow adding extra dependencies to the wrapper Flutter application derivations can add dependencies and build flags, but it's not as easy during development. As an alternative to nix-shell, a custom Flutter wrapper can be built with dependencies required by projects. This feature builds on the existing build environment setup techniques required for Linux desktop support, so is fairly cheap to maintain. --- pkgs/development/compilers/flutter/wrapper.nix | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index fe7d95b61809e..114465fd0efe7 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -3,6 +3,12 @@ , callPackage , flutter , supportsLinuxDesktop ? stdenv.isLinux +, extraPkgConfigPackages ? [ ] +, extraLibraries ? [ ] +, extraIncludes ? [ ] +, extraCxxFlags ? [ ] +, extraCFlags ? [ ] +, extraLinkerFlags ? [ ] , makeWrapper , runCommandLocal , writeShellScript @@ -62,7 +68,7 @@ let # Some header files and libraries are not properly located by the Flutter SDK. # They must be manually included. - appStaticBuildDeps = lib.optionals supportsLinuxDesktop [ libX11 xorgproto zlib ]; + appStaticBuildDeps = (lib.optionals supportsLinuxDesktop [ libX11 xorgproto zlib ]) ++ extraLibraries; # Tools used by the Flutter SDK to compile applications. buildTools = lib.optionals supportsLinuxDesktop [ @@ -73,9 +79,9 @@ let ]; # Nix-specific compiler configuration. - pkgConfigDirectories = builtins.filter builtins.pathExists (builtins.concatMap (pkg: map (dir: "${lib.getOutput "dev" pkg}/${dir}/pkgconfig") [ "lib" "share" ]) appBuildDeps); - cppFlags = map (pkg: "-isystem ${lib.getOutput "dev" pkg}/include") appStaticBuildDeps; - linkerFlags = map (pkg: "-rpath,${lib.getOutput "lib" pkg}/lib") appRuntimeDeps; + pkgConfigDirectories = builtins.filter builtins.pathExists (builtins.concatMap (pkg: map (dir: "${lib.getOutput "dev" pkg}/${dir}/pkgconfig") [ "lib" "share" ]) (appBuildDeps ++ extraPkgConfigPackages)); + includeFlags = map (pkg: "-isystem ${lib.getOutput "dev" pkg}/include") (appStaticBuildDeps ++ extraIncludes); + linkerFlags = (map (pkg: "-rpath,${lib.getOutput "lib" pkg}/lib") appRuntimeDeps) ++ extraLinkerFlags; in (callPackage ./sdk-symlink.nix { }) (runCommandLocal "flutter-wrapped" { @@ -94,6 +100,7 @@ in --prefix PATH : '${lib.makeBinPath (tools ++ buildTools)}' \ --prefix PKG_CONFIG_PATH : '${builtins.concatStringsSep ":" pkgConfigDirectories}' \ --prefix LIBRARY_PATH : '${lib.makeLibraryPath appStaticBuildDeps}' \ - --prefix CXXFLAGS "''\t" '${builtins.concatStringsSep " " cppFlags}' \ + --prefix CXXFLAGS "''\t" '${builtins.concatStringsSep " " (includeFlags ++ extraCxxFlags)}' \ + --prefix CFLAGS "''\t" '${builtins.concatStringsSep " " (includeFlags ++ extraCFlags)}' \ --prefix LDFLAGS "''\t" '${builtins.concatStringsSep " " (map (flag: "-Wl,${flag}") linkerFlags)}' '') -- cgit 1.4.1 From b68a185b0f6276340fa5aaf2d572c48d0e25a841 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 16 Apr 2023 23:06:22 +1000 Subject: dart.fetch-dart-deps: Expose the package cache files through passthru --- pkgs/build-support/dart/fetch-dart-deps/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/build-support/dart/fetch-dart-deps/default.nix b/pkgs/build-support/dart/fetch-dart-deps/default.nix index acde38fc67e04..460bba2b1b62b 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/default.nix +++ b/pkgs/build-support/dart/fetch-dart-deps/default.nix @@ -158,4 +158,5 @@ in # work at all anyway due to https://github.com/NixOS/nix/issues/6660. name = "${name}-dart-deps-setup-hook"; substitutions = { inherit deps; }; + passthru.files = deps.outPath; }) ./setup-hook.sh -- cgit 1.4.1 From 4f5dd08fe8a8bf81f636074a99dd4264faf017bb Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 16 Apr 2023 23:11:07 +1000 Subject: dart.fetch-dart-deps: Add hook runtime dependencies --- pkgs/build-support/dart/fetch-dart-deps/default.nix | 1 + pkgs/build-support/flutter/default.nix | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/build-support/dart/fetch-dart-deps/default.nix b/pkgs/build-support/dart/fetch-dart-deps/default.nix index 460bba2b1b62b..a3ab2c2c73a2e 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/default.nix +++ b/pkgs/build-support/dart/fetch-dart-deps/default.nix @@ -158,5 +158,6 @@ in # 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 diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index f85c7a19ce2e7..152b2dd888cc0 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -5,7 +5,6 @@ , llvmPackages_13 , cacert , flutter -, git }: # absolutely no mac support for now @@ -39,7 +38,6 @@ let makeWrapper deps flutter - git ] ++ nativeBuildInputs; configurePhase = '' -- cgit 1.4.1 From 87f809e0c6556126489d5340d8b3d71c4f85f0f1 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 16 Apr 2023 23:16:17 +1000 Subject: dart.list-dart-deps: Add list-dart-deps function This uses `dart pub deps` (https://dart.dev/tools/pub/cmd/pub-deps) to retrieve information about project dependencies. It requires a fetch-dart-deps derivation as input. --- pkgs/build-support/dart/list-dart-deps/default.nix | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 pkgs/build-support/dart/list-dart-deps/default.nix diff --git a/pkgs/build-support/dart/list-dart-deps/default.nix b/pkgs/build-support/dart/list-dart-deps/default.nix new file mode 100644 index 0000000000000..5cafd7773d452 --- /dev/null +++ b/pkgs/build-support/dart/list-dart-deps/default.nix @@ -0,0 +1,28 @@ +{ 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 + ''; +})) -- cgit 1.4.1 From 329c494d0c9e5983da84d5230a00c325b932f79c Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 17 Apr 2023 02:48:10 +1000 Subject: flutter.buildFlutterApplication: Allow overriding configuration attributes This allows thing like `flutterBuildFlags` and `runtimeDependencies` to be overridden with `overrideAttrs`. Attributes that affect dependency retrieval cannot be overridden. --- pkgs/build-support/flutter/default.nix | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 152b2dd888cc0..932306e86d1b3 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -30,8 +30,11 @@ let inherit pubGetScript vendorHash pubspecLockFile; buildDrvArgs = args; }; - self = -(self: llvmPackages_13.stdenv.mkDerivation (args // { + +in +llvmPackages_13.stdenv.mkDerivation (finalAttrs: args // { + inherit flutterBuildFlags runtimeDependencies; + outputs = [ "out" "debug" ]; nativeBuildInputs = [ @@ -54,7 +57,7 @@ let mkdir -p build/flutter_assets/fonts flutter packages get --offline -v - flutter build linux -v --release --split-debug-info="$debug" ${builtins.concatStringsSep " " (map (flag: "\"${flag}\"") flutterBuildFlags)} + flutter build linux -v --release --split-debug-info="$debug" ${builtins.concatStringsSep " " (map (flag: "\"${flag}\"") finalAttrs.flutterBuildFlags)} runHook postBuild ''; @@ -98,11 +101,9 @@ let # which is not what application authors expect. for f in "$out"/bin/*; do wrapProgram "$f" \ - --suffix LD_LIBRARY_PATH : '${lib.makeLibraryPath runtimeDependencies}' + --suffix LD_LIBRARY_PATH : '${lib.makeLibraryPath finalAttrs.runtimeDependencies}' done ${postFixup} ''; -})) self; -in - self +}) -- cgit 1.4.1 From 0495725a1f8e9df1ac3996459a9bb82305e69242 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 17 Apr 2023 03:01:32 +1000 Subject: flutter.buildFlutterApplication: Introduce a package override repository Some Flutter packages require additional attribute values to be added to buildFlutterApplication, to add things like libraries and environment variables. To prevent duplication in applications that use the packages, a repository of package overrides is kept. buildFlutterApplication will look for package overrides for each dependency, and apply them by calling overrideAttrs on itself. --- pkgs/build-support/flutter/default.nix | 128 +++++++++++---------- .../flutter/package-overrides/default.nix | 4 + 2 files changed, 74 insertions(+), 58 deletions(-) create mode 100644 pkgs/development/compilers/flutter/package-overrides/default.nix diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 932306e86d1b3..8c732c3377940 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -12,6 +12,7 @@ { pubGetScript ? "flutter pub get" , flutterBuildFlags ? [ ] , runtimeDependencies ? [ ] +, customPackageOverrides ? { } , vendorHash , pubspecLockFile ? null , nativeBuildInputs ? [ ] @@ -31,79 +32,90 @@ let buildDrvArgs = args; }; -in -llvmPackages_13.stdenv.mkDerivation (finalAttrs: args // { - inherit flutterBuildFlags runtimeDependencies; + baseDerivation = llvmPackages_13.stdenv.mkDerivation (finalAttrs: args // { + inherit flutterBuildFlags runtimeDependencies; - outputs = [ "out" "debug" ]; + outputs = [ "out" "debug" ]; - nativeBuildInputs = [ - makeWrapper - deps - flutter - ] ++ nativeBuildInputs; + nativeBuildInputs = [ + makeWrapper + deps + flutter + ] ++ nativeBuildInputs; - configurePhase = '' - runHook preConfigure + configurePhase = '' + runHook preConfigure - ${flutterSetupScript} + ${flutterSetupScript} - runHook postConfigure - ''; + runHook postConfigure + ''; - buildPhase = '' - runHook preBuild + buildPhase = '' + runHook preBuild - mkdir -p build/flutter_assets/fonts + mkdir -p build/flutter_assets/fonts - flutter packages get --offline -v - flutter build linux -v --release --split-debug-info="$debug" ${builtins.concatStringsSep " " (map (flag: "\"${flag}\"") finalAttrs.flutterBuildFlags)} + flutter packages get --offline -v + flutter build linux -v --release --split-debug-info="$debug" ${builtins.concatStringsSep " " (map (flag: "\"${flag}\"") finalAttrs.flutterBuildFlags)} - runHook postBuild - ''; + runHook postBuild + ''; - installPhase = '' - runHook preInstall + installPhase = '' + runHook preInstall - built=build/linux/*/release/bundle + built=build/linux/*/release/bundle - mkdir -p $out/bin - mv $built $out/app + mkdir -p $out/bin + mv $built $out/app - for f in $(find $out/app -iname "*.desktop" -type f); do - install -D $f $out/share/applications/$(basename $f) - done + for f in $(find $out/app -iname "*.desktop" -type f); do + install -D $f $out/share/applications/$(basename $f) + done - for f in $(find $out/app -maxdepth 1 -type f); do - ln -s $f $out/bin/$(basename $f) - done + for f in $(find $out/app -maxdepth 1 -type f); do + ln -s $f $out/bin/$(basename $f) + done - # make *.so executable - find $out/app -iname "*.so" -type f -exec chmod +x {} + + # make *.so executable + find $out/app -iname "*.so" -type f -exec chmod +x {} + - # remove stuff like /build/source/packages/ubuntu_desktop_installer/linux/flutter/ephemeral - for f in $(find $out/app -executable -type f); do - if patchelf --print-rpath "$f" | grep /build; then # this ignores static libs (e,g. libapp.so) also - echo "strip RPath of $f" - newrp=$(patchelf --print-rpath $f | sed -r "s|/build.*ephemeral:||g" | sed -r "s|/build.*profile:||g") - patchelf --set-rpath "$newrp" "$f" - fi - done + # remove stuff like /build/source/packages/ubuntu_desktop_installer/linux/flutter/ephemeral + for f in $(find $out/app -executable -type f); do + if patchelf --print-rpath "$f" | grep /build; then # this ignores static libs (e,g. libapp.so) also + echo "strip RPath of $f" + newrp=$(patchelf --print-rpath $f | sed -r "s|/build.*ephemeral:||g" | sed -r "s|/build.*profile:||g") + patchelf --set-rpath "$newrp" "$f" + fi + done - runHook postInstall - ''; + runHook postInstall + ''; - postFixup = '' - # Add runtime library dependencies to the LD_LIBRARY_PATH. - # For some reason, the RUNPATH of the executable is not used to load dynamic libraries in dart:ffi with DynamicLibrary.open(). - # - # This could alternatively be fixed with patchelf --add-needed, but this would cause all the libraries to be opened immediately, - # which is not what application authors expect. - for f in "$out"/bin/*; do - wrapProgram "$f" \ - --suffix LD_LIBRARY_PATH : '${lib.makeLibraryPath finalAttrs.runtimeDependencies}' - done - - ${postFixup} - ''; -}) + postFixup = '' + # Add runtime library dependencies to the LD_LIBRARY_PATH. + # For some reason, the RUNPATH of the executable is not used to load dynamic libraries in dart:ffi with DynamicLibrary.open(). + # + # This could alternatively be fixed with patchelf --add-needed, but this would cause all the libraries to be opened immediately, + # which is not what application authors expect. + for f in "$out"/bin/*; do + wrapProgram "$f" \ + --suffix LD_LIBRARY_PATH : '${lib.makeLibraryPath finalAttrs.runtimeDependencies}' + done + + ${postFixup} + ''; + }); + + 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; +in +builtins.foldl' + (prev: package: + if packageOverrideRepository ? ${package.name} + then prev.overrideAttrs packageOverrideRepository.${package.name} + else prev) + baseDerivation + productPackages diff --git a/pkgs/development/compilers/flutter/package-overrides/default.nix b/pkgs/development/compilers/flutter/package-overrides/default.nix new file mode 100644 index 0000000000000..4a3fcd1cded04 --- /dev/null +++ b/pkgs/development/compilers/flutter/package-overrides/default.nix @@ -0,0 +1,4 @@ +{ callPackage }: + +{ +} -- cgit 1.4.1 From 37e93f7c3b9c98eef13733f2a558194db2d1b0f6 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 17 Apr 2023 14:40:18 +1000 Subject: flutter.buildFlutterApplication: Supply package metadata to overrides --- pkgs/build-support/flutter/default.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 8c732c3377940..70428736c3248 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -115,7 +115,16 @@ in builtins.foldl' (prev: package: if packageOverrideRepository ? ${package.name} - then prev.overrideAttrs packageOverrideRepository.${package.name} + then + prev.overrideAttrs + (packageOverrideRepository.${package.name} { + inherit (package) + name + version + kind + source + dependencies; + }) else prev) baseDerivation productPackages -- cgit 1.4.1 From 9f05297dc8875baeeeb8160b60f120affc259f2c Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sat, 22 Apr 2023 16:42:22 +1000 Subject: flutter.buildFlutterApplication: Manually supply the dependency list This removes the need for IFD. --- .../applications/misc/yubioath-flutter/default.nix | 1 + pkgs/applications/misc/yubioath-flutter/deps.json | 1319 ++++++++++++++++++++ .../build-support/dart/fetch-dart-deps/default.nix | 41 +- pkgs/build-support/dart/list-dart-deps/default.nix | 28 - pkgs/build-support/flutter/default.nix | 21 +- .../linux/firmware/firmware-updater/default.nix | 1 + .../linux/firmware/firmware-updater/deps.json | 763 +++++++++++ 7 files changed, 2135 insertions(+), 39 deletions(-) create mode 100644 pkgs/applications/misc/yubioath-flutter/deps.json delete mode 100644 pkgs/build-support/dart/list-dart-deps/default.nix create mode 100644 pkgs/os-specific/linux/firmware/firmware-updater/deps.json diff --git a/pkgs/applications/misc/yubioath-flutter/default.nix b/pkgs/applications/misc/yubioath-flutter/default.nix index e3ff56e77d487..4012b40ff602a 100644 --- a/pkgs/applications/misc/yubioath-flutter/default.nix +++ b/pkgs/applications/misc/yubioath-flutter/default.nix @@ -21,6 +21,7 @@ flutter.buildFlutterApplication rec { passthru.helper = python3.pkgs.callPackage ./helper.nix { inherit src version meta; }; + depsListFile = ./deps.json; vendorHash = "sha256-WfZiB7MO4wHUg81xm67BMu4zQdC9CfhN5BQol+AI2S8="; postPatch = '' diff --git a/pkgs/applications/misc/yubioath-flutter/deps.json b/pkgs/applications/misc/yubioath-flutter/deps.json new file mode 100644 index 0000000000000..1ce525f799bd1 --- /dev/null +++ b/pkgs/applications/misc/yubioath-flutter/deps.json @@ -0,0 +1,1319 @@ +[ + { + "name": "yubico_authenticator", + "version": "6.1.0+60100", + "kind": "root", + "source": "root", + "dependencies": [ + "flutter", + "flutter_localizations", + "intl", + "async", + "logging", + "collection", + "shared_preferences", + "flutter_riverpod", + "json_annotation", + "freezed_annotation", + "window_manager", + "qrscanner_zxing", + "desktop_drop", + "url_launcher", + "integration_test", + "flutter_test", + "flutter_lints", + "build_runner", + "freezed", + "json_serializable" + ] + }, + { + "name": "json_serializable", + "version": "6.5.4", + "kind": "dev", + "source": "hosted", + "dependencies": [ + "analyzer", + "async", + "build", + "build_config", + "collection", + "json_annotation", + "meta", + "path", + "pub_semver", + "pubspec_parse", + "source_gen", + "source_helper" + ] + }, + { + "name": "source_helper", + "version": "1.3.3", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "analyzer", + "collection", + "source_gen" + ] + }, + { + "name": "source_gen", + "version": "1.2.6", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "analyzer", + "async", + "build", + "dart_style", + "glob", + "meta", + "path", + "source_span", + "yaml" + ] + }, + { + "name": "yaml", + "version": "3.1.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "collection", + "source_span", + "string_scanner" + ] + }, + { + "name": "string_scanner", + "version": "1.2.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "source_span" + ] + }, + { + "name": "source_span", + "version": "1.9.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "collection", + "path", + "term_glyph" + ] + }, + { + "name": "term_glyph", + "version": "1.2.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "path", + "version": "1.8.2", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "collection", + "version": "1.17.0", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "meta", + "version": "1.8.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "glob", + "version": "2.1.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "async", + "collection", + "file", + "path", + "string_scanner" + ] + }, + { + "name": "file", + "version": "6.1.4", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "meta", + "path" + ] + }, + { + "name": "async", + "version": "2.10.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "collection", + "meta" + ] + }, + { + "name": "dart_style", + "version": "2.2.4", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "analyzer", + "args", + "path", + "pub_semver", + "source_span" + ] + }, + { + "name": "pub_semver", + "version": "2.1.3", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "collection", + "meta" + ] + }, + { + "name": "args", + "version": "2.3.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "analyzer", + "version": "5.2.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "_fe_analyzer_shared", + "collection", + "convert", + "crypto", + "glob", + "meta", + "package_config", + "path", + "pub_semver", + "source_span", + "watcher", + "yaml" + ] + }, + { + "name": "watcher", + "version": "1.0.2", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "async", + "path" + ] + }, + { + "name": "package_config", + "version": "2.1.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "path" + ] + }, + { + "name": "crypto", + "version": "3.0.2", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "typed_data" + ] + }, + { + "name": "typed_data", + "version": "1.3.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "collection" + ] + }, + { + "name": "convert", + "version": "3.1.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "typed_data" + ] + }, + { + "name": "_fe_analyzer_shared", + "version": "50.0.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "meta" + ] + }, + { + "name": "build", + "version": "2.3.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "analyzer", + "async", + "convert", + "crypto", + "glob", + "logging", + "meta", + "path" + ] + }, + { + "name": "logging", + "version": "1.1.0", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "pubspec_parse", + "version": "1.2.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "checked_yaml", + "collection", + "json_annotation", + "pub_semver", + "yaml" + ] + }, + { + "name": "json_annotation", + "version": "4.7.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "meta" + ] + }, + { + "name": "checked_yaml", + "version": "2.0.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "json_annotation", + "source_span", + "yaml" + ] + }, + { + "name": "build_config", + "version": "1.1.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "checked_yaml", + "json_annotation", + "path", + "pubspec_parse", + "yaml" + ] + }, + { + "name": "freezed", + "version": "2.3.2", + "kind": "dev", + "source": "hosted", + "dependencies": [ + "analyzer", + "build", + "build_config", + "collection", + "meta", + "source_gen", + "freezed_annotation", + "json_annotation" + ] + }, + { + "name": "freezed_annotation", + "version": "2.2.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "collection", + "json_annotation", + "meta" + ] + }, + { + "name": "build_runner", + "version": "2.3.3", + "kind": "dev", + "source": "hosted", + "dependencies": [ + "args", + "async", + "analyzer", + "build", + "build_config", + "build_daemon", + "build_resolvers", + "build_runner_core", + "code_builder", + "collection", + "crypto", + "dart_style", + "frontend_server_client", + "glob", + "graphs", + "http_multi_server", + "io", + "js", + "logging", + "meta", + "mime", + "package_config", + "path", + "pool", + "pub_semver", + "pubspec_parse", + "shelf", + "shelf_web_socket", + "stack_trace", + "stream_transform", + "timing", + "watcher", + "web_socket_channel", + "yaml" + ] + }, + { + "name": "web_socket_channel", + "version": "2.2.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "async", + "crypto", + "stream_channel" + ] + }, + { + "name": "stream_channel", + "version": "2.1.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "async" + ] + }, + { + "name": "timing", + "version": "1.0.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "json_annotation" + ] + }, + { + "name": "stream_transform", + "version": "2.1.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "stack_trace", + "version": "1.11.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "path" + ] + }, + { + "name": "shelf_web_socket", + "version": "1.0.3", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "shelf", + "stream_channel", + "web_socket_channel" + ] + }, + { + "name": "shelf", + "version": "1.4.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "async", + "collection", + "http_parser", + "path", + "stack_trace", + "stream_channel" + ] + }, + { + "name": "http_parser", + "version": "4.0.2", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "collection", + "source_span", + "string_scanner", + "typed_data" + ] + }, + { + "name": "pool", + "version": "1.5.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "async", + "stack_trace" + ] + }, + { + "name": "mime", + "version": "1.0.3", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "js", + "version": "0.6.5", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "meta" + ] + }, + { + "name": "io", + "version": "1.0.3", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "meta", + "path", + "string_scanner" + ] + }, + { + "name": "http_multi_server", + "version": "3.2.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "async" + ] + }, + { + "name": "graphs", + "version": "2.2.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "collection" + ] + }, + { + "name": "frontend_server_client", + "version": "3.2.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "async", + "path" + ] + }, + { + "name": "code_builder", + "version": "4.3.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "built_collection", + "built_value", + "collection", + "matcher", + "meta" + ] + }, + { + "name": "matcher", + "version": "0.12.13", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "meta", + "stack_trace" + ] + }, + { + "name": "built_value", + "version": "8.4.2", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "built_collection", + "collection", + "fixnum", + "meta" + ] + }, + { + "name": "fixnum", + "version": "1.0.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "built_collection", + "version": "5.1.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "build_runner_core", + "version": "7.2.7", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "async", + "build", + "build_config", + "build_resolvers", + "collection", + "convert", + "crypto", + "glob", + "graphs", + "json_annotation", + "logging", + "meta", + "path", + "package_config", + "pool", + "timing", + "watcher", + "yaml" + ] + }, + { + "name": "build_resolvers", + "version": "2.1.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "analyzer", + "async", + "build", + "crypto", + "graphs", + "logging", + "path", + "package_config", + "pool", + "pub_semver", + "stream_transform", + "yaml" + ] + }, + { + "name": "build_daemon", + "version": "3.1.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "built_collection", + "built_value", + "http_multi_server", + "logging", + "path", + "pool", + "shelf", + "shelf_web_socket", + "stream_transform", + "watcher", + "web_socket_channel" + ] + }, + { + "name": "flutter_lints", + "version": "2.0.1", + "kind": "dev", + "source": "hosted", + "dependencies": [ + "lints" + ] + }, + { + "name": "lints", + "version": "2.0.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "flutter_test", + "version": "0.0.0", + "kind": "dev", + "source": "sdk", + "dependencies": [ + "flutter", + "test_api", + "path", + "fake_async", + "clock", + "stack_trace", + "vector_math", + "async", + "boolean_selector", + "characters", + "collection", + "js", + "matcher", + "material_color_utilities", + "meta", + "source_span", + "stream_channel", + "string_scanner", + "term_glyph" + ] + }, + { + "name": "material_color_utilities", + "version": "0.2.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "characters", + "version": "1.2.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "boolean_selector", + "version": "2.1.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "source_span", + "string_scanner" + ] + }, + { + "name": "vector_math", + "version": "2.1.4", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "clock", + "version": "1.1.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "fake_async", + "version": "1.3.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "clock", + "collection" + ] + }, + { + "name": "test_api", + "version": "0.4.16", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "async", + "boolean_selector", + "collection", + "meta", + "source_span", + "stack_trace", + "stream_channel", + "string_scanner", + "term_glyph", + "matcher" + ] + }, + { + "name": "flutter", + "version": "0.0.0", + "kind": "direct", + "source": "sdk", + "dependencies": [ + "characters", + "collection", + "js", + "material_color_utilities", + "meta", + "vector_math", + "sky_engine" + ] + }, + { + "name": "sky_engine", + "version": "0.0.99", + "kind": "transitive", + "source": "sdk", + "dependencies": [] + }, + { + "name": "integration_test", + "version": "0.0.0", + "kind": "dev", + "source": "sdk", + "dependencies": [ + "flutter", + "flutter_driver", + "flutter_test", + "path", + "vm_service", + "archive", + "async", + "boolean_selector", + "characters", + "clock", + "collection", + "crypto", + "fake_async", + "file", + "js", + "matcher", + "material_color_utilities", + "meta", + "source_span", + "stack_trace", + "stream_channel", + "string_scanner", + "sync_http", + "term_glyph", + "test_api", + "typed_data", + "vector_math", + "webdriver" + ] + }, + { + "name": "webdriver", + "version": "3.0.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "archive", + "matcher", + "path", + "stack_trace", + "sync_http" + ] + }, + { + "name": "sync_http", + "version": "0.3.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "archive", + "version": "3.3.2", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "crypto", + "path" + ] + }, + { + "name": "vm_service", + "version": "9.4.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "flutter_driver", + "version": "0.0.0", + "kind": "transitive", + "source": "sdk", + "dependencies": [ + "file", + "flutter", + "flutter_test", + "fuchsia_remote_debug_protocol", + "path", + "meta", + "vm_service", + "webdriver", + "archive", + "async", + "boolean_selector", + "characters", + "clock", + "collection", + "crypto", + "js", + "matcher", + "material_color_utilities", + "platform", + "process", + "source_span", + "stack_trace", + "stream_channel", + "string_scanner", + "sync_http", + "term_glyph", + "test_api", + "typed_data", + "vector_math" + ] + }, + { + "name": "process", + "version": "4.2.4", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "file", + "path", + "platform" + ] + }, + { + "name": "platform", + "version": "3.1.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "fuchsia_remote_debug_protocol", + "version": "0.0.0", + "kind": "transitive", + "source": "sdk", + "dependencies": [ + "process", + "vm_service", + "file", + "meta", + "path", + "platform" + ] + }, + { + "name": "url_launcher", + "version": "6.1.7", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "flutter", + "url_launcher_android", + "url_launcher_ios", + "url_launcher_linux", + "url_launcher_macos", + "url_launcher_platform_interface", + "url_launcher_web", + "url_launcher_windows" + ] + }, + { + "name": "url_launcher_windows", + "version": "3.0.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "url_launcher_platform_interface" + ] + }, + { + "name": "url_launcher_platform_interface", + "version": "2.1.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "plugin_platform_interface" + ] + }, + { + "name": "plugin_platform_interface", + "version": "2.1.3", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "meta" + ] + }, + { + "name": "url_launcher_web", + "version": "2.0.13", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "flutter_web_plugins", + "url_launcher_platform_interface" + ] + }, + { + "name": "flutter_web_plugins", + "version": "0.0.0", + "kind": "transitive", + "source": "sdk", + "dependencies": [ + "flutter", + "js", + "characters", + "collection", + "material_color_utilities", + "meta", + "vector_math" + ] + }, + { + "name": "url_launcher_macos", + "version": "3.0.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "url_launcher_platform_interface" + ] + }, + { + "name": "url_launcher_linux", + "version": "3.0.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "url_launcher_platform_interface" + ] + }, + { + "name": "url_launcher_ios", + "version": "6.0.17", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "url_launcher_platform_interface" + ] + }, + { + "name": "url_launcher_android", + "version": "6.0.22", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "url_launcher_platform_interface" + ] + }, + { + "name": "desktop_drop", + "version": "0.4.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "flutter", + "flutter_web_plugins", + "cross_file" + ] + }, + { + "name": "cross_file", + "version": "0.3.3+2", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "js", + "meta" + ] + }, + { + "name": "qrscanner_zxing", + "version": "1.0.0", + "kind": "direct", + "source": "path", + "dependencies": [ + "flutter", + "plugin_platform_interface" + ] + }, + { + "name": "window_manager", + "version": "0.3.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "flutter", + "path", + "screen_retriever" + ] + }, + { + "name": "screen_retriever", + "version": "0.1.4", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter" + ] + }, + { + "name": "flutter_riverpod", + "version": "2.1.3", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "collection", + "flutter", + "meta", + "riverpod", + "state_notifier" + ] + }, + { + "name": "state_notifier", + "version": "0.7.2+1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "meta" + ] + }, + { + "name": "riverpod", + "version": "2.1.3", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "collection", + "meta", + "stack_trace", + "state_notifier" + ] + }, + { + "name": "shared_preferences", + "version": "2.0.16", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "flutter", + "shared_preferences_android", + "shared_preferences_foundation", + "shared_preferences_linux", + "shared_preferences_platform_interface", + "shared_preferences_web", + "shared_preferences_windows" + ] + }, + { + "name": "shared_preferences_windows", + "version": "2.1.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "file", + "flutter", + "path", + "path_provider_platform_interface", + "path_provider_windows", + "shared_preferences_platform_interface" + ] + }, + { + "name": "shared_preferences_platform_interface", + "version": "2.1.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "plugin_platform_interface" + ] + }, + { + "name": "path_provider_windows", + "version": "2.1.3", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "ffi", + "flutter", + "path", + "path_provider_platform_interface", + "win32" + ] + }, + { + "name": "win32", + "version": "3.1.2", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "ffi" + ] + }, + { + "name": "ffi", + "version": "2.0.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "path_provider_platform_interface", + "version": "2.0.5", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "platform", + "plugin_platform_interface" + ] + }, + { + "name": "shared_preferences_web", + "version": "2.0.4", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "flutter_web_plugins", + "shared_preferences_platform_interface" + ] + }, + { + "name": "shared_preferences_linux", + "version": "2.1.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "file", + "flutter", + "path", + "path_provider_linux", + "path_provider_platform_interface", + "shared_preferences_platform_interface" + ] + }, + { + "name": "path_provider_linux", + "version": "2.1.7", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "ffi", + "flutter", + "path", + "path_provider_platform_interface", + "xdg_directories" + ] + }, + { + "name": "xdg_directories", + "version": "0.2.0+2", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "meta", + "path", + "process" + ] + }, + { + "name": "shared_preferences_foundation", + "version": "2.1.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "shared_preferences_platform_interface" + ] + }, + { + "name": "shared_preferences_android", + "version": "2.0.14", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "shared_preferences_platform_interface" + ] + }, + { + "name": "intl", + "version": "0.17.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "clock", + "path" + ] + }, + { + "name": "flutter_localizations", + "version": "0.0.0", + "kind": "direct", + "source": "sdk", + "dependencies": [ + "flutter", + "intl", + "characters", + "clock", + "collection", + "js", + "material_color_utilities", + "meta", + "path", + "vector_math" + ] + } +] diff --git a/pkgs/build-support/dart/fetch-dart-deps/default.nix b/pkgs/build-support/dart/fetch-dart-deps/default.nix index a3ab2c2c73a2e..9deb99648c08a 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 5cafd7773d452..0000000000000 --- 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 70428736c3248..622a19c32bd0f 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: diff --git a/pkgs/os-specific/linux/firmware/firmware-updater/default.nix b/pkgs/os-specific/linux/firmware/firmware-updater/default.nix index d6dfa4dbae348..13421c5cc8bda 100644 --- a/pkgs/os-specific/linux/firmware/firmware-updater/default.nix +++ b/pkgs/os-specific/linux/firmware/firmware-updater/default.nix @@ -8,6 +8,7 @@ flutter2.buildFlutterApplication { version = "unstable"; pubspecLockFile = ./pubspec.lock; + depsListFile = ./deps.json; vendorHash = "sha256-kKfe+7obb2fihrca+mjCM2+51wNkbPLEPFLpXzK5Wvc="; src = fetchFromGitHub { diff --git a/pkgs/os-specific/linux/firmware/firmware-updater/deps.json b/pkgs/os-specific/linux/firmware/firmware-updater/deps.json new file mode 100644 index 0000000000000..9264a9fb70eee --- /dev/null +++ b/pkgs/os-specific/linux/firmware/firmware-updater/deps.json @@ -0,0 +1,763 @@ +[ + { + "name": "firmware_updater", + "version": "0.0.0", + "kind": "root", + "source": "root", + "dependencies": [ + "collection", + "dio", + "flutter", + "flutter_html", + "flutter_localizations", + "fwupd", + "path", + "provider", + "yaru", + "yaru_icons", + "yaru_widgets", + "flutter_lints", + "flutter_test" + ] + }, + { + "name": "flutter_test", + "version": "0.0.0", + "kind": "dev", + "source": "sdk", + "dependencies": [ + "flutter", + "test_api", + "path", + "fake_async", + "clock", + "stack_trace", + "vector_math", + "async", + "boolean_selector", + "characters", + "charcode", + "collection", + "matcher", + "material_color_utilities", + "meta", + "source_span", + "stream_channel", + "string_scanner", + "term_glyph", + "typed_data" + ] + }, + { + "name": "typed_data", + "version": "1.3.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "collection" + ] + }, + { + "name": "collection", + "version": "1.15.0", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "term_glyph", + "version": "1.2.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "string_scanner", + "version": "1.1.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "charcode", + "source_span" + ] + }, + { + "name": "source_span", + "version": "1.8.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "collection", + "path", + "term_glyph" + ] + }, + { + "name": "path", + "version": "1.8.0", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "charcode", + "version": "1.3.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "stream_channel", + "version": "2.1.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "async" + ] + }, + { + "name": "async", + "version": "2.8.2", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "collection", + "meta" + ] + }, + { + "name": "meta", + "version": "1.7.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "material_color_utilities", + "version": "0.1.3", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "matcher", + "version": "0.12.11", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "stack_trace" + ] + }, + { + "name": "stack_trace", + "version": "1.10.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "path" + ] + }, + { + "name": "characters", + "version": "1.2.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "boolean_selector", + "version": "2.1.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "source_span", + "string_scanner" + ] + }, + { + "name": "vector_math", + "version": "2.1.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "clock", + "version": "1.1.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "fake_async", + "version": "1.2.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "clock", + "collection" + ] + }, + { + "name": "test_api", + "version": "0.4.8", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "async", + "boolean_selector", + "collection", + "meta", + "source_span", + "stack_trace", + "stream_channel", + "string_scanner", + "term_glyph", + "matcher" + ] + }, + { + "name": "flutter", + "version": "0.0.0", + "kind": "direct", + "source": "sdk", + "dependencies": [ + "characters", + "collection", + "material_color_utilities", + "meta", + "typed_data", + "vector_math", + "sky_engine" + ] + }, + { + "name": "sky_engine", + "version": "0.0.99", + "kind": "transitive", + "source": "sdk", + "dependencies": [] + }, + { + "name": "flutter_lints", + "version": "1.0.4", + "kind": "dev", + "source": "hosted", + "dependencies": [ + "lints" + ] + }, + { + "name": "lints", + "version": "1.0.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "yaru_widgets", + "version": "1.0.8", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "flutter" + ] + }, + { + "name": "yaru_icons", + "version": "0.1.3", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "flutter" + ] + }, + { + "name": "yaru", + "version": "0.2.5", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "flutter" + ] + }, + { + "name": "provider", + "version": "6.0.5", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "collection", + "flutter", + "nested" + ] + }, + { + "name": "nested", + "version": "1.0.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter" + ] + }, + { + "name": "fwupd", + "version": "0.2.2", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "collection", + "dbus", + "meta" + ] + }, + { + "name": "dbus", + "version": "0.7.3", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "args", + "ffi", + "meta", + "xml" + ] + }, + { + "name": "xml", + "version": "5.3.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "collection", + "meta", + "petitparser" + ] + }, + { + "name": "petitparser", + "version": "4.4.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "meta" + ] + }, + { + "name": "ffi", + "version": "1.2.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "args", + "version": "2.3.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "flutter_localizations", + "version": "0.0.0", + "kind": "direct", + "source": "sdk", + "dependencies": [ + "flutter", + "intl", + "characters", + "clock", + "collection", + "material_color_utilities", + "meta", + "path", + "typed_data", + "vector_math" + ] + }, + { + "name": "intl", + "version": "0.17.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "clock", + "path" + ] + }, + { + "name": "flutter_html", + "version": "2.2.1", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "html", + "csslib", + "flutter_layout_grid", + "video_player", + "chewie", + "webview_flutter", + "chewie_audio", + "flutter_svg", + "flutter_math_fork", + "collection", + "numerus", + "flutter" + ] + }, + { + "name": "numerus", + "version": "1.1.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "flutter_math_fork", + "version": "0.5.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "flutter_svg", + "provider", + "meta", + "collection", + "tuple" + ] + }, + { + "name": "tuple", + "version": "2.0.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "flutter_svg", + "version": "0.23.0+1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "meta", + "path_drawing", + "vector_math", + "xml" + ] + }, + { + "name": "path_drawing", + "version": "0.5.1+1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "vector_math", + "meta", + "path_parsing", + "flutter" + ] + }, + { + "name": "path_parsing", + "version": "0.2.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "vector_math", + "meta" + ] + }, + { + "name": "chewie_audio", + "version": "1.3.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "cupertino_icons", + "flutter", + "video_player" + ] + }, + { + "name": "video_player", + "version": "2.5.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "html", + "video_player_android", + "video_player_avfoundation", + "video_player_platform_interface", + "video_player_web" + ] + }, + { + "name": "video_player_web", + "version": "2.0.13", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "flutter_web_plugins", + "video_player_platform_interface" + ] + }, + { + "name": "video_player_platform_interface", + "version": "6.0.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "plugin_platform_interface" + ] + }, + { + "name": "plugin_platform_interface", + "version": "2.1.3", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "meta" + ] + }, + { + "name": "flutter_web_plugins", + "version": "0.0.0", + "kind": "transitive", + "source": "sdk", + "dependencies": [ + "flutter", + "js", + "characters", + "collection", + "material_color_utilities", + "meta", + "typed_data", + "vector_math" + ] + }, + { + "name": "js", + "version": "0.6.3", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "video_player_avfoundation", + "version": "2.3.8", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "video_player_platform_interface" + ] + }, + { + "name": "video_player_android", + "version": "2.3.10", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "video_player_platform_interface" + ] + }, + { + "name": "html", + "version": "0.15.1", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "csslib", + "source_span" + ] + }, + { + "name": "csslib", + "version": "0.17.2", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "source_span" + ] + }, + { + "name": "cupertino_icons", + "version": "1.0.5", + "kind": "transitive", + "source": "hosted", + "dependencies": [] + }, + { + "name": "webview_flutter", + "version": "2.8.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "webview_flutter_android", + "webview_flutter_platform_interface", + "webview_flutter_wkwebview" + ] + }, + { + "name": "webview_flutter_wkwebview", + "version": "2.7.5", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "path", + "webview_flutter_platform_interface" + ] + }, + { + "name": "webview_flutter_platform_interface", + "version": "1.9.5", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "meta", + "plugin_platform_interface" + ] + }, + { + "name": "webview_flutter_android", + "version": "2.8.14", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "webview_flutter_platform_interface" + ] + }, + { + "name": "chewie", + "version": "1.4.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "cupertino_icons", + "flutter", + "provider", + "video_player", + "wakelock" + ] + }, + { + "name": "wakelock", + "version": "0.6.2", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "meta", + "wakelock_macos", + "wakelock_platform_interface", + "wakelock_web", + "wakelock_windows" + ] + }, + { + "name": "wakelock_windows", + "version": "0.2.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "wakelock_platform_interface", + "win32" + ] + }, + { + "name": "win32", + "version": "2.5.2", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "ffi" + ] + }, + { + "name": "wakelock_platform_interface", + "version": "0.3.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "meta" + ] + }, + { + "name": "wakelock_web", + "version": "0.4.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "flutter_web_plugins", + "js", + "wakelock_platform_interface" + ] + }, + { + "name": "wakelock_macos", + "version": "0.4.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "flutter_web_plugins", + "wakelock_platform_interface" + ] + }, + { + "name": "flutter_layout_grid", + "version": "1.0.6", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "flutter", + "collection", + "meta", + "quiver" + ] + }, + { + "name": "quiver", + "version": "3.1.0", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "matcher" + ] + }, + { + "name": "dio", + "version": "4.0.6", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "http_parser", + "path" + ] + }, + { + "name": "http_parser", + "version": "4.0.2", + "kind": "transitive", + "source": "hosted", + "dependencies": [ + "collection", + "source_span", + "string_scanner", + "typed_data" + ] + } +] -- cgit 1.4.1 From 89bb0ed91bd5ed327ce0c9bd745921fdf4bad097 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 23 Apr 2023 00:32:24 +1000 Subject: flutter.buildFlutterApplication: Add an option to generate the dependency list with IFD This is useful for projects outside of Nixpkgs. --- pkgs/build-support/flutter/default.nix | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 622a19c32bd0f..abb1c8ac359fc 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -14,6 +14,7 @@ , flutterBuildFlags ? [ ] , runtimeDependencies ? [ ] , customPackageOverrides ? { } +, autoDepsList ? false , depsListFile ? null , vendorHash , pubspecLockFile ? null @@ -48,11 +49,16 @@ let ] ++ 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 + ${lib.optionalString (!autoDepsList) '' + 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 choose one of the following solutions:' \ + '\n - Duplicate the following file and pass it to the depsListFile argument.' \ + '\n ${finalAttrs.passthru.depsListFile}' \ + '\n - Set autoDepsList to true (not supported by Hydra or permitted in Nixpkgs)'. + exit 1 + fi + ''} ${preUnpack} ''; @@ -127,7 +133,13 @@ let }); packageOverrideRepository = (callPackage ../../development/compilers/flutter/package-overrides { }) // customPackageOverrides; - productPackages = builtins.filter (package: package.kind != "dev") (if depsListFile == null then [ ] else (builtins.fromJSON (builtins.readFile depsListFile))); + productPackages = builtins.filter (package: package.kind != "dev") + (if autoDepsList + then builtins.fromJSON (builtins.readFile deps.depsListFile) + else + if depsListFile == null + then [ ] + else builtins.fromJSON (builtins.readFile depsListFile)); in builtins.foldl' (prev: package: -- cgit 1.4.1 From 7e53598823416e2feb0c4fdc645e7692b8453b5d Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 23 Apr 2023 14:30:37 +1000 Subject: flutter: 3.7.11 -> 3.7.12 --- pkgs/development/compilers/flutter/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix index 56361bbb6abf2..e3b060777e706 100644 --- a/pkgs/development/compilers/flutter/default.nix +++ b/pkgs/development/compilers/flutter/default.nix @@ -31,9 +31,9 @@ in { inherit mkFlutter wrapFlutter flutterDrv flutter3Patches flutter2Patches; stable = flutterDrv { - version = "3.7.11"; + version = "3.7.12"; dartVersion = "2.19.6"; - hash = "sha256-H2S8nRpTte6ux34jTkCneGbSMQldrnjH1dI+/pzrcNg="; + hash = "sha256-5ExDBQXIpoZ5NwS66seY3m9/V8xDiyq/RdzldAyHdEE="; dartHash = { x86_64-linux = "sha256-4ezRuwhQHVCxZg5WbzU/tBUDvZVpfCo6coDE4K0UzXo="; aarch64-linux = "sha256-pYmClIqOo0sRPOkrcF4xQbo0mHlrr1TkhT1fnNyYNck="; -- cgit 1.4.1 From ae0aff848fce2a672919bedffbe04f85bfed13b6 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 23 Apr 2023 14:43:48 +1000 Subject: flutter: Throw a useful message when there are missing artifact hashes --- pkgs/development/compilers/flutter/engine-artifacts/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/flutter/engine-artifacts/default.nix b/pkgs/development/compilers/flutter/engine-artifacts/default.nix index 30ef16bbeca98..214a195e0c4b8 100644 --- a/pkgs/development/compilers/flutter/engine-artifacts/default.nix +++ b/pkgs/development/compilers/flutter/engine-artifacts/default.nix @@ -9,7 +9,8 @@ }: let - hashes = (import ./hashes.nix).${engineVersion}; + hashes = (import ./hashes.nix).${engineVersion} or + (throw "There are no known artifact hashes for Flutter engine version ${engineVersion}."); artifacts = { -- cgit 1.4.1 From 552e3fe49817599c2127a8ab32b72b8e6bf9f724 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 23 Apr 2023 14:44:46 +1000 Subject: flutter: Don't use IFD to read the engine version --- pkgs/development/compilers/flutter/default.nix | 8 +++++--- pkgs/development/compilers/flutter/flutter.nix | 12 +++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix index e3b060777e706..2cc1844801ffb 100644 --- a/pkgs/development/compilers/flutter/default.nix +++ b/pkgs/development/compilers/flutter/default.nix @@ -1,12 +1,12 @@ { callPackage, fetchzip, dart }: let - mkFlutter = { version, patches, dart, src }: callPackage ./flutter.nix { inherit version patches dart src; }; + mkFlutter = { version, engineVersion, patches, dart, src }: callPackage ./flutter.nix { inherit version engineVersion patches dart src; }; wrapFlutter = flutter: callPackage ./wrapper.nix { inherit flutter; }; getPatches = dir: let files = builtins.attrNames (builtins.readDir dir); in map (f: dir + ("/" + f)) files; - flutterDrv = { version, dartVersion, hash, dartHash, patches }: mkFlutter { - inherit version patches; + flutterDrv = { version, engineVersion, dartVersion, hash, dartHash, patches }: mkFlutter { + inherit version engineVersion patches; dart = dart.override { version = dartVersion; sources = { @@ -32,6 +32,7 @@ in inherit mkFlutter wrapFlutter flutterDrv flutter3Patches flutter2Patches; stable = flutterDrv { version = "3.7.12"; + engineVersion = "1a65d409c7a1438a34d21b60bf30a6fd5db59314"; dartVersion = "2.19.6"; hash = "sha256-5ExDBQXIpoZ5NwS66seY3m9/V8xDiyq/RdzldAyHdEE="; dartHash = { @@ -43,6 +44,7 @@ in v2 = flutterDrv { version = "2.10.5"; + engineVersion = "57d3bac3dd5cb5b0e464ab70e7bc8a0d8cf083ab"; dartVersion = "2.16.2"; hash = "sha256-MxaWvlcCfXN8gsC116UMzqb4LgixHL3YjrGWy7WYgW4="; dartHash = { diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index a566a543e4184..92d635be96781 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -1,4 +1,5 @@ { version +, engineVersion , patches , dart , src @@ -29,9 +30,7 @@ let engineArtifactDirectory = let - engineArtifacts = callPackage ./engine-artifacts { - engineVersion = lib.removeSuffix "\n" (builtins.readFile (src + /bin/internal/engine.version)); - }; + engineArtifacts = callPackage ./engine-artifacts { inherit engineVersion; }; in runCommandLocal "flutter-engine-artifacts-${version}" { } ( @@ -81,6 +80,13 @@ let buildInputs = [ git ]; + preConfigure = '' + if [ "$(< bin/internal/engine.version)" != '${engineVersion}' ]; then + echo 1>&2 "The given engine version (${engineVersion}) does not match the version required by the Flutter SDK ($(< bin/internal/engine.version))." + exit 1 + fi + ''; + postPatch = '' patchShebangs --build ./bin/ ''; -- cgit 1.4.1 From f7af9373ed3a615471669802134cf02f7a46f985 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Tue, 25 Apr 2023 14:40:29 +1000 Subject: flutter: Generate target PKG_CONFIG_PATH at build time --- pkgs/development/compilers/flutter/wrapper.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index 114465fd0efe7..4ea17924ecb71 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -79,7 +79,7 @@ let ]; # Nix-specific compiler configuration. - pkgConfigDirectories = builtins.filter builtins.pathExists (builtins.concatMap (pkg: map (dir: "${lib.getOutput "dev" pkg}/${dir}/pkgconfig") [ "lib" "share" ]) (appBuildDeps ++ extraPkgConfigPackages)); + pkgConfigPackages = map (lib.getOutput "dev") (appBuildDeps ++ extraPkgConfigPackages); includeFlags = map (pkg: "-isystem ${lib.getOutput "dev" pkg}/include") (appStaticBuildDeps ++ extraIncludes); linkerFlags = (map (pkg: "-rpath,${lib.getOutput "lib" pkg}/lib") appRuntimeDeps) ++ extraLinkerFlags; in @@ -94,11 +94,15 @@ in inherit (flutter) meta; } '' + for path in ${builtins.concatStringsSep " " (builtins.foldl' (paths: pkg: paths ++ (map (directory: "'${pkg}/${directory}/pkgconfig'") ["lib" "share"])) [ ] pkgConfigPackages)}; do + addToSearchPath FLUTTER_PKG_CONFIG_PATH "$path" + done + mkdir -p $out/bin makeWrapper '${immutableFlutter}' $out/bin/flutter \ --set-default ANDROID_EMULATOR_USE_SYSTEM_LIBS 1 \ --prefix PATH : '${lib.makeBinPath (tools ++ buildTools)}' \ - --prefix PKG_CONFIG_PATH : '${builtins.concatStringsSep ":" pkgConfigDirectories}' \ + --prefix PKG_CONFIG_PATH : "$FLUTTER_PKG_CONFIG_PATH" \ --prefix LIBRARY_PATH : '${lib.makeLibraryPath appStaticBuildDeps}' \ --prefix CXXFLAGS "''\t" '${builtins.concatStringsSep " " (includeFlags ++ extraCxxFlags)}' \ --prefix CFLAGS "''\t" '${builtins.concatStringsSep " " (includeFlags ++ extraCFlags)}' \ -- cgit 1.4.1