about summary refs log tree commit diff
path: root/doc
diff options
context:
space:
mode:
authorKira Bruneau <kira.bruneau@pm.me>2023-05-11 14:43:20 -0400
committerGitHub <noreply@github.com>2023-05-11 14:43:20 -0400
commitd4652d33d6af0caf80c9976af34db03d5c2c8fa7 (patch)
tree025e128adb31d1079357c92933f67531e541e31c /doc
parent8317bbe57a2b785b04aabb7ea8c520a8e8cdadd8 (diff)
parent70d3f5c0b4814d63ff364eec75b3b82d3e09a39c (diff)
downloadnixlib-d4652d33d6af0caf80c9976af34db03d5c2c8fa7.tar
nixlib-d4652d33d6af0caf80c9976af34db03d5c2c8fa7.tar.gz
nixlib-d4652d33d6af0caf80c9976af34db03d5c2c8fa7.tar.bz2
nixlib-d4652d33d6af0caf80c9976af34db03d5c2c8fa7.tar.lz
nixlib-d4652d33d6af0caf80c9976af34db03d5c2c8fa7.tar.xz
nixlib-d4652d33d6af0caf80c9976af34db03d5c2c8fa7.tar.zst
nixlib-d4652d33d6af0caf80c9976af34db03d5c2c8fa7.zip
Merge pull request #229770 from Misterio77/init-buildDartPackage
buildDartApplication: init
Diffstat (limited to 'doc')
-rw-r--r--doc/languages-frameworks/dart.section.md65
-rw-r--r--doc/languages-frameworks/index.xml1
2 files changed, 66 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..b00327b78eb2
--- /dev/null
+++ b/doc/languages-frameworks/dart.section.md
@@ -0,0 +1,65 @@
+# 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 [`buildFlutterApplication`](#ssec-dart-flutter) 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=";
+}
+```
+
+## Flutter applications {#ssec-dart-flutter}
+
+The function `buildFlutterApplication` builds Flutter applications.
+
+The deps.json file must always be provided when packaging in Nixpkgs. It will be generated and printed if the derivation is attempted to be built without one. Alternatively, `autoDepsList` may be set to `true` when outside of Nixpkgs, as it relies on import-from-derivation.
+
+A `pubspec.lock` file must be available. See the [Dart documentation](#ssec-dart-applications) for more details.
+
+```nix
+{  flutter, fetchFromGitHub }:
+
+flutter.buildFlutterApplication {
+  pname = "firmware-updater";
+  version = "unstable-2023-04-30";
+
+  src = fetchFromGitHub {
+    owner = "canonical";
+    repo = "firmware-updater";
+    rev = "6e7dbdb64e344633ea62874b54ff3990bd3b8440";
+    sha256 = "sha256-s5mwtr5MSPqLMN+k851+pFIFFPa0N1hqz97ys050tFA=";
+    fetchSubmodules = true;
+  };
+
+  pubspecLockFile = ./pubspec.lock;
+  depsListFile = ./deps.json;
+  vendorHash = "sha256-cdMO+tr6kYiN5xKXa+uTMAcFf2C75F3wVPrn21G4QPQ=";
+}
+```
diff --git a/doc/languages-frameworks/index.xml b/doc/languages-frameworks/index.xml
index e1e35564e321..94c4e303027f 100644
--- a/doc/languages-frameworks/index.xml
+++ b/doc/languages-frameworks/index.xml
@@ -14,6 +14,7 @@
  <xi:include href="crystal.section.xml" />
  <xi:include href="cuda.section.xml" />
  <xi:include href="cuelang.section.xml" />
+ <xi:include href="dart.section.xml" />
  <xi:include href="dhall.section.xml" />
  <xi:include href="dotnet.section.xml" />
  <xi:include href="emscripten.section.xml" />