buildDartApplication: Document running build tools

authored by

hacker1024 and committed by
FlafyDev
92809a1c bea71b1f

+22
+22
doc/languages-frameworks/dart.section.md
··· 38 } 39 ``` 40 41 ### Usage with nix-shell {#ssec-dart-applications-nix-shell} 42 43 As `buildDartApplication` provides dependencies instead of `pub get`, Dart needs to be explicitly told where to find them.
··· 38 } 39 ``` 40 41 + ### Running executables from dev_dependencies {#ssec-dart-applications-build-tools} 42 + 43 + Many Dart applications require executables from the `dev_dependencies` section in `pubspec.yaml` to be run before building them. 44 + 45 + This can be done in `preBuild`, in one of two ways: 46 + 47 + 1. Packaging the tool with `buildDartApplication`, adding it to Nixpkgs, and running it like any other application 48 + 2. Running the tool from the Pub cache 49 + 50 + Of these methods, the first is recommended when using a tool that does not need 51 + to be of a specific version. 52 + 53 + To use the second method, first make the derivation accessible within itself (e.g. `let self = ...; in self`), and then run it from the Pub cache in `preBuild`. 54 + 55 + e.g., for `build_runner`: 56 + 57 + ```bash 58 + dart --packages=.dart_tool/package_config.json ${self.pubspecLock.dependencySources.build_runner.packagePath}/bin/build_runner.dart build 59 + ``` 60 + 61 + Do _not_ use `dart run <package_name>`, as this will attempt to download dependencies with Pub. 62 + 63 ### Usage with nix-shell {#ssec-dart-applications-nix-shell} 64 65 As `buildDartApplication` provides dependencies instead of `pub get`, Dart needs to be explicitly told where to find them.