Use lib.makeScope for consistent package resolution

This commit is contained in:
Tad Fisher
2024-06-16 12:22:38 -07:00
committed by Tad Fisher
parent 6e37e6e3f9
commit 0160c945b8
7 changed files with 96 additions and 98 deletions

View File

@@ -1,28 +1,6 @@
# This file is generated by gradle2nix.
#
# Example usage (e.g. in default.nix):
#
# with (import <nixpkgs> {});
# let
# buildGradle = callPackage ./gradle.nix {};
# in
# buildGradle {
# lockFile = ./gradle.lock;
#
# src = ./.;
#
# gradleFlags = [ "installDist" ];
#
# installPhase = ''
# mkdir -p $out
# cp -r app/build/install/myproject $out
# '';
# }
{
lib,
stdenv,
gradle,
buildMavenRepo,
gradleSetupHook,
writeText,
@@ -31,10 +9,8 @@
{
# Path to the lockfile generated by gradle2nix (e.g. gradle.lock).
lockFile ? null,
pname ? "project",
version ? null,
# The Gradle package to use. Default is 'pkgs.gradle'.
gradlePackage ? gradle,
gradle ? null,
# Override the default JDK used to run Gradle itself.
buildJdk ? null,
# Override functions which fetch dependency artifacts.
@@ -105,24 +81,25 @@
let
inherit (builtins) removeAttrs;
gradleSetupHook' = gradleSetupHook.overrideAttrs (_: {
propagatedBuildInputs = [ gradlePackage ];
});
offlineRepo =
if lockFile != null then buildMavenRepo { inherit lockFile fetchers overrides; } else null;
buildGradlePackage = stdenv.mkDerivation (
finalAttrs:
{
inherit buildJdk pname version;
inherit buildJdk gradle;
inherit (offlineRepo) gradleInitScript;
dontStrip = true;
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ gradleSetupHook' ];
gradleSetupHook =
if (finalAttrs.gradle != null) then
gradleSetupHook.override { inherit (finalAttrs) gradle; }
else
gradleSetupHook;
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ finalAttrs.gradleSetupHook ];
gradleFlags =
[ "--console=plain" ]
@@ -137,7 +114,7 @@ let
"lockFile"
"fetchers"
"nativeBuildInputs"
"overlays"
"overrides"
"passthru"
]
);