Loading doc/hooks/tauri.section.md +5 −5 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ In Nixpkgs, `cargo-tauri.hook` overrides the default build and install phases. wrapGAppsHook4, }: rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage (finalAttrs: { # ... useFetchCargoVendor = true; Loading @@ -31,7 +31,7 @@ rustPlatform.buildRustPackage rec { # Assuming our app's frontend uses `npm` as a package manager npmDeps = fetchNpmDeps { name = "${pname}-npm-deps-${version}"; name = "${finalAttrs.pname}-npm-deps-${finalAttrs.version}"; inherit src; hash = "..."; }; Loading Loading @@ -62,7 +62,7 @@ rustPlatform.buildRustPackage rec { buildAndTestSubdir = cargoRoot; # ... } }) ``` ## Variables controlling cargo-tauri {#tauri-hook-variables-controlling} Loading doc/languages-frameworks/go.section.md +3 −3 Original line number Diff line number Diff line Loading @@ -13,14 +13,14 @@ The following is an example expression using `buildGoModule`: ```nix { pet = buildGoModule rec { pet = buildGoModule (finalAttrs: { pname = "pet"; version = "0.3.4"; src = fetchFromGitHub { owner = "knqyf263"; repo = "pet"; rev = "v${version}"; rev = "v${finalAttrs.version}"; hash = "sha256-Gjw1dRrgM8D3G7v6WIM2+50r4HmTXvx0Xxme2fH9TlQ="; }; Loading @@ -32,7 +32,7 @@ The following is an example expression using `buildGoModule`: license = lib.licenses.mit; maintainers = with lib.maintainers; [ kalbasit ]; }; }; }); } ``` Loading doc/languages-frameworks/javascript.section.md +3 −3 Original line number Diff line number Diff line Loading @@ -198,14 +198,14 @@ Here's an example: fetchFromGitHub, }: buildNpmPackage rec { buildNpmPackage (finalAttrs: { pname = "flood"; version = "4.7.0"; src = fetchFromGitHub { owner = "jesec"; repo = pname; rev = "v${version}"; rev = "v${finalAttrs.version}"; hash = "sha256-BR+ZGkBBfd0dSQqAvujsbgsEPFYw/ThrylxUbOksYxM="; }; Loading @@ -222,7 +222,7 @@ buildNpmPackage rec { license = lib.licenses.gpl3Only; maintainers = with lib.maintainers; [ winter ]; }; } }) ``` In the default `installPhase` set by `buildNpmPackage`, it uses `npm pack --json --dry-run` to decide what files to install in `$out/lib/node_modules/$name/`, where `$name` is the `name` string defined in the package's `package.json`. Loading doc/languages-frameworks/maven.section.md +12 −12 Original line number Diff line number Diff line Loading @@ -370,7 +370,7 @@ let # pick a repository derivation, here we will use buildMaven repository = callPackage ./build-maven-repository.nix { }; in stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: { pname = "maven-demo"; version = "1.0"; Loading @@ -393,7 +393,7 @@ stdenv.mkDerivation rec { runHook postInstall ''; } }) ``` ::: {.tip} Loading Loading @@ -441,7 +441,7 @@ We make sure to provide this classpath to the `makeWrapper`. let repository = callPackage ./build-maven-repository.nix { }; in stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: { pname = "maven-demo"; version = "1.0"; Loading @@ -464,16 +464,16 @@ stdenv.mkDerivation rec { mkdir -p $out/bin classpath=$(find ${repository} -name "*.jar" -printf ':%h/%f'); install -Dm644 target/${pname}-${version}.jar $out/share/java install -Dm644 target/maven-demo-${finalAttrs.version}.jar $out/share/java # create a wrapper that will automatically set the classpath # this should be the paths from the dependency derivation makeWrapper ${jre}/bin/java $out/bin/${pname} \ --add-flags "-classpath $out/share/java/${pname}-${version}.jar:''${classpath#:}" \ makeWrapper ${jre}/bin/java $out/bin/maven-demo \ --add-flags "-classpath $out/share/java/maven-demo-${finalAttrs.version}.jar:''${classpath#:}" \ --add-flags "Main" runHook postInstall ''; } }) ``` #### MANIFEST file via Maven Plugin {#manifest-file-via-maven-plugin} Loading Loading @@ -534,7 +534,7 @@ let # pick a repository derivation, here we will use buildMaven repository = callPackage ./build-maven-repository.nix { }; in stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: { pname = "maven-demo"; version = "1.0"; Loading @@ -559,15 +559,15 @@ stdenv.mkDerivation rec { # create a symbolic link for the repository directory ln -s ${repository} $out/repository install -Dm644 target/${pname}-${version}.jar $out/share/java install -Dm644 target/maven-demo-${finalAttrs.version}.jar $out/share/java # create a wrapper that will automatically set the classpath # this should be the paths from the dependency derivation makeWrapper ${jre}/bin/java $out/bin/${pname} \ --add-flags "-jar $out/share/java/${pname}-${version}.jar" makeWrapper ${jre}/bin/java $out/bin/maven-demo \ --add-flags "-jar $out/share/java/maven-demo-${finalAttrs.version}.jar" runHook postInstall ''; } }) ``` ::: {.note} Our script produces a dependency on `jre` rather than `jdk` to restrict the runtime closure necessary to run the application. Loading doc/languages-frameworks/rust.section.md +20 −19 Original line number Diff line number Diff line Loading @@ -28,14 +28,14 @@ Rust applications are packaged by using the `buildRustPackage` helper from `rust rustPlatform, }: rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage (finalAttrs: { pname = "ripgrep"; version = "14.1.1"; src = fetchFromGitHub { owner = "BurntSushi"; repo = pname; rev = version; repo = "ripgrep"; tag = finalAttrs.version; hash = "sha256-gyWnahj1A+iXUQlQ1O1H1u7K5euYQOld9qWm99Vjaeg="; }; Loading @@ -48,7 +48,7 @@ rustPlatform.buildRustPackage rec { license = lib.licenses.unlicense; maintainers = [ ]; }; } }) ``` `buildRustPackage` requires a `cargoHash` attribute, computed over all crate sources of this package. Loading Loading @@ -104,21 +104,21 @@ be made invariant to the version by setting `cargoDepsName` to `pname`: ```nix rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage (finalAttrs: { pname = "broot"; version = "1.2.0"; src = fetchCrate { inherit pname version; inherit (finalAttrs) pname version; hash = "sha256-aDQA4A5mScX9or3Lyiv/5GyAehidnpKKE0grhbP1Ctc="; }; useFetchCargoVendor = true; cargoHash = "sha256-iDYh52rj1M5Uupvbx2WeDd/jvQZ+2A50V5rp5e2t7q4="; cargoDepsName = pname; cargoDepsName = finalAttrs.pname; # ... } }) ``` ### Importing a `Cargo.lock` file {#importing-a-cargo.lock-file} Loading Loading @@ -184,7 +184,7 @@ The output hash of each dependency that uses a git source must be specified in the `outputHashes` attribute. For example: ```nix rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage { pname = "myproject"; version = "1.0.0"; Loading @@ -209,7 +209,7 @@ For usage outside nixpkgs, `allowBuiltinFetchGit` could be used to avoid having to specify `outputHashes`. For example: ```nix rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage { pname = "myproject"; version = "1.0.0"; Loading @@ -235,7 +235,7 @@ If you want to use different features for check phase, you can use For example: ```nix rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage { pname = "myproject"; version = "1.0.0"; Loading Loading @@ -427,7 +427,7 @@ source code in a reproducible way. If it is missing or out-of-date one can use the `cargoPatches` attribute to update or add it. ```nix rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage { # ... cargoPatches = [ # a patch file to add/update Cargo.lock in the source code Loading Loading @@ -705,7 +705,7 @@ Some projects, especially GNOME applications, are built with the Meson Build Sys tinysparql, }: stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: { pname = "health"; version = "0.95.0"; Loading @@ -713,12 +713,12 @@ stdenv.mkDerivation rec { domain = "gitlab.gnome.org"; owner = "World"; repo = "health"; rev = version; tag = finalAttrs.version; hash = "sha256-PrNPprSS98yN8b8yw2G6hzTSaoE65VbsM3q7FVB4mds="; }; cargoDeps = rustPlatform.fetchCargoVendor { inherit pname version src; inherit (finalAttrs) pname version src; hash = "sha256-eR1ZGtTZQNhofFUEjI7IX16sMKPJmAl7aIFfPJukecg="; }; Loading @@ -740,7 +740,7 @@ stdenv.mkDerivation rec { ]; # ... } }) ``` ## `buildRustCrate`: Compiling Rust crates using Nix instead of Cargo {#compiling-rust-crates-using-nix-instead-of-cargo} Loading Loading @@ -1000,20 +1000,21 @@ let }; in rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage (finalAttrs: { pname = "ripgrep"; version = "14.1.1"; src = fetchFromGitHub { owner = "BurntSushi"; repo = "ripgrep"; rev = version; tag = finalAttrs.version; hash = "sha256-gyWnahj1A+iXUQlQ1O1H1u7K5euYQOld9qWm99Vjaeg="; }; useFetchCargoVendor = true; cargoHash = "sha256-9atn5qyBDy4P6iUoHFhg+TV6Ur71fiah4oTJbBMeEy4="; # Tests require network access. Skipping. doCheck = false; meta = { Loading @@ -1025,7 +1026,7 @@ rustPlatform.buildRustPackage rec { ]; maintainers = with lib.maintainers; [ ]; }; } }) ``` Follow the below steps to try that snippet. Loading Loading
doc/hooks/tauri.section.md +5 −5 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ In Nixpkgs, `cargo-tauri.hook` overrides the default build and install phases. wrapGAppsHook4, }: rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage (finalAttrs: { # ... useFetchCargoVendor = true; Loading @@ -31,7 +31,7 @@ rustPlatform.buildRustPackage rec { # Assuming our app's frontend uses `npm` as a package manager npmDeps = fetchNpmDeps { name = "${pname}-npm-deps-${version}"; name = "${finalAttrs.pname}-npm-deps-${finalAttrs.version}"; inherit src; hash = "..."; }; Loading Loading @@ -62,7 +62,7 @@ rustPlatform.buildRustPackage rec { buildAndTestSubdir = cargoRoot; # ... } }) ``` ## Variables controlling cargo-tauri {#tauri-hook-variables-controlling} Loading
doc/languages-frameworks/go.section.md +3 −3 Original line number Diff line number Diff line Loading @@ -13,14 +13,14 @@ The following is an example expression using `buildGoModule`: ```nix { pet = buildGoModule rec { pet = buildGoModule (finalAttrs: { pname = "pet"; version = "0.3.4"; src = fetchFromGitHub { owner = "knqyf263"; repo = "pet"; rev = "v${version}"; rev = "v${finalAttrs.version}"; hash = "sha256-Gjw1dRrgM8D3G7v6WIM2+50r4HmTXvx0Xxme2fH9TlQ="; }; Loading @@ -32,7 +32,7 @@ The following is an example expression using `buildGoModule`: license = lib.licenses.mit; maintainers = with lib.maintainers; [ kalbasit ]; }; }; }); } ``` Loading
doc/languages-frameworks/javascript.section.md +3 −3 Original line number Diff line number Diff line Loading @@ -198,14 +198,14 @@ Here's an example: fetchFromGitHub, }: buildNpmPackage rec { buildNpmPackage (finalAttrs: { pname = "flood"; version = "4.7.0"; src = fetchFromGitHub { owner = "jesec"; repo = pname; rev = "v${version}"; rev = "v${finalAttrs.version}"; hash = "sha256-BR+ZGkBBfd0dSQqAvujsbgsEPFYw/ThrylxUbOksYxM="; }; Loading @@ -222,7 +222,7 @@ buildNpmPackage rec { license = lib.licenses.gpl3Only; maintainers = with lib.maintainers; [ winter ]; }; } }) ``` In the default `installPhase` set by `buildNpmPackage`, it uses `npm pack --json --dry-run` to decide what files to install in `$out/lib/node_modules/$name/`, where `$name` is the `name` string defined in the package's `package.json`. Loading
doc/languages-frameworks/maven.section.md +12 −12 Original line number Diff line number Diff line Loading @@ -370,7 +370,7 @@ let # pick a repository derivation, here we will use buildMaven repository = callPackage ./build-maven-repository.nix { }; in stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: { pname = "maven-demo"; version = "1.0"; Loading @@ -393,7 +393,7 @@ stdenv.mkDerivation rec { runHook postInstall ''; } }) ``` ::: {.tip} Loading Loading @@ -441,7 +441,7 @@ We make sure to provide this classpath to the `makeWrapper`. let repository = callPackage ./build-maven-repository.nix { }; in stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: { pname = "maven-demo"; version = "1.0"; Loading @@ -464,16 +464,16 @@ stdenv.mkDerivation rec { mkdir -p $out/bin classpath=$(find ${repository} -name "*.jar" -printf ':%h/%f'); install -Dm644 target/${pname}-${version}.jar $out/share/java install -Dm644 target/maven-demo-${finalAttrs.version}.jar $out/share/java # create a wrapper that will automatically set the classpath # this should be the paths from the dependency derivation makeWrapper ${jre}/bin/java $out/bin/${pname} \ --add-flags "-classpath $out/share/java/${pname}-${version}.jar:''${classpath#:}" \ makeWrapper ${jre}/bin/java $out/bin/maven-demo \ --add-flags "-classpath $out/share/java/maven-demo-${finalAttrs.version}.jar:''${classpath#:}" \ --add-flags "Main" runHook postInstall ''; } }) ``` #### MANIFEST file via Maven Plugin {#manifest-file-via-maven-plugin} Loading Loading @@ -534,7 +534,7 @@ let # pick a repository derivation, here we will use buildMaven repository = callPackage ./build-maven-repository.nix { }; in stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: { pname = "maven-demo"; version = "1.0"; Loading @@ -559,15 +559,15 @@ stdenv.mkDerivation rec { # create a symbolic link for the repository directory ln -s ${repository} $out/repository install -Dm644 target/${pname}-${version}.jar $out/share/java install -Dm644 target/maven-demo-${finalAttrs.version}.jar $out/share/java # create a wrapper that will automatically set the classpath # this should be the paths from the dependency derivation makeWrapper ${jre}/bin/java $out/bin/${pname} \ --add-flags "-jar $out/share/java/${pname}-${version}.jar" makeWrapper ${jre}/bin/java $out/bin/maven-demo \ --add-flags "-jar $out/share/java/maven-demo-${finalAttrs.version}.jar" runHook postInstall ''; } }) ``` ::: {.note} Our script produces a dependency on `jre` rather than `jdk` to restrict the runtime closure necessary to run the application. Loading
doc/languages-frameworks/rust.section.md +20 −19 Original line number Diff line number Diff line Loading @@ -28,14 +28,14 @@ Rust applications are packaged by using the `buildRustPackage` helper from `rust rustPlatform, }: rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage (finalAttrs: { pname = "ripgrep"; version = "14.1.1"; src = fetchFromGitHub { owner = "BurntSushi"; repo = pname; rev = version; repo = "ripgrep"; tag = finalAttrs.version; hash = "sha256-gyWnahj1A+iXUQlQ1O1H1u7K5euYQOld9qWm99Vjaeg="; }; Loading @@ -48,7 +48,7 @@ rustPlatform.buildRustPackage rec { license = lib.licenses.unlicense; maintainers = [ ]; }; } }) ``` `buildRustPackage` requires a `cargoHash` attribute, computed over all crate sources of this package. Loading Loading @@ -104,21 +104,21 @@ be made invariant to the version by setting `cargoDepsName` to `pname`: ```nix rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage (finalAttrs: { pname = "broot"; version = "1.2.0"; src = fetchCrate { inherit pname version; inherit (finalAttrs) pname version; hash = "sha256-aDQA4A5mScX9or3Lyiv/5GyAehidnpKKE0grhbP1Ctc="; }; useFetchCargoVendor = true; cargoHash = "sha256-iDYh52rj1M5Uupvbx2WeDd/jvQZ+2A50V5rp5e2t7q4="; cargoDepsName = pname; cargoDepsName = finalAttrs.pname; # ... } }) ``` ### Importing a `Cargo.lock` file {#importing-a-cargo.lock-file} Loading Loading @@ -184,7 +184,7 @@ The output hash of each dependency that uses a git source must be specified in the `outputHashes` attribute. For example: ```nix rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage { pname = "myproject"; version = "1.0.0"; Loading @@ -209,7 +209,7 @@ For usage outside nixpkgs, `allowBuiltinFetchGit` could be used to avoid having to specify `outputHashes`. For example: ```nix rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage { pname = "myproject"; version = "1.0.0"; Loading @@ -235,7 +235,7 @@ If you want to use different features for check phase, you can use For example: ```nix rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage { pname = "myproject"; version = "1.0.0"; Loading Loading @@ -427,7 +427,7 @@ source code in a reproducible way. If it is missing or out-of-date one can use the `cargoPatches` attribute to update or add it. ```nix rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage { # ... cargoPatches = [ # a patch file to add/update Cargo.lock in the source code Loading Loading @@ -705,7 +705,7 @@ Some projects, especially GNOME applications, are built with the Meson Build Sys tinysparql, }: stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: { pname = "health"; version = "0.95.0"; Loading @@ -713,12 +713,12 @@ stdenv.mkDerivation rec { domain = "gitlab.gnome.org"; owner = "World"; repo = "health"; rev = version; tag = finalAttrs.version; hash = "sha256-PrNPprSS98yN8b8yw2G6hzTSaoE65VbsM3q7FVB4mds="; }; cargoDeps = rustPlatform.fetchCargoVendor { inherit pname version src; inherit (finalAttrs) pname version src; hash = "sha256-eR1ZGtTZQNhofFUEjI7IX16sMKPJmAl7aIFfPJukecg="; }; Loading @@ -740,7 +740,7 @@ stdenv.mkDerivation rec { ]; # ... } }) ``` ## `buildRustCrate`: Compiling Rust crates using Nix instead of Cargo {#compiling-rust-crates-using-nix-instead-of-cargo} Loading Loading @@ -1000,20 +1000,21 @@ let }; in rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage (finalAttrs: { pname = "ripgrep"; version = "14.1.1"; src = fetchFromGitHub { owner = "BurntSushi"; repo = "ripgrep"; rev = version; tag = finalAttrs.version; hash = "sha256-gyWnahj1A+iXUQlQ1O1H1u7K5euYQOld9qWm99Vjaeg="; }; useFetchCargoVendor = true; cargoHash = "sha256-9atn5qyBDy4P6iUoHFhg+TV6Ur71fiah4oTJbBMeEy4="; # Tests require network access. Skipping. doCheck = false; meta = { Loading @@ -1025,7 +1026,7 @@ rustPlatform.buildRustPackage rec { ]; maintainers = with lib.maintainers; [ ]; }; } }) ``` Follow the below steps to try that snippet. Loading