summary refs log tree commit diff
path: root/pkgs/development/interpreters/ruby/patches.nix
blob: 9d694eac1e42a843d1387dc7e0bcdcb307dceb03 (plain) (blame)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
{ fetchurl, writeScript, ruby, ncurses, sqlite, libxml2, libxslt, libffi
, zlib, libuuid, gems, jdk, python, stdenv, libiconvOrEmpty, imagemagick
, pkgconfig, libiconv }:

let

  patchUsrBinEnv = writeScript "path-usr-bin-env" ''
    #!/bin/sh
    echo "==================="
    find "$1" -type f -name "*.rb" | xargs sed -i "s@/usr/bin/env@$(type -p env)@g"
    find "$1" -type f -name "*.mk" | xargs sed -i "s@/usr/bin/env@$(type -p env)@g"
  '';

in

{
  buildr = {
    # Many Buildfiles rely on RUBYLIB containing the current directory
    # (as was the default in Ruby < 1.9.2).
    extraWrapperFlags = "--prefix RUBYLIB : .";
  };

  fakes3 = {
    postInstall = ''
      cd $out/${ruby.gemPath}/gems/*
      patch -Np1 -i ${../../ruby-modules/fake-s3-list-bucket.patch}
    '';
  };

  ffi = {
    postUnpack = "onetuh";
    buildFlags = ["--with-ffi-dir=${libffi}"];
    NIX_POST_EXTRACT_FILES_HOOK = patchUsrBinEnv;
  };

  iconv = { buildInputs = [ libiconvOrEmpty ]; };

  libv8 = {
    # This fix is needed to fool scons, which clears the environment by default.
    # It's ugly, but it works.
    #
    # We create a gcc wrapper wrapper, which reexposes the environment variables
    # that scons hides. Furthermore, they treat warnings as errors causing the
    # build to fail, due to an unused variable.
    #
    # Finally, we must set CC and AR explicitly to allow scons to find the
    # compiler and archiver

    preBuild = ''
      cat > $TMPDIR/g++ <<EOF
      #! ${stdenv.shell}
      $(export)

      g++ \$(echo \$@ | sed 's/-Werror//g')
      EOF
      chmod +x $TMPDIR/g++

      export CXX=$TMPDIR/g++
      export AR=$(type -p ar)
    '';
    buildInputs = [ python ];
    NIX_POST_EXTRACT_FILES_HOOK = writeScript "patch-scons" ''
      #!/bin/sh
      for i in `find "$1" -name scons`
      do
          sed -i -e "s@/usr/bin/env@$(type -p env)@g" $i
      done
    '';
  };

  ncurses = { propagatedBuildInputs = [ ncurses ]; };

  ncursesw = { propagatedBuildInputs = [ ncurses ]; };

  nix = {
    postInstall = ''
      cd $out/${ruby.gemPath}/gems/nix*
      patch -Np1 -i ${./fix-gem-nix-versions.patch}
    '';
  };

  nokogiri = {
    buildInputs = [ libxml2 ];
    buildFlags =
      [ "--with-xml2-dir=${libxml2} --with-xml2-include=${libxml2}/include/libxml2"
        "--with-xslt-dir=${libxslt} --with-iconv-dir=${libiconv} --use-system-libraries"
      ];
  };

  pry = { gemFlags = "--no-ri --no-rdoc"; };

  rails = { gemFlags = "--no-ri --no-rdoc"; };

  rjb = {
    buildInputs = [ jdk ];
    JAVA_HOME = jdk;
  };

  rmagick = {
    buildInputs = [ imagemagick pkgconfig ];

    NIX_CFLAGS_COMPILE = "-I${imagemagick}/include/ImageMagick-6";
  };

  sqlite3 = { propagatedBuildInputs = [ sqlite ]; };

  xapian_full = {
    buildInputs = [ gems.rake zlib libuuid ];
    gemFlags = "--no-rdoc --no-ri";
  };

  xapian_full_alaveteli = {
    buildInputs = [ zlib libuuid ];
  };

  xapian_ruby = {
    buildInputs = [ zlib libuuid ];
  };

  xrefresh_server =
    let
      patch = fetchurl {
        url = "http://mawercer.de/~nix/xrefresh.diff.gz";
        sha256 = "1f7bnmn1pgkmkml0ms15m5lx880hq2sxy7vsddb3sbzm7n1yyicq";
      };
    in {
      propagatedBuildInputs = [ gems.rb_inotify ];

      # monitor implementation for Linux
      postInstall = ''
        cd $out/${ruby.gemPath}/gems/*
        zcat ${patch} | patch -p 1
      ''; # */
    };
}