diff --git a/pkgs/tools/graphics/zxing/default.nix b/pkgs/tools/graphics/zxing/default.nix new file mode 100644 index 000000000000..6834150f4775 --- /dev/null +++ b/pkgs/tools/graphics/zxing/default.nix @@ -0,0 +1,34 @@ +{stdenv, fetchurl, openjre, jre ? openjre}: +stdenv.mkDerivation rec { + name = "zxing-${version}"; + version = "3.1.0"; + # Maven builds are hard to get right + core_jar = fetchurl { + url = "http://repo1.maven.org/maven2/com/google/zxing/core/${version}/core-${version}.jar"; + sha256 = "199l4xvlcpafqn69r3k9qjpqkw9lvkl02hzpm0ackvdhl7vk42zh"; + }; + javase_jar = fetchurl { + url = "http://repo1.maven.org/maven2/com/google/zxing/javase/${version}/javase-${version}.jar"; + sha256 = "0fzxvvf5dqyrs5m9rqw4ffm9h1s27bi7q3jb1dam34s80q2rp2zq"; + }; + inherit jre; + unpackPhase = ''true''; + installPhase = '' + mkdir -p "$out/lib/java" "$out/bin" + cp "${core_jar}" "${javase_jar}" "$out/lib/java" + substituteAll "${./java-zxing.sh}" "$out/bin/java-zxing" + substituteAll "${./zxing-cmdline-runner.sh}" "$out/bin/zxing-cmdline-runner" + substituteAll "${./zxing-cmdline-encoder.sh}" "$out/bin/zxing-cmdline-encoder" + substituteAll "${./zxing.sh}" "$out/bin/zxing" + chmod a+x "$out/bin"/* + cd "$out/lib/java"; for i in *.jar; do mv "$i" "''${i#*-}"; done + ''; + meta = { + inherit version; + description = ''1D and 2D code reading library''; + license = stdenv.lib.licenses.asl20; + maintainers = [stdenv.lib.maintainers.raskin]; + platforms = stdenv.lib.platforms.linux; + homepage = "https://github.com/zxing/zxing"; + }; +} diff --git a/pkgs/tools/graphics/zxing/java-zxing.sh b/pkgs/tools/graphics/zxing/java-zxing.sh new file mode 100644 index 000000000000..bee3ac9e27a6 --- /dev/null +++ b/pkgs/tools/graphics/zxing/java-zxing.sh @@ -0,0 +1,3 @@ +#! /bin/sh + +@jre@/bin/java -cp @out@/lib/java/core-@version@.jar:@out@/lib/java/javase-@version@.jar "$@" diff --git a/pkgs/tools/graphics/zxing/zxing-cmdline-encoder.sh b/pkgs/tools/graphics/zxing/zxing-cmdline-encoder.sh new file mode 100644 index 000000000000..a17ba49cecf0 --- /dev/null +++ b/pkgs/tools/graphics/zxing/zxing-cmdline-encoder.sh @@ -0,0 +1,3 @@ +#! /bin/sh + +java-zxing com.google.zxing.client.j2se.CommandLineEncoder "$@" diff --git a/pkgs/tools/graphics/zxing/zxing-cmdline-runner.sh b/pkgs/tools/graphics/zxing/zxing-cmdline-runner.sh new file mode 100644 index 000000000000..cb2a25dc03f7 --- /dev/null +++ b/pkgs/tools/graphics/zxing/zxing-cmdline-runner.sh @@ -0,0 +1,3 @@ +#! /bin/sh + +java-zxing com.google.zxing.client.j2se.CommandLineRunner "$@" diff --git a/pkgs/tools/graphics/zxing/zxing.sh b/pkgs/tools/graphics/zxing/zxing.sh new file mode 100644 index 000000000000..1d473236e945 --- /dev/null +++ b/pkgs/tools/graphics/zxing/zxing.sh @@ -0,0 +1,11 @@ +#! /bin/sh +choice="$1"; +shift +case "$choice" in + encode | create | write | CommandLineEncoder) + zxing-cmdline-encoder "$@"; + ;; + decode | read | run | CommandLineRunner) + zxing-cmdline-runner "$@"; + ;; +esac diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1701881ebaff..912decd2afc7 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2855,6 +2855,8 @@ let zsync = callPackage ../tools/compression/zsync { }; + zxing = callPackage ../tools/graphics/zxing {}; + ### SHELLS