1{
2 lib,
3 stdenv,
4 babashka,
5 cacert,
6 clojure,
7 git,
8 jdk,
9 obb,
10 fetchFromGitHub,
11 makeWrapper,
12 runCommand,
13}:
14
15stdenv.mkDerivation rec {
16 pname = "obb";
17 version = "0.0.2";
18
19 src = fetchFromGitHub {
20 owner = "babashka";
21 repo = "obb";
22 rev = "v${version}";
23 sha256 = "1Gxh4IMtytQCuPS+BWOc5AgjEBxa43ebYfDsxLSPeY0=";
24 };
25
26 nativeBuildInputs = [ makeWrapper ];
27
28 buildInputs = [
29 babashka
30 cacert
31 git
32 jdk
33 ];
34
35 configurePhase = ''
36 runHook preConfigure
37
38 mkdir -p .m2
39 substituteInPlace deps.edn --replace ':paths' ':mvn/local-repo "./.m2" :paths'
40 substituteInPlace bb.edn --replace ':paths' ':mvn/local-repo "./.m2" :paths'
41 echo deps.edn
42
43 runHook postConfigure
44 '';
45
46 buildPhase = ''
47 runHook preBuild
48
49 export DEPS_CLJ_TOOLS_DIR=${clojure}
50 export DEPS_CLJ_TOOLS_VERSION=${clojure.version}
51 mkdir -p .gitlibs
52 mkdir -p .cpcache
53 export GITLIBS=.gitlibs
54 export CLJ_CACHE=.cpcache
55
56 bb build
57
58 runHook postBuild
59 '';
60
61 installPhase = ''
62 runHook preInstall
63
64 mkdir -p $out/bin
65 ln -s /usr/bin/osascript $out/bin/osascript
66
67 install -Dm755 "out/bin/obb" "$out/bin/obb"
68 wrapProgram $out/bin/obb --prefix PATH : $out/bin
69
70 runHook postInstall
71 '';
72
73 passthru.tests = {
74 simple = runCommand "obb-test" { } ''
75 [ $(${obb}/bin/obb -e '(+ 1 2)') = '3' ]
76 touch $out
77 '';
78 };
79
80 meta = with lib; {
81 description = "Ad-hoc ClojureScript scripting of Mac applications via Apple's Open Scripting Architecture";
82 homepage = "https://github.com/babashka/obb";
83 license = licenses.epl10;
84 maintainers = with maintainers; [
85 willcohen
86 ];
87 platforms = platforms.darwin;
88
89 # https://hydra.nixos.org/job/nixpkgs/trunk/obb.aarch64-darwin/all
90 broken = true;
91 };
92}