1{
2 lib,
3 stdenv,
4 rustPlatform,
5 fetchFromGitHub,
6 autoconf,
7 automake,
8 bison,
9 ruby,
10 zlib,
11 readline,
12 libiconv,
13 libunwind,
14 libxcrypt,
15 libyaml,
16 rust-jemalloc-sys-unprefixed,
17}:
18
19rustPlatform.buildRustPackage rec {
20 pname = "rubyfmt";
21 version = "0.10.0";
22
23 src = fetchFromGitHub {
24 owner = "fables-tales";
25 repo = "rubyfmt";
26 rev = "v${version}";
27 hash = "sha256-IIHPU6iwFwQ5cOAtOULpMSjexFtTelSd/LGLuazdmUo=";
28 fetchSubmodules = true;
29 };
30
31 nativeBuildInputs = [
32 autoconf
33 automake
34 bison
35 ruby
36 ];
37
38 buildInputs = [
39 zlib
40 libxcrypt
41 libyaml
42 rust-jemalloc-sys-unprefixed
43 ]
44 ++ lib.optionals stdenv.hostPlatform.isDarwin [
45 readline
46 libiconv
47 libunwind
48 ];
49
50 preConfigure = ''
51 pushd librubyfmt/ruby_checkout
52 autoreconf --install --force --verbose
53 ./configure
54 popd
55 '';
56
57 cargoPatches = [
58 # Avoid checking whether ruby gitsubmodule is up-to-date.
59 ./0002-remove-dependency-on-git.patch
60 # Avoid failing on unused variable warnings.
61 ./0003-ignore-warnings.patch
62 ];
63
64 cargoHash = "sha256-8LgAHznxU30bbK8ivNamVD3Yi2pljgpqJg2WC0nxftk=";
65
66 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-fdeclspec";
67
68 preFixup = ''
69 mv $out/bin/rubyfmt{-main,}
70 '';
71
72 meta = {
73 description = "Ruby autoformatter";
74 homepage = "https://github.com/fables-tales/rubyfmt";
75 license = lib.licenses.mit;
76 maintainers = with lib.maintainers; [ bobvanderlinden ];
77 broken = stdenv.hostPlatform.isDarwin;
78 mainProgram = "rubyfmt";
79 };
80}