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