diff --git a/doc/languages-frameworks/gradle.section.md b/doc/languages-frameworks/gradle.section.md index b2058ef87491..762c8003a7a7 100644 --- a/doc/languages-frameworks/gradle.section.md +++ b/doc/languages-frameworks/gradle.section.md @@ -17,11 +17,11 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitLab { owner = "pdftk-java"; repo = "pdftk"; - rev = "v${finalAttrs.version}"; + tag = "v${finalAttrs.version}"; hash = "sha256-ciKotTHSEcITfQYKFZ6sY2LZnXGChBJy0+eno8B3YHY="; }; - nativeBuildInputs = [ gradle ]; + nativeBuildInputs = [ gradle makeWrapper ]; # if the package has dependencies, mitmCache must be set mitmCache = gradle.fetchDeps { @@ -44,7 +44,7 @@ stdenv.mkDerivation (finalAttrs: { mkdir -p $out/{bin,share/pdftk} cp build/libs/pdftk-all.jar $out/share/pdftk - makeWrapper ${jre}/bin/java $out/bin/pdftk \ + makeWrapper ${lib.getExe jre} $out/bin/pdftk \ --add-flags "-jar $out/share/pdftk/pdftk-all.jar" cp ${finalAttrs.src}/pdftk.1 $out/share/man/man1 @@ -74,6 +74,7 @@ package. Using the pdftk example above: ```nix { lib , stdenv +, gradle # ... , pdftk }: @@ -87,30 +88,22 @@ stdenv.mkDerivation (finalAttrs: { }) ``` -This allows you to `override` any arguments of the `pkg` used for -the update script (for example, `pkg = pdftk.override { enableSomeFlag = -true };`), so this is the preferred way. +This allows you to `override` any arguments of the `pkg` used for the update script (for example, `pkg = pdftk.override { enableSomeFlag = true };)`. -The second is to create a `let` binding for the package, like this: +The second is to use `finalAttrs.finalPackage` like this: ```nix -let self = stdenv.mkDerivation { +stdenv.mkDerivation (finalAttrs: { # ... mitmCache = gradle.fetchDeps { - pkg = self; + pkg = finalAttrs.finalPackage; data = ./deps.json; }; -}; in self +}) ``` +The limitation of this method is that you cannot override the `pkg` derivations's arguments. -This is useful if you can't easily pass the derivation as its own -argument, or if your `mkDerivation` call is responsible for building -multiple packages. - -In the former case, the update script will stay the same even if the -derivation is called with different arguments. In the latter case, the -update script will change depending on the derivation arguments. It's up -to you to decide which one would work best for your derivation. +In the former case, the update script will stay the same even if the derivation is called with different arguments. In the latter case, the update script will change depending on the derivation arguments. It's up to you to decide which one would work best for your derivation. ## Update Script {#gradle-update-script}