3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/applications/misc/dbeaver/default.nix

166 lines
4.5 KiB
Nix
Raw Normal View History

2021-01-04 10:26:50 +00:00
{ lib
, stdenv
2021-03-21 21:31:11 +00:00
, copyDesktopItems
2021-01-04 10:26:50 +00:00
, fetchFromGitHub
2021-04-18 20:32:13 +01:00
, fetchpatch
2021-01-04 10:26:50 +00:00
, makeDesktopItem
, makeWrapper
, fontconfig
, freetype
, glib
, gtk3
, jdk
, libX11
, libXrender
, libXtst
, zlib
, maven
}:
2021-03-21 21:31:11 +00:00
2021-01-04 10:26:50 +00:00
stdenv.mkDerivation rec {
pname = "dbeaver-ce";
2021-04-18 20:32:13 +01:00
version = "21.0.3"; # When updating also update fetchedMavenDeps.sha256
2021-01-04 10:26:50 +00:00
src = fetchFromGitHub {
owner = "dbeaver";
repo = "dbeaver";
rev = version;
2021-04-18 20:32:13 +01:00
sha256 = "sha256-ItM8t+gqE0ccuuimfEMUddykl+xt2eZIBd3MbpreRwA=";
2021-01-04 10:26:50 +00:00
};
fetchedMavenDeps = stdenv.mkDerivation {
name = "dbeaver-${version}-maven-deps";
2021-04-18 20:32:13 +01:00
inherit src patches;
2021-01-04 10:26:50 +00:00
buildInputs = [
maven
];
2021-02-28 19:41:44 +00:00
buildPhase = "mvn package -Dmaven.repo.local=$out/.m2 -P desktop,all-platforms";
2021-01-04 10:26:50 +00:00
# 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";
2021-04-18 20:32:13 +01:00
outputHash = "sha256-rsK/B39ogNu5nC41OfyAsLiwBz4gWyH+8Fj7E6+rOng=";
2021-01-04 10:26:50 +00:00
};
2018-01-08 23:22:32 +00:00
2021-04-18 20:32:13 +01:00
patches = [
# Fix eclipse-color-theme URL (https://github.com/dbeaver/dbeaver/pull/12133)
# After April 15, 2021 eclipse-color-theme.github.com no longer redirects to eclipse-color-theme.github.io
(fetchpatch {
url = "https://github.com/dbeaver/dbeaver/commit/65d65e2c2c711cc87fddcec425a6915aa80f4ced.patch";
sha256 = "sha256-pxOcRYkV/5o+tHcRhHDZ1TmZSHMnKBmkNTVAlIf9nUE=";
})
];
2021-03-21 21:31:11 +00:00
nativeBuildInputs = [
copyDesktopItems
makeWrapper
maven
];
2018-01-08 23:22:32 +00:00
buildInputs = [
2021-01-04 10:26:50 +00:00
fontconfig
freetype
glib
gtk3
jdk
libX11
libXrender
libXtst
zlib
2018-01-08 23:22:32 +00:00
];
2021-03-21 21:31:11 +00:00
desktopItems = [
(makeDesktopItem {
name = "dbeaver";
exec = "dbeaver";
icon = "dbeaver";
desktopName = "dbeaver";
comment = "SQL Integrated Development Environment";
genericName = "SQL Integrated Development Environment";
categories = "Development;";
})
2018-01-08 23:22:32 +00:00
];
2021-01-04 10:26:50 +00:00
buildPhase = ''
2021-02-28 19:41:44 +00:00
runHook preBuild
mvn package --offline -Dmaven.repo.local=$(cp -dpR ${fetchedMavenDeps}/.m2 ./ && chmod +w -R .m2 && pwd)/.m2 -P desktop,all-platforms
runHook postBuild
2021-01-04 10:26:50 +00:00
'';
2020-12-21 16:09:57 +00:00
2021-01-04 10:26:50 +00:00
installPhase =
let
2021-03-21 21:31:11 +00:00
productTargetPath = "product/community/target/products/org.jkiss.dbeaver.core.product";
2021-02-28 19:41:44 +00:00
platformMap = {
aarch64-linux = "aarch64";
x86_64-darwin = "x86_64";
x86_64-linux = "x86_64";
};
systemPlatform = platformMap.${stdenv.hostPlatform.system} or (throw "dbeaver not supported on ${stdenv.hostPlatform.system}");
2021-01-04 10:26:50 +00:00
in
2021-01-04 18:27:48 +00:00
if stdenv.isDarwin then ''
2021-02-28 19:41:44 +00:00
runHook preInstall
2021-01-04 18:27:48 +00:00
mkdir -p $out/Applications $out/bin
2021-02-28 19:41:44 +00:00
cp -r ${productTargetPath}/macosx/cocoa/${systemPlatform}/DBeaver.app $out/Applications
2021-01-04 18:27:48 +00:00
sed -i "/^-vm/d; /bin\/java/d" $out/Applications/DBeaver.app/Contents/Eclipse/dbeaver.ini
ln -s $out/Applications/DBeaver.app/Contents/MacOS/dbeaver $out/bin/dbeaver
wrapProgram $out/Applications/DBeaver.app/Contents/MacOS/dbeaver \
--prefix JAVA_HOME : ${jdk.home} \
--prefix PATH : ${jdk}/bin
2021-02-28 19:41:44 +00:00
runHook postInstall
2021-01-04 18:27:48 +00:00
'' else ''
2021-02-28 19:41:44 +00:00
runHook preInstall
2021-01-04 10:26:50 +00:00
mkdir -p $out/
2021-02-28 19:41:44 +00:00
cp -r ${productTargetPath}/linux/gtk/${systemPlatform}/dbeaver $out/dbeaver
2018-01-08 23:22:32 +00:00
2021-01-04 10:26:50 +00:00
# Patch binaries.
interpreter=$(cat $NIX_CC/nix-support/dynamic-linker)
patchelf --set-interpreter $interpreter $out/dbeaver/dbeaver
2018-01-08 23:22:32 +00:00
2021-01-04 10:26:50 +00:00
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"
2018-01-08 23:22:32 +00:00
2021-01-04 10:26:50 +00:00
mkdir -p $out/share/pixmaps
ln -s $out/dbeaver/icon.xpm $out/share/pixmaps/dbeaver.xpm
2021-02-28 19:41:44 +00:00
runHook postInstall
2021-01-04 10:26:50 +00:00
'';
2018-01-08 23:22:32 +00:00
meta = with lib; {
2020-03-23 09:05:32 +00:00
homepage = "https://dbeaver.io/";
2018-01-08 23:22:32 +00:00
description = "Universal SQL Client for developers, DBA and analysts. Supports MySQL, PostgreSQL, MariaDB, SQLite, and more";
longDescription = ''
Free multi-platform database tool for developers, SQL programmers, database
administrators and analysts. Supports all popular databases: MySQL,
PostgreSQL, MariaDB, SQLite, Oracle, DB2, SQL Server, Sybase, MS Access,
Teradata, Firebird, Derby, etc.
'';
license = licenses.asl20;
2021-02-28 19:41:44 +00:00
platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" ];
2021-01-04 10:26:50 +00:00
maintainers = with maintainers; [ jojosch ];
2018-01-08 23:22:32 +00:00
};
}