From 2bd3e5d779f31c751cf2f23e98fc4dbe74f4328c Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 29 Oct 2023 01:16:08 +1100 Subject: [PATCH] buildDartApplication: Use package source builders and setup hooks instead of package overrides --- .../dart/build-dart-application/default.nix | 21 +------------ .../dart/pub2nix/pubspec-lock.nix | 21 ++++++++++--- .../dart/package-overrides/ffigen/default.nix | 14 --------- .../flutter-secure-storage-linux/default.nix | 17 ---------- .../handy-window/default.nix | 14 --------- .../dart/package-overrides/matrix/default.nix | 12 ------- .../dart/package-overrides/olm/default.nix | 12 ------- .../package-overrides/system-tray/default.nix | 18 ----------- .../default.nix | 1 - .../flutter-secure-storage-linux/default.nix | 23 ++++++++++++++ .../handy-window/default.nix | 31 +++++++++++++++++++ .../matrix/default.nix | 30 ++++++++++++++++++ .../package-source-builders/olm/default.nix | 30 ++++++++++++++++++ .../system-tray/default.nix | 22 +++++++++++++ 14 files changed, 153 insertions(+), 113 deletions(-) delete mode 100644 pkgs/development/compilers/dart/package-overrides/ffigen/default.nix delete mode 100644 pkgs/development/compilers/dart/package-overrides/flutter-secure-storage-linux/default.nix delete mode 100644 pkgs/development/compilers/dart/package-overrides/handy-window/default.nix delete mode 100644 pkgs/development/compilers/dart/package-overrides/matrix/default.nix delete mode 100644 pkgs/development/compilers/dart/package-overrides/olm/default.nix delete mode 100644 pkgs/development/compilers/dart/package-overrides/system-tray/default.nix rename pkgs/development/compilers/dart/{package-overrides => package-source-builders}/default.nix (87%) create mode 100644 pkgs/development/compilers/dart/package-source-builders/flutter-secure-storage-linux/default.nix create mode 100644 pkgs/development/compilers/dart/package-source-builders/handy-window/default.nix create mode 100644 pkgs/development/compilers/dart/package-source-builders/matrix/default.nix create mode 100644 pkgs/development/compilers/dart/package-source-builders/olm/default.nix create mode 100644 pkgs/development/compilers/dart/package-source-builders/system-tray/default.nix diff --git a/pkgs/build-support/dart/build-dart-application/default.nix b/pkgs/build-support/dart/build-dart-application/default.nix index 2e99479c9bb0..ccecbe6fd3e8 100644 --- a/pkgs/build-support/dart/build-dart-application/default.nix +++ b/pkgs/build-support/dart/build-dart-application/default.nix @@ -44,7 +44,6 @@ , runtimeDependencies ? [ ] , extraWrapProgramArgs ? "" -, customPackageOverrides ? { } , autoDepsList ? false , depsListFile ? null , pubspecLock @@ -143,25 +142,7 @@ let meta = (args.meta or { }) // { platforms = args.meta.platforms or dart.meta.platforms; }; }); - - packageOverrideRepository = (callPackage ../../../development/compilers/dart/package-overrides { }) // customPackageOverrides; - productPackages = if depsList == null then [ ] else depsList; in assert !(builtins.isString dartOutputType && dartOutputType != "") -> throw "dartOutputType must be a non-empty string"; -builtins.foldl' - (prev: package: - if packageOverrideRepository ? ${package.name} - then - prev.overrideAttrs - (packageOverrideRepository.${package.name} { - inherit (package) - name - version - kind - source - dependencies; - }) - else prev) - baseDerivation - productPackages +baseDerivation diff --git a/pkgs/build-support/dart/pub2nix/pubspec-lock.nix b/pkgs/build-support/dart/pub2nix/pubspec-lock.nix index 3b9e50400264..fac096de31f7 100644 --- a/pkgs/build-support/dart/pub2nix/pubspec-lock.nix +++ b/pkgs/build-support/dart/pub2nix/pubspec-lock.nix @@ -1,4 +1,5 @@ { lib +, callPackage , fetchurl , fetchgit , runCommand @@ -22,6 +23,14 @@ # Functions to generate SDK package sources. # The function names should match the SDK names, and the package name is given as an argument. , sdkSourceBuilders ? { } + + # Functions that create custom package source derivations. + # + # The function names should match the package names, and the package version, + # source, and source files are given in an attribute set argument. + # + # The passthru of the source derivation should be propagated. +, customSourceBuilders ? { } }: let @@ -77,20 +86,22 @@ let addDependencySourceUtils = dependencySource: details: dependencySource.overrideAttrs ({ passthru, ... }: { passthru = passthru // { inherit (details) version; - packagePath = dependencySource + "/${dependencySource.packageRoot}"; }; }); + sourceBuilders = callPackage ../../../development/compilers/dart/package-source-builders { } // customSourceBuilders; + dependencySources = lib.filterAttrs (name: src: src != null) (builtins.mapAttrs (name: details: - addDependencySourceUtils - (({ + (sourceBuilders.${name} or ({ src, ... }: src)) { + inherit (details) version source; + src = ((addDependencySourceUtils (({ "hosted" = mkHostedDependencySource; "git" = mkGitDependencySource; "path" = mkPathDependencySource; "sdk" = mkSdkDependencySource; - }.${details.source} name) details) - details) + }.${details.source} name) details)) details); + }) pubspecLock.packages); in { diff --git a/pkgs/development/compilers/dart/package-overrides/ffigen/default.nix b/pkgs/development/compilers/dart/package-overrides/ffigen/default.nix deleted file mode 100644 index e855cb49f0ad..000000000000 --- a/pkgs/development/compilers/dart/package-overrides/ffigen/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ lib -, llvmPackages -}: - -{ ... }: - -{ FFIGEN_COMPILER_OPTS ? "" -, ... -}: - -{ - FFIGEN_LIBCLANG = lib.getLib llvmPackages.libclang; - FFIGEN_COMPILER_OPTS = "-I${FFIGEN_COMPILER_OPTS} ${llvmPackages.clang}/resource-root/include -I${lib.makeSearchPathOutput "dev" "include" [ llvmPackages.clang.libc_dev ]}"; -} diff --git a/pkgs/development/compilers/dart/package-overrides/flutter-secure-storage-linux/default.nix b/pkgs/development/compilers/dart/package-overrides/flutter-secure-storage-linux/default.nix deleted file mode 100644 index 91a61cb6c603..000000000000 --- a/pkgs/development/compilers/dart/package-overrides/flutter-secure-storage-linux/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ lib -, pkg-config -, libsecret -, jsoncpp -}: - -{ ... }: - -{ nativeBuildInputs ? [ ] -, buildInputs ? [ ] -, ... -}: - -{ - nativeBuildInputs = [ pkg-config ] ++ nativeBuildInputs; - buildInputs = [ libsecret jsoncpp ] ++ buildInputs; -} diff --git a/pkgs/development/compilers/dart/package-overrides/handy-window/default.nix b/pkgs/development/compilers/dart/package-overrides/handy-window/default.nix deleted file mode 100644 index 49b5d47487e8..000000000000 --- a/pkgs/development/compilers/dart/package-overrides/handy-window/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ lib -, cairo -, fribidi -}: - -{ ... }: - -{ CFLAGS ? "" -, ... -}: - -{ - CFLAGS = "${CFLAGS} -isystem ${lib.getOutput "dev" fribidi}/include/fribidi -isystem ${lib.getOutput "dev" cairo}/include"; -} diff --git a/pkgs/development/compilers/dart/package-overrides/matrix/default.nix b/pkgs/development/compilers/dart/package-overrides/matrix/default.nix deleted file mode 100644 index fb1adafa3208..000000000000 --- a/pkgs/development/compilers/dart/package-overrides/matrix/default.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ openssl -}: - -{ ... }: - -{ runtimeDependencies ? [ ] -, ... -}: - -{ - runtimeDependencies = runtimeDependencies ++ [ openssl ]; -} diff --git a/pkgs/development/compilers/dart/package-overrides/olm/default.nix b/pkgs/development/compilers/dart/package-overrides/olm/default.nix deleted file mode 100644 index e91e8f393ca7..000000000000 --- a/pkgs/development/compilers/dart/package-overrides/olm/default.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ olm -}: - -{ ... }: - -{ runtimeDependencies ? [ ] -, ... -}: - -{ - runtimeDependencies = runtimeDependencies ++ [ olm ]; -} diff --git a/pkgs/development/compilers/dart/package-overrides/system-tray/default.nix b/pkgs/development/compilers/dart/package-overrides/system-tray/default.nix deleted file mode 100644 index 531d833a6998..000000000000 --- a/pkgs/development/compilers/dart/package-overrides/system-tray/default.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ libayatana-appindicator -}: - -{ ... }: - -{ preBuild ? "" -, ... -}: - -{ - preBuild = preBuild + '' - # $PUB_CACHE/hosted is a symlink to a store path. - mv $PUB_CACHE/hosted $PUB_CACHE/hosted_copy - cp -HR $PUB_CACHE/hosted_copy $PUB_CACHE/hosted - substituteInPlace $PUB_CACHE/hosted/pub.dev/system_tray-*/linux/tray.cc \ - --replace "libappindicator3.so.1" "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1" - ''; -} diff --git a/pkgs/development/compilers/dart/package-overrides/default.nix b/pkgs/development/compilers/dart/package-source-builders/default.nix similarity index 87% rename from pkgs/development/compilers/dart/package-overrides/default.nix rename to pkgs/development/compilers/dart/package-source-builders/default.nix index e0467b3987ef..e015d423a1ca 100644 --- a/pkgs/development/compilers/dart/package-overrides/default.nix +++ b/pkgs/development/compilers/dart/package-source-builders/default.nix @@ -1,7 +1,6 @@ { callPackage }: { - ffigen = callPackage ./ffigen { }; flutter_secure_storage_linux = callPackage ./flutter-secure-storage-linux { }; handy_window = callPackage ./handy-window { }; matrix = callPackage ./matrix { }; diff --git a/pkgs/development/compilers/dart/package-source-builders/flutter-secure-storage-linux/default.nix b/pkgs/development/compilers/dart/package-source-builders/flutter-secure-storage-linux/default.nix new file mode 100644 index 000000000000..c111a7364656 --- /dev/null +++ b/pkgs/development/compilers/dart/package-source-builders/flutter-secure-storage-linux/default.nix @@ -0,0 +1,23 @@ +{ stdenv +, libsecret +, jsoncpp +}: + +{ version, src, ... }: + +stdenv.mkDerivation { + pname = "flutter-secure-storage-linux"; + inherit version src; + inherit (src) passthru; + + propagatedBuildInputs = [ libsecret jsoncpp ]; + + installPhase = '' + runHook preInstall + + mkdir -p "$out" + ln -s '${src}'/* "$out" + + runHook postInstall + ''; +} diff --git a/pkgs/development/compilers/dart/package-source-builders/handy-window/default.nix b/pkgs/development/compilers/dart/package-source-builders/handy-window/default.nix new file mode 100644 index 000000000000..bd43e0ed947f --- /dev/null +++ b/pkgs/development/compilers/dart/package-source-builders/handy-window/default.nix @@ -0,0 +1,31 @@ +{ stdenv +, lib +, writeScript +, cairo +, fribidi +}: + +{ version, src, ... }: + +stdenv.mkDerivation rec { + pname = "handy-window"; + inherit version src; + inherit (src) passthru; + + setupHook = writeScript "${pname}-setup-hook" '' + handyWindowConfigureHook() { + export CFLAGS="$CFLAGS -isystem ${lib.getDev fribidi}/include/fribidi -isystem ${lib.getDev cairo}/include" + } + + postConfigureHooks+=(handyWindowConfigureHook) + ''; + + installPhase = '' + runHook preInstall + + mkdir -p "$out" + ln -s '${src}'/* "$out" + + runHook postInstall + ''; +} diff --git a/pkgs/development/compilers/dart/package-source-builders/matrix/default.nix b/pkgs/development/compilers/dart/package-source-builders/matrix/default.nix new file mode 100644 index 000000000000..1e2c3fea80e7 --- /dev/null +++ b/pkgs/development/compilers/dart/package-source-builders/matrix/default.nix @@ -0,0 +1,30 @@ +{ stdenv +, lib +, writeScript +, openssl +}: + +{ version, src, ... }: + +stdenv.mkDerivation rec { + pname = "matrix"; + inherit version src; + inherit (src) passthru; + + setupHook = writeScript "${pname}-setup-hook" '' + matrixFixupHook() { + runtimeDependencies+=('${lib.getLib openssl}') + } + + preFixupHooks+=(matrixFixupHook) + ''; + + installPhase = '' + runHook preInstall + + mkdir -p "$out" + ln -s '${src}'/* "$out" + + runHook postInstall + ''; +} diff --git a/pkgs/development/compilers/dart/package-source-builders/olm/default.nix b/pkgs/development/compilers/dart/package-source-builders/olm/default.nix new file mode 100644 index 000000000000..8d715ff190fc --- /dev/null +++ b/pkgs/development/compilers/dart/package-source-builders/olm/default.nix @@ -0,0 +1,30 @@ +{ stdenv +, lib +, writeScript +, olm +}: + +{ version, src, ... }: + +stdenv.mkDerivation rec { + pname = "olm"; + inherit version src; + inherit (src) passthru; + + setupHook = writeScript "${pname}-setup-hook" '' + olmFixupHook() { + runtimeDependencies+=('${lib.getLib olm}') + } + + preFixupHooks+=(olmFixupHook) + ''; + + installPhase = '' + runHook preInstall + + mkdir -p "$out" + ln -s '${src}'/* "$out" + + runHook postInstall + ''; +} diff --git a/pkgs/development/compilers/dart/package-source-builders/system-tray/default.nix b/pkgs/development/compilers/dart/package-source-builders/system-tray/default.nix new file mode 100644 index 000000000000..81dc88ab2f52 --- /dev/null +++ b/pkgs/development/compilers/dart/package-source-builders/system-tray/default.nix @@ -0,0 +1,22 @@ +{ stdenv +, libayatana-appindicator +}: + +{ version, src, ... }: + +stdenv.mkDerivation rec { + pname = "system-tray"; + inherit version src; + inherit (src) passthru; + + installPhase = '' + runHook preInstall + + mkdir -p "$out" + cp -r '${src}'/* "$out" + substituteInPlace "$out/linux/tray.cc" \ + --replace "libappindicator3.so.1" "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1" + + runHook postInstall + ''; +}