nixpkgs/pkgs/by-name/ap/apksigner/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

67 lines
1.9 KiB
Nix

{ lib
, stdenv
, fetchgit
, jdk_headless
, gradle
, makeWrapper
}:
stdenv.mkDerivation rec {
pname = "apksigner";
version = "34.0.5-unstable-2024-03-06";
src = fetchgit {
# use pname here because the final jar uses this as the filename
name = pname;
url = "https://android.googlesource.com/platform/tools/apksig";
rev = "ac5cbb07d87cc342fcf07715857a812305d69888";
hash = "sha256-sLAs7XEkhNkQjB/nhBODxI3QzxFvLWM1SBKDuXp6gvw=";
};
postPatch = ''
cat >> build.gradle <<EOF
apply plugin: 'application'
mainClassName = "com.android.apksigner.ApkSignerTool"
sourceSets.main.java.srcDirs = [ 'src/apksigner/java', 'src/main/java' ]
jar {
manifest { attributes "Main-Class": "com.android.apksigner.ApkSignerTool" }
from { (configurations.runtimeClasspath).collect { it.isDirectory() ? it : zipTree(it) } } {
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/native/*.dll'
}
from('src/apksigner/java') {
include 'com/android/apksigner/*.txt'
}
}
tasks.named("processTestResources") { dependsOn("extractTestProto") }
EOF
sed -i -e '/conscrypt/s/testImplementation/implementation/' build.gradle
'';
mitmCache = gradle.fetchDeps {
inherit pname;
data = ./deps.json;
};
__darwinAllowLocalNetworking = true;
doCheck = true;
nativeBuildInputs = [ gradle makeWrapper ];
installPhase = ''
install -Dm444 build/libs/apksigner.jar -t $out/lib
makeWrapper "${jdk_headless}/bin/java" "$out/bin/apksigner" \
--add-flags "-jar $out/lib/apksigner.jar"
'';
meta = with lib; {
description = "Command line tool to sign and verify Android APKs";
mainProgram = "apksigner";
homepage = "https://developer.android.com/studio/command-line/apksigner";
license = licenses.asl20;
maintainers = with maintainers; [ linsui ];
platforms = platforms.unix;
};
}