buildDartApplication: Use package source builders and setup hooks instead of package overrides

authored by hacker1024 and committed by FlafyDev 2bd3e5d7 cf55bc73

+153 -113
+1 -20
pkgs/build-support/dart/build-dart-application/default.nix
··· 44 45 , runtimeDependencies ? [ ] 46 , extraWrapProgramArgs ? "" 47 - , customPackageOverrides ? { } 48 , autoDepsList ? false 49 , depsListFile ? null 50 , pubspecLock ··· 143 144 meta = (args.meta or { }) // { platforms = args.meta.platforms or dart.meta.platforms; }; 145 }); 146 - 147 - packageOverrideRepository = (callPackage ../../../development/compilers/dart/package-overrides { }) // customPackageOverrides; 148 - productPackages = if depsList == null then [ ] else depsList; 149 in 150 assert !(builtins.isString dartOutputType && dartOutputType != "") -> 151 throw "dartOutputType must be a non-empty string"; 152 - builtins.foldl' 153 - (prev: package: 154 - if packageOverrideRepository ? ${package.name} 155 - then 156 - prev.overrideAttrs 157 - (packageOverrideRepository.${package.name} { 158 - inherit (package) 159 - name 160 - version 161 - kind 162 - source 163 - dependencies; 164 - }) 165 - else prev) 166 - baseDerivation 167 - productPackages
··· 44 45 , runtimeDependencies ? [ ] 46 , extraWrapProgramArgs ? "" 47 , autoDepsList ? false 48 , depsListFile ? null 49 , pubspecLock ··· 142 143 meta = (args.meta or { }) // { platforms = args.meta.platforms or dart.meta.platforms; }; 144 }); 145 in 146 assert !(builtins.isString dartOutputType && dartOutputType != "") -> 147 throw "dartOutputType must be a non-empty string"; 148 + baseDerivation
+16 -5
pkgs/build-support/dart/pub2nix/pubspec-lock.nix
··· 1 { lib 2 , fetchurl 3 , fetchgit 4 , runCommand ··· 22 # Functions to generate SDK package sources. 23 # The function names should match the SDK names, and the package name is given as an argument. 24 , sdkSourceBuilders ? { } 25 }: 26 27 let ··· 77 addDependencySourceUtils = dependencySource: details: dependencySource.overrideAttrs ({ passthru, ... }: { 78 passthru = passthru // { 79 inherit (details) version; 80 - packagePath = dependencySource + "/${dependencySource.packageRoot}"; 81 }; 82 }); 83 84 dependencySources = lib.filterAttrs (name: src: src != null) (builtins.mapAttrs 85 (name: details: 86 - addDependencySourceUtils 87 - (({ 88 "hosted" = mkHostedDependencySource; 89 "git" = mkGitDependencySource; 90 "path" = mkPathDependencySource; 91 "sdk" = mkSdkDependencySource; 92 - }.${details.source} name) details) 93 - details) 94 pubspecLock.packages); 95 in 96 {
··· 1 { lib 2 + , callPackage 3 , fetchurl 4 , fetchgit 5 , runCommand ··· 23 # Functions to generate SDK package sources. 24 # The function names should match the SDK names, and the package name is given as an argument. 25 , sdkSourceBuilders ? { } 26 + 27 + # Functions that create custom package source derivations. 28 + # 29 + # The function names should match the package names, and the package version, 30 + # source, and source files are given in an attribute set argument. 31 + # 32 + # The passthru of the source derivation should be propagated. 33 + , customSourceBuilders ? { } 34 }: 35 36 let ··· 86 addDependencySourceUtils = dependencySource: details: dependencySource.overrideAttrs ({ passthru, ... }: { 87 passthru = passthru // { 88 inherit (details) version; 89 }; 90 }); 91 + 92 + sourceBuilders = callPackage ../../../development/compilers/dart/package-source-builders { } // customSourceBuilders; 93 94 dependencySources = lib.filterAttrs (name: src: src != null) (builtins.mapAttrs 95 (name: details: 96 + (sourceBuilders.${name} or ({ src, ... }: src)) { 97 + inherit (details) version source; 98 + src = ((addDependencySourceUtils (({ 99 "hosted" = mkHostedDependencySource; 100 "git" = mkGitDependencySource; 101 "path" = mkPathDependencySource; 102 "sdk" = mkSdkDependencySource; 103 + }.${details.source} name) details)) details); 104 + }) 105 pubspecLock.packages); 106 in 107 {
-1
pkgs/development/compilers/dart/package-overrides/default.nix pkgs/development/compilers/dart/package-source-builders/default.nix
··· 1 { callPackage }: 2 3 { 4 - ffigen = callPackage ./ffigen { }; 5 flutter_secure_storage_linux = callPackage ./flutter-secure-storage-linux { }; 6 handy_window = callPackage ./handy-window { }; 7 matrix = callPackage ./matrix { };
··· 1 { callPackage }: 2 3 { 4 flutter_secure_storage_linux = callPackage ./flutter-secure-storage-linux { }; 5 handy_window = callPackage ./handy-window { }; 6 matrix = callPackage ./matrix { };
-14
pkgs/development/compilers/dart/package-overrides/ffigen/default.nix
··· 1 - { lib 2 - , llvmPackages 3 - }: 4 - 5 - { ... }: 6 - 7 - { FFIGEN_COMPILER_OPTS ? "" 8 - , ... 9 - }: 10 - 11 - { 12 - FFIGEN_LIBCLANG = lib.getLib llvmPackages.libclang; 13 - FFIGEN_COMPILER_OPTS = "-I${FFIGEN_COMPILER_OPTS} ${llvmPackages.clang}/resource-root/include -I${lib.makeSearchPathOutput "dev" "include" [ llvmPackages.clang.libc_dev ]}"; 14 - }
···
-17
pkgs/development/compilers/dart/package-overrides/flutter-secure-storage-linux/default.nix
··· 1 - { lib 2 - , pkg-config 3 - , libsecret 4 - , jsoncpp 5 - }: 6 - 7 - { ... }: 8 - 9 - { nativeBuildInputs ? [ ] 10 - , buildInputs ? [ ] 11 - , ... 12 - }: 13 - 14 - { 15 - nativeBuildInputs = [ pkg-config ] ++ nativeBuildInputs; 16 - buildInputs = [ libsecret jsoncpp ] ++ buildInputs; 17 - }
···
-14
pkgs/development/compilers/dart/package-overrides/handy-window/default.nix
··· 1 - { lib 2 - , cairo 3 - , fribidi 4 - }: 5 - 6 - { ... }: 7 - 8 - { CFLAGS ? "" 9 - , ... 10 - }: 11 - 12 - { 13 - CFLAGS = "${CFLAGS} -isystem ${lib.getOutput "dev" fribidi}/include/fribidi -isystem ${lib.getOutput "dev" cairo}/include"; 14 - }
···
-12
pkgs/development/compilers/dart/package-overrides/matrix/default.nix
··· 1 - { openssl 2 - }: 3 - 4 - { ... }: 5 - 6 - { runtimeDependencies ? [ ] 7 - , ... 8 - }: 9 - 10 - { 11 - runtimeDependencies = runtimeDependencies ++ [ openssl ]; 12 - }
···
-12
pkgs/development/compilers/dart/package-overrides/olm/default.nix
··· 1 - { olm 2 - }: 3 - 4 - { ... }: 5 - 6 - { runtimeDependencies ? [ ] 7 - , ... 8 - }: 9 - 10 - { 11 - runtimeDependencies = runtimeDependencies ++ [ olm ]; 12 - }
···
-18
pkgs/development/compilers/dart/package-overrides/system-tray/default.nix
··· 1 - { libayatana-appindicator 2 - }: 3 - 4 - { ... }: 5 - 6 - { preBuild ? "" 7 - , ... 8 - }: 9 - 10 - { 11 - preBuild = preBuild + '' 12 - # $PUB_CACHE/hosted is a symlink to a store path. 13 - mv $PUB_CACHE/hosted $PUB_CACHE/hosted_copy 14 - cp -HR $PUB_CACHE/hosted_copy $PUB_CACHE/hosted 15 - substituteInPlace $PUB_CACHE/hosted/pub.dev/system_tray-*/linux/tray.cc \ 16 - --replace "libappindicator3.so.1" "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1" 17 - ''; 18 - }
···
+23
pkgs/development/compilers/dart/package-source-builders/flutter-secure-storage-linux/default.nix
···
··· 1 + { stdenv 2 + , libsecret 3 + , jsoncpp 4 + }: 5 + 6 + { version, src, ... }: 7 + 8 + stdenv.mkDerivation { 9 + pname = "flutter-secure-storage-linux"; 10 + inherit version src; 11 + inherit (src) passthru; 12 + 13 + propagatedBuildInputs = [ libsecret jsoncpp ]; 14 + 15 + installPhase = '' 16 + runHook preInstall 17 + 18 + mkdir -p "$out" 19 + ln -s '${src}'/* "$out" 20 + 21 + runHook postInstall 22 + ''; 23 + }
+31
pkgs/development/compilers/dart/package-source-builders/handy-window/default.nix
···
··· 1 + { stdenv 2 + , lib 3 + , writeScript 4 + , cairo 5 + , fribidi 6 + }: 7 + 8 + { version, src, ... }: 9 + 10 + stdenv.mkDerivation rec { 11 + pname = "handy-window"; 12 + inherit version src; 13 + inherit (src) passthru; 14 + 15 + setupHook = writeScript "${pname}-setup-hook" '' 16 + handyWindowConfigureHook() { 17 + export CFLAGS="$CFLAGS -isystem ${lib.getDev fribidi}/include/fribidi -isystem ${lib.getDev cairo}/include" 18 + } 19 + 20 + postConfigureHooks+=(handyWindowConfigureHook) 21 + ''; 22 + 23 + installPhase = '' 24 + runHook preInstall 25 + 26 + mkdir -p "$out" 27 + ln -s '${src}'/* "$out" 28 + 29 + runHook postInstall 30 + ''; 31 + }
+30
pkgs/development/compilers/dart/package-source-builders/matrix/default.nix
···
··· 1 + { stdenv 2 + , lib 3 + , writeScript 4 + , openssl 5 + }: 6 + 7 + { version, src, ... }: 8 + 9 + stdenv.mkDerivation rec { 10 + pname = "matrix"; 11 + inherit version src; 12 + inherit (src) passthru; 13 + 14 + setupHook = writeScript "${pname}-setup-hook" '' 15 + matrixFixupHook() { 16 + runtimeDependencies+=('${lib.getLib openssl}') 17 + } 18 + 19 + preFixupHooks+=(matrixFixupHook) 20 + ''; 21 + 22 + installPhase = '' 23 + runHook preInstall 24 + 25 + mkdir -p "$out" 26 + ln -s '${src}'/* "$out" 27 + 28 + runHook postInstall 29 + ''; 30 + }
+30
pkgs/development/compilers/dart/package-source-builders/olm/default.nix
···
··· 1 + { stdenv 2 + , lib 3 + , writeScript 4 + , olm 5 + }: 6 + 7 + { version, src, ... }: 8 + 9 + stdenv.mkDerivation rec { 10 + pname = "olm"; 11 + inherit version src; 12 + inherit (src) passthru; 13 + 14 + setupHook = writeScript "${pname}-setup-hook" '' 15 + olmFixupHook() { 16 + runtimeDependencies+=('${lib.getLib olm}') 17 + } 18 + 19 + preFixupHooks+=(olmFixupHook) 20 + ''; 21 + 22 + installPhase = '' 23 + runHook preInstall 24 + 25 + mkdir -p "$out" 26 + ln -s '${src}'/* "$out" 27 + 28 + runHook postInstall 29 + ''; 30 + }
+22
pkgs/development/compilers/dart/package-source-builders/system-tray/default.nix
···
··· 1 + { stdenv 2 + , libayatana-appindicator 3 + }: 4 + 5 + { version, src, ... }: 6 + 7 + stdenv.mkDerivation rec { 8 + pname = "system-tray"; 9 + inherit version src; 10 + inherit (src) passthru; 11 + 12 + installPhase = '' 13 + runHook preInstall 14 + 15 + mkdir -p "$out" 16 + cp -r '${src}'/* "$out" 17 + substituteInPlace "$out/linux/tray.cc" \ 18 + --replace "libappindicator3.so.1" "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1" 19 + 20 + runHook postInstall 21 + ''; 22 + }