mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-22 06:05:13 +00:00
4a7f99d55d
Part of: https://github.com/NixOS/nixpkgs/issues/108938 meta = with stdenv.lib; is a widely used pattern. We want to slowly remove the `stdenv.lib` indirection and encourage people to use `lib` directly. Thus let’s start with the meta field. This used a rewriting script to mostly automatically replace all occurances of this pattern, and add the `lib` argument to the package header if it doesn’t exist yet. The script in its current form is available at https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
95 lines
3.2 KiB
Nix
95 lines
3.2 KiB
Nix
{ lib, stdenv, fetchFromGitHub, gradle, perl, jre, makeWrapper, makeDesktopItem, mplayer }:
|
|
|
|
let
|
|
version = "6.6.7-build-529";
|
|
name = "frostwire-desktop-${version}";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "frostwire";
|
|
repo = "frostwire";
|
|
rev = name;
|
|
sha256 = "03wdj2kr8akzx8m1scvg98132zbaxh81qjdsxn2645b3gahjwz0m";
|
|
};
|
|
|
|
desktopItem = makeDesktopItem {
|
|
name = "frostwire";
|
|
desktopName = "FrostWire";
|
|
genericName = "P2P Bittorrent client";
|
|
exec = "frostwire";
|
|
icon = "frostwire";
|
|
comment = "Search and explore all kinds of files on the Bittorrent network";
|
|
categories = "Network;FileTransfer;P2P;";
|
|
};
|
|
|
|
# fake build to pre-download deps into fixed-output derivation
|
|
deps = stdenv.mkDerivation {
|
|
name = "${name}-deps";
|
|
inherit src;
|
|
buildInputs = [ gradle perl ];
|
|
buildPhase = ''
|
|
export GRADLE_USER_HOME=$(mktemp -d)
|
|
( cd desktop
|
|
gradle --no-daemon build
|
|
)
|
|
'';
|
|
# perl code mavenizes pathes (com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar -> com/squareup/okio/okio/1.13.0/okio-1.13.0.jar)
|
|
installPhase = ''
|
|
find $GRADLE_USER_HOME -type f -regex '.*\.\(jar\|pom\)' \
|
|
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \
|
|
| sh
|
|
'';
|
|
outputHashAlgo = "sha256";
|
|
outputHashMode = "recursive";
|
|
outputHash = "11zd98g0d0fdgls4lsskkagwfxyh26spfd6c6g9cahl89czvlg3c";
|
|
};
|
|
|
|
in stdenv.mkDerivation {
|
|
inherit name src;
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
buildInputs = [ gradle ];
|
|
|
|
buildPhase = ''
|
|
export GRADLE_USER_HOME=$(mktemp -d)
|
|
( cd desktop
|
|
|
|
# disable auto-update (anyway it won't update frostwire installed in nix store)
|
|
substituteInPlace src/com/frostwire/gui/updates/UpdateManager.java \
|
|
--replace 'um.checkForUpdates' '// um.checkForUpdates'
|
|
|
|
# fix path to mplayer
|
|
substituteInPlace src/com/frostwire/gui/player/MediaPlayerLinux.java \
|
|
--replace /usr/bin/mplayer ${mplayer}/bin/mplayer
|
|
|
|
substituteInPlace build.gradle \
|
|
--replace 'mavenCentral()' 'mavenLocal(); maven { url uri("${deps}") }'
|
|
gradle --offline --no-daemon build
|
|
)
|
|
'';
|
|
|
|
installPhase = ''
|
|
mkdir -p $out/lib $out/share/java
|
|
|
|
cp desktop/build/libs/frostwire.jar $out/share/java/frostwire.jar
|
|
|
|
cp ${ { x86_64-darwin = "desktop/lib/native/*.dylib";
|
|
x86_64-linux = "desktop/lib/native/lib{jlibtorrent,SystemUtilities}.so";
|
|
i686-linux = "desktop/lib/native/lib{jlibtorrent,SystemUtilities}X86.so";
|
|
}.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}")
|
|
} $out/lib
|
|
|
|
cp -dpR ${desktopItem}/share $out
|
|
|
|
makeWrapper ${jre}/bin/java $out/bin/frostwire \
|
|
--add-flags "-Djava.library.path=$out/lib -jar $out/share/java/frostwire.jar"
|
|
'';
|
|
|
|
meta = with lib; {
|
|
homepage = "https://www.frostwire.com/";
|
|
description = "BitTorrent Client and Cloud File Downloader";
|
|
license = licenses.gpl2;
|
|
maintainers = with maintainers; [ gavin ];
|
|
platforms = [ "x86_64-darwin" "x86_64-linux" "i686-linux" ];
|
|
};
|
|
}
|