Merge pull request #233 from anthonyroussel/maven

Add support for updating buildMavenPackage's mvnHash
This commit is contained in:
Jörg Thalheim 2024-03-18 08:34:45 +01:00 committed by GitHub
commit c20ec18496
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 55 additions and 0 deletions

View File

@ -20,6 +20,7 @@ designed to work with nixpkgs but also other package sets.
- update buildGoModule's vendorHash/vendorSha256 - update buildGoModule's vendorHash/vendorSha256
- update buildNpmPackage's npmDepsHash and npmConfigHook's npmDeps - update buildNpmPackage's npmDepsHash and npmConfigHook's npmDeps
- update buildComposerProject's vendorHash - update buildComposerProject's vendorHash
- update buildMavenPackage's mvnHash
- update fetchYarnDeps offlineCache output hash - update fetchYarnDeps offlineCache output hash
- update flake outputs (see `--flake`) - update flake outputs (see `--flake`)
- build and run the resulting package (see `--build`, - build and run the resulting package (see `--build`,

View File

@ -56,6 +56,7 @@ class Package:
npm_deps: str | None npm_deps: str | None
yarn_deps: str | None yarn_deps: str | None
composer_deps: str | None composer_deps: str | None
maven_deps: str | None
tests: list[str] tests: list[str]
has_update_script: bool has_update_script: bool
@ -162,6 +163,7 @@ in {{
composer_deps = pkg.composerRepository.outputHash or null; composer_deps = pkg.composerRepository.outputHash or null;
npm_deps = pkg.npmDeps.outputHash or null; npm_deps = pkg.npmDeps.outputHash or null;
yarn_deps = pkg.offlineCache.outputHash or null; yarn_deps = pkg.offlineCache.outputHash or null;
maven_deps = pkg.fetchedMavenDeps.outputHash or null;
tests = builtins.attrNames (pkg.passthru.tests or {{}}); tests = builtins.attrNames (pkg.passthru.tests or {{}});
has_update_script = {has_update_script}; has_update_script = {has_update_script};
src_homepage = pkg.src.meta.homepage or null; src_homepage = pkg.src.meta.homepage or null;

View File

@ -271,6 +271,11 @@ def update_yarn_deps_hash(opts: Options, filename: str, current_hash: str) -> No
replace_hash(filename, current_hash, target_hash) replace_hash(filename, current_hash, target_hash)
def update_maven_deps_hash(opts: Options, filename: str, current_hash: str) -> None:
target_hash = nix_prefetch(opts, "fetchedMavenDeps")
replace_hash(filename, current_hash, target_hash)
def update_version( def update_version(
package: Package, version: str, preference: VersionPreference, version_regex: str package: Package, version: str, preference: VersionPreference, version_regex: str
) -> bool: ) -> bool:
@ -385,4 +390,7 @@ def update(opts: Options) -> Package:
if package.yarn_deps: if package.yarn_deps:
update_yarn_deps_hash(opts, package.filename, package.yarn_deps) update_yarn_deps_hash(opts, package.filename, package.yarn_deps)
if package.maven_deps:
update_maven_deps_hash(opts, package.filename, package.maven_deps)
return package return package

27
tests/test_maven.py Normal file
View File

@ -0,0 +1,27 @@
import subprocess
import conftest
from nix_update.options import Options
from nix_update.update import update
def test_update(helpers: conftest.Helpers) -> None:
with helpers.testpkgs() as path:
opts = Options(attribute="maven", import_path=str(path))
update(opts)
version = subprocess.run(
[
"nix",
"eval",
"--raw",
"--extra-experimental-features",
"nix-command",
"-f",
path,
"maven.version",
],
text=True,
stdout=subprocess.PIPE,
).stdout.strip()
assert tuple(map(int, version.split("."))) > (3, 3, 0)

View File

@ -13,4 +13,5 @@
sourcehut = pkgs.python3.pkgs.callPackage ./sourcehut.nix { }; sourcehut = pkgs.python3.pkgs.callPackage ./sourcehut.nix { };
savanna = pkgs.python3.pkgs.callPackage ./savanna.nix { }; savanna = pkgs.python3.pkgs.callPackage ./savanna.nix { };
npm = pkgs.callPackage ./npm.nix { }; npm = pkgs.callPackage ./npm.nix { };
maven = pkgs.callPackage ./maven.nix { };
} }

16
tests/testpkgs/maven.nix Normal file
View File

@ -0,0 +1,16 @@
{ maven, fetchFromGitHub }:
maven.buildMavenPackage rec {
pname = "mariadb-connector-java";
version = "3.3.0";
src = fetchFromGitHub {
owner = "mariadb-corporation";
repo = "mariadb-connector-j";
rev = "refs/tags/${version}";
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
mvnHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
mvnParameters = "-DskipTests";
}