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, Foundation
17, Security
18}:
19
20rustPlatform.buildRustPackage rec {
21 pname = "rubyfmt";
22 version = "0.10.0";
23
24 src = fetchFromGitHub {
25 owner = "fables-tales";
26 repo = "rubyfmt";
27 rev = "v${version}";
28 hash = "sha256-IIHPU6iwFwQ5cOAtOULpMSjexFtTelSd/LGLuazdmUo=";
29 fetchSubmodules = true;
30 };
31
32 nativeBuildInputs = [
33 autoconf
34 automake
35 bison
36 ruby
37 ];
38
39 buildInputs = [
40 zlib
41 libxcrypt
42 libyaml
43 ] ++ lib.optionals stdenv.isDarwin [
44 readline
45 libiconv
46 libobjc
47 libunwind
48 Foundation
49 Security
50 ];
51
52 preConfigure = ''
53 pushd librubyfmt/ruby_checkout
54 autoreconf --install --force --verbose
55 ./configure
56 popd
57 '';
58
59 cargoPatches = [
60 # Avoid checking whether ruby gitsubmodule is up-to-date.
61 ./0002-remove-dependency-on-git.patch
62 ];
63
64 cargoHash = "sha256-QZ26GmsKyENkzdCGg2peie/aJhEt7KQAF/lwsibonDk=";
65
66 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-fdeclspec";
67
68 preFixup = ''
69 mv $out/bin/rubyfmt{-main,}
70 '';
71
72 meta = with lib; {
73 description = "A Ruby autoformatter";
74 homepage = "https://github.com/fables-tales/rubyfmt";
75 license = licenses.mit;
76 maintainers = with maintainers; [ bobvanderlinden ];
77 # = note: Undefined symbols for architecture x86_64:
78 # "_utimensat", referenced from:
79 # _utime_internal in librubyfmt-3c969812b3b27083.rlib(file.o)
80 broken = stdenv.isDarwin && stdenv.isx86_64;
81 mainProgram = "rubyfmt";
82 };
83}