summary refs log tree commit diff
path: root/pkgs/development/libraries/ruby_gpgme/default.nix
blob: c5f2366bfa1c2cb83ee0bd3599f79ba908a17ba5 (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
{ stdenv, fetchurl, gpgme, ruby, rubygems, hoe }:

stdenv.mkDerivation {
  name = "ruby-gpgme-1.0.8";

  src = fetchurl {
    url = "https://github.com/ueno/ruby-gpgme/archive/1.0.8.tar.gz";
    sha256 = "1j7jkl9s8iqcmxf3x6c9kljm19hw1jg6yvwbndmkw43qacdr9nxb";
  };

  meta = {
    description = ''
      Ruby-GPGME is a Ruby language binding of GPGME (GnuPG Made
      Easy)
    '';
    homepage = "http://rubyforge.org/projects/ruby-gpgme/";
    longDescription = ''
      Ruby-GPGME is a Ruby language binding of GPGME (GnuPG Made Easy).

      GnuPG Made Easy (GPGME) is a library designed to make access to GnuPG
      easier for applications. It provides a High-Level Crypto API for
      encryption, decryption, signing, signature verification and key
      management.
    '';
  };

  buildInputs = [ gpgme rubygems hoe ruby ];

  buildPhase = ''
    ${ruby}/bin/ruby extconf.rb
    rake gem
  '';

  installPhase = ''
    export HOME=$TMP/home; mkdir -pv "$HOME"

    # For some reason, the installation phase doesn't work with the default
    # make install command run by gem (we'll fix it and do it ourselves later)
    gem install --no-verbose --install-dir "$out/${ruby.gemPath}" \
        --bindir "$out/bin" --no-rdoc --no-ri pkg/gpgme-1.0.8.gem || true

    # Create a bare-bones gemspec file so that ruby will recognise the gem
    cat <<EOF >"$out/${ruby.gemPath}/specifications/gpgme.gemspec"
    Gem::Specification.new do |s|
      s.name              = 'gpgme'
      s.version           = '1.0.8'
      s.files             = Dir['{lib,examples}/**/*']
      s.rubyforge_project = 'ruby-gpgme'
      s.require_paths     = ['lib']
    end
    EOF

    cd "$out/${ruby.gemPath}/gems/gpgme-1.0.8"
    mkdir src
    mv lib src
    sed -i "s/srcdir = ./srcdir = src/" Makefile
    make install

    mv lib lib.bak
    mv src/lib lib
    rmdir src
  '';
}