about summary refs log tree commit diff
path: root/doc/languages-frameworks/dart.section.md
diff options
context:
space:
mode:
authorGabriel Fontes <hi@m7.rs>2023-05-04 20:20:03 -0300
committerGabriel Fontes <hi@m7.rs>2023-05-05 13:32:45 -0300
commit782c8b44ddda7b5c51ad22d388d93bb39f05586e (patch)
treec492cb1160e8364f575a6e4b22e164fa5d6d62fe /doc/languages-frameworks/dart.section.md
parentac9172023093dad1adf9931513afb0c55bb14b7f (diff)
downloadnixlib-782c8b44ddda7b5c51ad22d388d93bb39f05586e.tar
nixlib-782c8b44ddda7b5c51ad22d388d93bb39f05586e.tar.gz
nixlib-782c8b44ddda7b5c51ad22d388d93bb39f05586e.tar.bz2
nixlib-782c8b44ddda7b5c51ad22d388d93bb39f05586e.tar.lz
nixlib-782c8b44ddda7b5c51ad22d388d93bb39f05586e.tar.xz
nixlib-782c8b44ddda7b5c51ad22d388d93bb39f05586e.tar.zst
nixlib-782c8b44ddda7b5c51ad22d388d93bb39f05586e.zip
buildDartApplication: init
This adds a function for easily packaging non-flutter dart apps.
Diffstat (limited to 'doc/languages-frameworks/dart.section.md')
-rw-r--r--doc/languages-frameworks/dart.section.md36
1 files changed, 36 insertions, 0 deletions
diff --git a/doc/languages-frameworks/dart.section.md b/doc/languages-frameworks/dart.section.md
new file mode 100644
index 000000000000..eb7c82748ad6
--- /dev/null
+++ b/doc/languages-frameworks/dart.section.md
@@ -0,0 +1,36 @@
+# Dart {#sec-language-dart}
+
+## Dart applications {#ssec-dart-applications}
+
+The function `buildDartApplication` builds Dart applications managed with pub.
+
+It fetches its Dart dependencies automatically through `fetchDartDeps`, and (through a series of hooks) builds and installs the executables specified in the pubspec file. The hooks can be used in other derivations, if needed. The phases can also be overridden to do something different from installing binaries.
+
+If you are packaging a Flutter desktop application, use the `buildFlutterApplication` function instead.
+
+`vendorHash`: is the hash of the output of the dependency fetcher derivation. To obtain it, simply set it to `lib.fakeHash` (or omit it) and run the build ([more details here](#sec-source-hashes)).
+
+If the upstream source is missing a `pubspec.lock` file, you'll have to vendor one and specify it using `pubspecLockFile`. If it is needed, one will be generated for you and printed when attempting to build the derivation.
+
+The `dart` commands run can be overridden through `pubGetScript` and `dartCompileCommand`, you can also add flags using `dartCompileFlags` or `dartJitFlags`.
+
+Dart supports multiple [outputs types](https://dart.dev/tools/dart-compile#types-of-output), you can choose between them using `dartOutputType` (defaults to `exe`). If you want to override the binaries path or the source path they come from, you can use `dartEntryPoints`. Outputs that require a runtime will automatically be wrapped with the relevant runtime (`dartaotruntime` for `aot-snapshot`, `dart run` for `jit-snapshot` and `kernel`, `node` for `js`), this can be overridden through `dartRuntimeCommand`.
+
+```nix
+{ buildDartApplication, fetchFromGitHub }:
+
+buildDartApplication rec {
+  pname = "dart-sass";
+  version = "1.62.1";
+
+  src = fetchFromGitHub {
+    owner = "sass";
+    repo = pname;
+    rev = version;
+    hash = "sha256-U6enz8yJcc4Wf8m54eYIAnVg/jsGi247Wy8lp1r1wg4=";
+  };
+
+  pubspecLockFile = ./pubspec.lock;
+  vendorHash = "sha256-Atm7zfnDambN/BmmUf4BG0yUz/y6xWzf0reDw3Ad41s=";
+}
+```