Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, stdenv 3, fetchurl 4, jre 5, makeWrapper 6, mysqlSupport ? true 7, mysql_jdbc 8, postgresqlSupport ? true 9, postgresql_jdbc 10, redshiftSupport ? true 11, redshift_jdbc 12, liquibase_redshift_extension 13}: 14 15let 16 extraJars = 17 lib.optional mysqlSupport mysql_jdbc 18 ++ lib.optional postgresqlSupport postgresql_jdbc 19 ++ lib.optionals redshiftSupport [ 20 redshift_jdbc 21 liquibase_redshift_extension 22 ]; 23in 24 25stdenv.mkDerivation rec { 26 pname = "liquibase"; 27 version = "4.9.0"; 28 29 src = fetchurl { 30 url = "https://github.com/liquibase/liquibase/releases/download/v${version}/${pname}-${version}.tar.gz"; 31 sha256 = "sha256-1InRJzHqikm6Jd7z54TW6JFn3FO0LtStehWNaC+rdw8="; 32 }; 33 34 nativeBuildInputs = [ makeWrapper ]; 35 buildInputs = [ jre ]; 36 37 unpackPhase = '' 38 tar xfz ${src} 39 ''; 40 41 installPhase = 42 let addJars = dir: '' 43 for jar in ${dir}/*.jar; do 44 CP="\$CP":"\$jar" 45 done 46 ''; 47 in 48 '' 49 mkdir -p $out 50 mv ./{lib,licenses,liquibase.jar} $out/ 51 52 mkdir -p $out/share/doc/${pname}-${version} 53 mv LICENSE.txt \ 54 README.txt \ 55 ABOUT.txt \ 56 changelog.txt \ 57 $out/share/doc/${pname}-${version} 58 59 mkdir -p $out/bin 60 # theres a lot of escaping, but Im not sure how to improve that 61 cat > $out/bin/liquibase <<EOF 62 #!/usr/bin/env bash 63 # taken from the executable script in the source 64 CP="$out/liquibase.jar" 65 ${addJars "$out/lib"} 66 ${lib.concatStringsSep "\n" (map (p: addJars "${p}/share/java") extraJars)} 67 68 ${lib.getBin jre}/bin/java -cp "\$CP" \$JAVA_OPTS \ 69 liquibase.integration.commandline.LiquibaseCommandLine \''${1+"\$@"} 70 EOF 71 chmod +x $out/bin/liquibase 72 ''; 73 74 meta = with lib; { 75 description = "Version Control for your database"; 76 homepage = "https://www.liquibase.org/"; 77 changelog = "https://raw.githubusercontent.com/liquibase/liquibase/v${version}/changelog.txt"; 78 sourceProvenance = with sourceTypes; [ binaryBytecode ]; 79 license = licenses.asl20; 80 maintainers = with maintainers; [ ]; 81 platforms = with platforms; unix; 82 }; 83}