diff options
author | hacker1024 <hacker1024@users.sourceforge.net> | 2023-10-26 15:40:37 +1100 |
---|---|---|
committer | FlafyDev <flafyarazi@gmail.com> | 2023-12-26 17:06:18 +0200 |
commit | 7e043f5f28da0813c0317deb5478475abb8a6156 (patch) | |
tree | 353dc0622cac565b53e3a1f0e44b7323c7f78180 /pkgs/build-support/dart | |
parent | 4eb35ef7115d9b358de4cf746c3477ab08836d28 (diff) |
buildDartApplication: Accept additional package_config.json setup commands
Diffstat (limited to 'pkgs/build-support/dart')
-rw-r--r-- | pkgs/build-support/dart/build-dart-application/default.nix | 34 | ||||
-rw-r--r-- | pkgs/build-support/dart/build-dart-application/generators.nix | 3 |
2 files changed, 21 insertions, 16 deletions
diff --git a/pkgs/build-support/dart/build-dart-application/default.nix b/pkgs/build-support/dart/build-dart-application/default.nix index 2f38a17d24424..f160cb757e484 100644 --- a/pkgs/build-support/dart/build-dart-application/default.nix +++ b/pkgs/build-support/dart/build-dart-application/default.nix @@ -19,6 +19,7 @@ , sdkSetupScript ? "" , pubGetScript ? "dart pub get" +, extraPackageConfigSetup ? "" # Output type to produce. Can be any kind supported by dart # https://dart.dev/tools/dart-compile#types-of-output @@ -64,21 +65,24 @@ let pubspecLockFile = builtins.toJSON pubspecLock; pubspecLockData = pub2nix.readPubspecLock { inherit src packageRoot pubspecLock gitHashes sdkSourceBuilders; }; - packageConfig = generators.linkPackageConfig (pub2nix.generatePackageConfig { - pname = if args.pname != null then "${args.pname}-${args.version}" else null; - - dependencies = - # Ideally, we'd only include the main dependencies and their transitive - # dependencies. - # - # The pubspec.lock file does not contain information about where - # transitive dependencies come from, though, and it would be weird to - # include the transitive dependencies of dev and override dependencies - # without including the dev and override dependencies themselves. - builtins.concatLists (builtins.attrValues pubspecLockData.dependencies); - - inherit (pubspecLockData) dependencySources; - }); + packageConfig = generators.linkPackageConfig { + packageConfig = pub2nix.generatePackageConfig { + pname = if args.pname != null then "${args.pname}-${args.version}" else null; + + dependencies = + # Ideally, we'd only include the main dependencies and their transitive + # dependencies. + # + # The pubspec.lock file does not contain information about where + # transitive dependencies come from, though, and it would be weird to + # include the transitive dependencies of dev and override dependencies + # without including the dev and override dependencies themselves. + builtins.concatLists (builtins.attrValues pubspecLockData.dependencies); + + inherit (pubspecLockData) dependencySources; + }; + extraSetupCommands = extraPackageConfigSetup; + }; inherit (dartHooks.override { inherit dart; }) dartConfigHook dartBuildHook dartInstallHook dartFixupHook; diff --git a/pkgs/build-support/dart/build-dart-application/generators.nix b/pkgs/build-support/dart/build-dart-application/generators.nix index 67b5fd81b4cdc..6af9a66b2f7f5 100644 --- a/pkgs/build-support/dart/build-dart-application/generators.nix +++ b/pkgs/build-support/dart/build-dart-application/generators.nix @@ -50,7 +50,7 @@ let name = (if drvArgs ? name then drvArgs.name else "${drvArgs.pname}-${drvArgs.version}"); # Adds the root package to a dependency package_config.json file from pub2nix. - linkPackageConfig = packageConfig: stdenvNoCC.mkDerivation (drvArgs // { + linkPackageConfig = { packageConfig, extraSetupCommands ? "" }: stdenvNoCC.mkDerivation (drvArgs // { name = "${name}-package-config-with-root.json"; nativeBuildInputs = drvArgs.nativeBuildInputs or [ ] ++ args.nativeBuildInputs or [ ] ++ [ jq yq ]; @@ -62,6 +62,7 @@ let packageName="$(yq --raw-output .name pubspec.yaml)" jq --arg name "$packageName" '.packages |= . + [{ name: $name, rootUri: "../", packageUri: "lib/" }]' '${packageConfig}' > "$out" + ${extraSetupCommands} runHook postInstall ''; |