about summary refs log tree commit diff
path: root/doc
diff options
context:
space:
mode:
authorAleksana <me@aleksana.moe>2024-03-26 04:45:19 +0800
committerGitHub <noreply@github.com>2024-03-25 21:45:19 +0100
commit5616042a51ddfa5ab5ac248f94938a46a273d2a4 (patch)
treea69fd60071287a02be8d99e200389b692f0553b1 /doc
parent03adc266bf51cdd6bf04b660b421012b8c5cc281 (diff)
downloadnixlib-5616042a51ddfa5ab5ac248f94938a46a273d2a4.tar
nixlib-5616042a51ddfa5ab5ac248f94938a46a273d2a4.tar.gz
nixlib-5616042a51ddfa5ab5ac248f94938a46a273d2a4.tar.bz2
nixlib-5616042a51ddfa5ab5ac248f94938a46a273d2a4.tar.lz
nixlib-5616042a51ddfa5ab5ac248f94938a46a273d2a4.tar.xz
nixlib-5616042a51ddfa5ab5ac248f94938a46a273d2a4.tar.zst
nixlib-5616042a51ddfa5ab5ac248f94938a46a273d2a4.zip
doc: add build rust package with meson example (#298881)
Diffstat (limited to 'doc')
-rw-r--r--doc/languages-frameworks/rust.section.md60
1 files changed, 60 insertions, 0 deletions
diff --git a/doc/languages-frameworks/rust.section.md b/doc/languages-frameworks/rust.section.md
index 75e57a8bb574..274ee9ce9cc4 100644
--- a/doc/languages-frameworks/rust.section.md
+++ b/doc/languages-frameworks/rust.section.md
@@ -651,6 +651,66 @@ buildPythonPackage rec {
 }
 ```
 
+#### Rust package built with `meson` {#rust-package-built-with-meson}
+
+Some projects, especially GNOME applications, are built with the Meson Build System instead of calling Cargo directly. Using `rustPlatform.buildRustPackage` may successfully build the main program, but related files will be missing. Instead, you need to set up Cargo dependencies with `fetchCargoTarball` and `cargoSetupHook` and leave the rest to Meson. `rust` and `cargo` are still needed in `nativeBuildInputs` for Meson to use.
+
+```nix
+{ lib
+, stdenv
+, fetchFromGitLab
+, meson
+, ninja
+, pkg-config
+, rustPlatform
+, rustc
+, cargo
+, wrapGAppsHook4
+, blueprint-compiler
+, libadwaita
+, libsecret
+, tracker
+}:
+
+stdenv.mkDerivation rec {
+  pname = "health";
+  version = "0.95.0";
+
+  src = fetchFromGitLab {
+    domain = "gitlab.gnome.org";
+    owner = "World";
+    repo = "health";
+    rev = version;
+    hash = "sha256-PrNPprSS98yN8b8yw2G6hzTSaoE65VbsM3q7FVB4mds=";
+  };
+
+  cargoDeps = rustPlatform.fetchCargoTarball {
+    inherit src;
+    name = "${pname}-${version}";
+    hash = "sha256-8fa3fa+sFi5H+49B5sr2vYPkp9C9s6CcE0zv4xB8gww=";
+  };
+
+  nativeBuildInputs = [
+    meson
+    ninja
+    pkg-config
+    rustPlatform.cargoSetupHook
+    rustc
+    cargo
+    wrapGAppsHook4
+    blueprint-compiler
+  ];
+
+  buildInputs = [
+    libadwaita
+    libsecret
+    tracker
+  ];
+
+  # ...
+}
+```
+
 ## `buildRustCrate`: Compiling Rust crates using Nix instead of Cargo {#compiling-rust-crates-using-nix-instead-of-cargo}
 
 ### Simple operation {#simple-operation}