summary refs log tree commit diff
path: root/pkgs/development/tools/database
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2016-12-16 12:19:59 +0100
committerFranz Pletz <fpletz@fnordicwalking.de>2016-12-16 12:19:59 +0100
commit52c34f626ca54b8d664dbba925bd5cfc959f9dc7 (patch)
treefb625b0e695babfe65a514d26f5a793129b5c934 /pkgs/development/tools/database
parent3fc60ec351d660caa43c456b84ef41ce0156d1c9 (diff)
downloadnixlib-52c34f626ca54b8d664dbba925bd5cfc959f9dc7.tar
nixlib-52c34f626ca54b8d664dbba925bd5cfc959f9dc7.tar.gz
nixlib-52c34f626ca54b8d664dbba925bd5cfc959f9dc7.tar.bz2
nixlib-52c34f626ca54b8d664dbba925bd5cfc959f9dc7.tar.lz
nixlib-52c34f626ca54b8d664dbba925bd5cfc959f9dc7.tar.xz
nixlib-52c34f626ca54b8d664dbba925bd5cfc959f9dc7.tar.zst
nixlib-52c34f626ca54b8d664dbba925bd5cfc959f9dc7.zip
liquibase: improve external jar integration (#20818)
This replaces the upstream wrapper script with one tailored for nixpkgs.
We gain the ability to selectively enable/disable jdbc backends.
Diffstat (limited to 'pkgs/development/tools/database')
-rw-r--r--pkgs/development/tools/database/liquibase/default.nix45
1 files changed, 37 insertions, 8 deletions
diff --git a/pkgs/development/tools/database/liquibase/default.nix b/pkgs/development/tools/database/liquibase/default.nix
index 5305297a27af..b49719ae0b96 100644
--- a/pkgs/development/tools/database/liquibase/default.nix
+++ b/pkgs/development/tools/database/liquibase/default.nix
@@ -1,4 +1,13 @@
-{ stdenv, fetchurl, jre, makeWrapper }:
+{ stdenv, fetchurl, writeText, jre, makeWrapper, fetchMavenArtifact
+, mysqlSupport ? true, mysql_jdbc ? null }:
+
+assert mysqlSupport -> mysql_jdbc != null;
+
+with stdenv.lib;
+let
+  extraJars = optional mysqlSupport mysql_jdbc;
+
+in
 
 stdenv.mkDerivation rec {
   name = "${pname}-${version}";
@@ -16,18 +25,38 @@ stdenv.mkDerivation rec {
     tar xfz ${src}
   '';
 
-  installPhase = ''
-    mkdir -p $out/{bin,lib,sdk}
-    mv ./* $out/
-    wrapProgram $out/liquibase --prefix PATH ":" ${jre}/bin --set LIQUIBASE_HOME $out;
-    ln -s $out/liquibase $out/bin/liquibase
+  installPhase =
+    let addJars = dir: ''
+      for jar in ${dir}/*.jar; do
+        CP="\$CP":"\$jar"
+      done
+    '';
+    in ''
+      mkdir -p $out/{bin,lib,sdk}
+      mv ./* $out/
+
+      # we provide our own script
+      rm $out/liquibase
+
+      # there’s a lot of escaping, but I’m not sure how to improve that
+      cat > $out/bin/liquibase <<EOF
+      #!/usr/bin/env bash
+      # taken from the executable script in the source
+      CP="$out/liquibase.jar"
+      ${addJars "$out/lib"}
+      ${concatStringsSep "\n" (map (p: addJars "${p}/share/java") extraJars)}
+
+      ${getBin jre}/bin/java -cp "\$CP" \$JAVA_OPTS \
+        liquibase.integration.commandline.Main \''${1+"\$@"}
+      EOF
+      chmod +x $out/bin/liquibase
   '';
 
-  meta = with stdenv.lib; {
+  meta = {
     description = "Version Control for your database";
     homepage = "http://www.liquibase.org/";
     license = licenses.asl20;
-    maintainers = with maintainers; [ nequissimus ];
+    maintainers = with maintainers; [ nequissimus profpatsch ];
     platforms = with platforms; unix;
   };
 }