about summary refs log tree commit diff
path: root/pkgs/development/interpreters/clojure/obb.nix
blob: adb7a926173966ad6adf1bb74b015eb4cd59c1d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{ lib
, stdenv
, fetchurl
, babashka
, cacert
, clojure
, git
, jdk
, obb
, fetchFromGitHub
, makeWrapper
, runCommand }:

stdenv.mkDerivation rec {
  pname = "obb";
  version = "0.0.2";

  src = fetchFromGitHub {
    owner = "babashka";
    repo = pname;
    rev = "v${version}";
    sha256 = "1Gxh4IMtytQCuPS+BWOc5AgjEBxa43ebYfDsxLSPeY0=";
  };

  nativeBuildInputs = [ makeWrapper ];

  buildInputs = [ babashka cacert git jdk ];

  configurePhase = ''
    runHook preConfigure

    mkdir -p .m2
    substituteInPlace deps.edn --replace ':paths' ':mvn/local-repo "./.m2" :paths'
    substituteInPlace bb.edn --replace ':paths' ':mvn/local-repo "./.m2" :paths'
    echo deps.edn

    runHook postConfigure
  '';

  buildPhase = ''
    runHook preBuild

    export DEPS_CLJ_TOOLS_DIR=${clojure}
    export DEPS_CLJ_TOOLS_VERSION=${clojure.version}
    mkdir -p .gitlibs
    mkdir -p .cpcache
    export GITLIBS=.gitlibs
    export CLJ_CACHE=.cpcache

    bb build

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    ln -s /usr/bin/osascript $out/bin/osascript

    install -Dm755 "out/bin/obb" "$out/bin/obb"
    wrapProgram $out/bin/obb --prefix PATH : $out/bin

    runHook postInstall
  '';

  passthru.tests = {
    simple = runCommand "${pname}-test" {} ''
      [ $(${obb}/bin/obb -e '(+ 1 2)') = '3' ]
      touch $out
    '';
  };

  meta = with lib; {
    description = "Ad-hoc ClojureScript scripting of Mac applications via Apple's Open Scripting Architecture";
    homepage = "https://github.com/babashka/obb";
    license = licenses.epl10;
    maintainers = with maintainers; [
      willcohen
    ];
    platforms = platforms.darwin;
  };
}