-
Notifications
You must be signed in to change notification settings - Fork 0
/
comby.nix
70 lines (62 loc) · 2.11 KB
/
comby.nix
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
# You probably want to install this with something like:
#
# `nix-env -f 'https://github.com/virusdave/nixpkgs/tarball/master' -iA '(import comby.nix) pkgs' `
#
# or similar...
{ stdenv, fetchurl, pcre, pkgconfig, autoPatchelfHook /*, fixDarwinDylibNames*/
, ...
}:
let
platform_specifics = if (stdenv.isDarwin) then {
platform = "macos";
sha256 = "0542jv54ia1zlhxhb0lcnifvkiw75xhi43jp0ijl7xybf59zs2cv";
} else {
platform = "linux";
sha256 = "0gr5n0r1rri39xmivp19pi9msy1vv2pd83jwckwzjzx3p6r27a7h";
};
sha256 = platform_specifics.sha256;
platform = platform_specifics.platform;
in
with stdenv;
stdenv.mkDerivation rec {
pname = "comby";
version = "0.8.0";
src = fetchurl {
url = "https://github.com/comby-tools/comby/releases/download/${version}/comby-${version}-x86_64-${platform}.tar.gz";
sha256 = sha256;
};
# The tarball is just the prebuilt binary, in the archive root.
sourceRoot = ".";
dontBuild = true;
dontConfigure = true;
nativeBuildInputs =
lib.optionals (!stdenv.isDarwin) [autoPatchelfHook] ++
lib.optionals stdenv.isDarwin [/*fixDarwinDylibNames*/];
BuildInputs = [ pcre.out pkgconfig ];
binary = "comby-${version}-x86_64-${platform}";
binary_out = "comby";
installPhase = ''
#echo INSTALLING.
mkdir -p $out/bin
mkdir -p $out/lib
cp -r ${pcre.out}/lib/* $out/lib
mv ${binary} $out/bin/${binary_out}
#ls -la $out/bin
#echo INSTALLING DONE.
'';
# Comby binary has libpcre location hardcoded. Yuck.
# Fix that by pointing it to the pcre dependency.
postFixup = stdenv.lib.optionalString stdenv.isDarwin ''
for f in $out/lib/*.dylib; do
install_name_tool -id $out/lib/$(basename $f) $f || true
done
/Library/Developer/CommandLineTools/usr/bin/install_name_tool -change /usr/local/opt/pcre/lib/libpcre.1.dylib $out/lib/libpcre.1.dylib $out/bin/${binary_out}
'';
meta = with lib; {
description = "A tool for changing code across many languages";
homepage = https://comby.dev/;
license = licenses.gpl;
maintainers = [ maintainers.virusdave ];
platforms = [ "x86_64-darwin" "x86_64-linux" ];
};
}