nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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 nix-update-script,
18}:
19
20rustPlatform.buildRustPackage (finalAttrs: {
21 pname = "rubyfmt";
22 version = "0.11.0";
23
24 src = fetchFromGitHub {
25 owner = "fables-tales";
26 repo = "rubyfmt";
27 tag = "v${finalAttrs.version}";
28 hash = "sha256-wGvfmBm2GNXASXc//K2JOrn/iUdlbA5dDReNJ+NqjDM=";
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 rust-jemalloc-sys-unprefixed
44 ]
45 ++ lib.optionals stdenv.hostPlatform.isDarwin [
46 readline
47 libiconv
48 libunwind
49 ];
50
51 preConfigure = ''
52 pushd librubyfmt/ruby_checkout
53 autoreconf --install --force --verbose
54 ./configure
55 popd
56 '';
57
58 cargoPatches = [
59 # Avoid checking whether ruby gitsubmodule is up-to-date.
60 ./0002-remove-dependency-on-git.patch
61 # Avoid failing on unused variable warnings.
62 ./0003-ignore-warnings.patch
63 ];
64
65 cargoHash = "sha256-jJa/6TKwTTN3xOBuUy+YdwKOJbtYVrmlHgMyqPCVqVs=";
66
67 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-fdeclspec";
68
69 preFixup = ''
70 mv $out/bin/rubyfmt{-main,}
71 '';
72
73 passthru.updateScript = nix-update-script { extraArgs = [ "--use-github-releases" ]; };
74
75 meta = {
76 description = "Ruby autoformatter";
77 homepage = "https://github.com/fables-tales/rubyfmt";
78 license = lib.licenses.mit;
79 maintainers = with lib.maintainers; [ bobvanderlinden ];
80 broken = stdenv.hostPlatform.isDarwin;
81 mainProgram = "rubyfmt";
82 };
83})