1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-22 21:50:55 +00:00

dbeaver: build from source

This commit is contained in:
Johannes Schleifenbaum 2021-01-04 11:26:50 +01:00
parent c28984592c
commit 4fc999db62
No known key found for this signature in database
GPG key ID: 059093B1A278BCD0
2 changed files with 100 additions and 43 deletions

View file

@ -1,14 +1,20 @@
{ lib, stdenv, fetchurl, makeDesktopItem, makeWrapper
, fontconfig, freetype, glib, gtk3
, jdk, libX11, libXrender, libXtst, zlib }:
# The build process is almost like eclipse's.
# See `pkgs/applications/editors/eclipse/*.nix`
stdenv.mkDerivation rec {
pname = "dbeaver-ce";
version = "7.3.2";
{ lib
, stdenv
, fetchFromGitHub
, makeDesktopItem
, makeWrapper
, fontconfig
, freetype
, glib
, gtk3
, jdk
, libX11
, libXrender
, libXtst
, zlib
, maven
}:
let
desktopItem = makeDesktopItem {
name = "dbeaver";
exec = "dbeaver";
@ -18,45 +24,90 @@ stdenv.mkDerivation rec {
genericName = "SQL Integrated Development Environment";
categories = "Development;";
};
in
stdenv.mkDerivation rec {
pname = "dbeaver-ce";
version = "7.3.2"; # When updating also update fetchedMavenDeps.sha256
src = fetchFromGitHub {
owner = "dbeaver";
repo = "dbeaver";
rev = version;
sha256 = "sha256-gh3++IEQzWOKGsazqeMp0aHuZ835etAou62cgz0GoNQ=";
};
fetchedMavenDeps = stdenv.mkDerivation {
name = "dbeaver-${version}-maven-deps";
inherit src;
buildInputs = [
maven
];
buildPhase = "mvn package -Dmaven.repo.local=$out/.m2";
# keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
installPhase = ''
find $out -type f \
-name \*.lastUpdated -or \
-name resolver-status.properties -or \
-name _remote.repositories \
-delete
'';
# don't do any fixup
dontFixup = true;
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = "sha256-uTKevwZvKiYOBz0hshh1rLEj7htYF7FQiTq6vZiVs7Q=";
};
buildInputs = [
fontconfig freetype glib gtk3
jdk libX11 libXrender libXtst zlib
fontconfig
freetype
glib
gtk3
jdk
libX11
libXrender
libXtst
makeWrapper
zlib
];
nativeBuildInputs = [
makeWrapper
maven
];
src = fetchurl {
url = "https://dbeaver.io/files/${version}/dbeaver-ce-${version}-linux.gtk.x86_64.tar.gz";
sha256 = "sha256-4BVXcR8/E4uIrPQJe9KU9577j4XLTxJWTO8g0vCHWts=";
};
installPhase = ''
# remove bundled jre
rm -rf jre
mkdir -p $out/
cp -r . $out/dbeaver
# Patch binaries.
interpreter=$(cat $NIX_CC/nix-support/dynamic-linker)
patchelf --set-interpreter $interpreter $out/dbeaver/dbeaver
makeWrapper $out/dbeaver/dbeaver $out/bin/dbeaver \
--prefix PATH : ${jdk}/bin \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath ([ glib gtk3 libXtst ])} \
--prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH"
# Create desktop item.
mkdir -p $out/share/applications
cp ${desktopItem}/share/applications/* $out/share/applications
mkdir -p $out/share/pixmaps
ln -s $out/dbeaver/icon.xpm $out/share/pixmaps/dbeaver.xpm
buildPhase = ''
mvn package --offline -Dmaven.repo.local=$(cp -dpR ${fetchedMavenDeps}/.m2 ./ && chmod +w -R .m2 && pwd)/.m2
'';
installPhase =
let
productTargetPath = "product/standalone/target/products/org.jkiss.dbeaver.core.product";
in
''
mkdir -p $out/
cp -r ${productTargetPath}/linux/gtk/x86_64/dbeaver $out/dbeaver
# Patch binaries.
interpreter=$(cat $NIX_CC/nix-support/dynamic-linker)
patchelf --set-interpreter $interpreter $out/dbeaver/dbeaver
makeWrapper $out/dbeaver/dbeaver $out/bin/dbeaver \
--prefix PATH : ${jdk}/bin \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath ([ glib gtk3 libXtst ])} \
--prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH"
# Create desktop item.
mkdir -p $out/share/applications
cp ${desktopItem}/share/applications/* $out/share/applications
mkdir -p $out/share/pixmaps
ln -s $out/dbeaver/icon.xpm $out/share/pixmaps/dbeaver.xpm
'';
meta = with lib; {
homepage = "https://dbeaver.io/";
description = "Universal SQL Client for developers, DBA and analysts. Supports MySQL, PostgreSQL, MariaDB, SQLite, and more";
@ -68,6 +119,6 @@ stdenv.mkDerivation rec {
'';
license = licenses.asl20;
platforms = [ "x86_64-linux" ];
maintainers = [ maintainers.jojosch ];
maintainers = with maintainers; [ jojosch ];
};
}

View file

@ -3479,7 +3479,13 @@ in
davfs2 = callPackage ../tools/filesystems/davfs2 { };
dbeaver = callPackage ../applications/misc/dbeaver { };
dbeaver = callPackage ../applications/misc/dbeaver {
# TODO: remove once maven uses JDK 11
# error: org/eclipse/tycho/core/p2/P2ArtifactRepositoryLayout has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
maven = maven.override {
jdk = jdk11;
};
};
dbench = callPackage ../development/tools/misc/dbench { };