ruby: rewrite `sup` package

+244 -128
+6 -4
pkgs/applications/networking/mailreaders/sup/Gemfile
··· 1 1 source "https://rubygems.org" 2 2 3 - #gem "sup", "0.20.0" 4 - #gem 'sup', '~> 0.20.0' 5 - #gem 'gpgme' 6 - gem 'gpgme', '2.0.7' 3 + gem 'sup' 4 + gem 'gpgme' 5 + 6 + # Sup tries to `xapian-ruby` in its extconf instead of listing it as a 7 + # dependency. 8 + gem 'xapian-ruby', "~> 1.2.15"
+23 -1
pkgs/applications/networking/mailreaders/sup/Gemfile.lock
··· 1 1 GEM 2 2 remote: https://rubygems.org/ 3 3 specs: 4 + chronic (0.9.1) 4 5 gpgme (2.0.7) 5 6 mini_portile (>= 0.5.0, <= 0.6.0) 7 + highline (1.6.21) 8 + locale (2.1.0) 9 + lockfile (2.1.3) 10 + mime-types (1.25.1) 6 11 mini_portile (0.6.0) 12 + ncursesw (1.4.9) 13 + rmail-sup (1.0.1) 14 + sup (0.20.0) 15 + chronic (~> 0.9.1) 16 + highline 17 + locale (~> 2.0) 18 + lockfile 19 + mime-types (~> 1.0) 20 + ncursesw (~> 1.4.0) 21 + rmail-sup (~> 1.0.1) 22 + trollop (>= 1.12) 23 + unicode (~> 0.4.4) 24 + trollop (2.1.1) 25 + unicode (0.4.4.2) 26 + xapian-ruby (1.2.19.1) 7 27 8 28 PLATFORMS 9 29 ruby 10 30 11 31 DEPENDENCIES 12 - gpgme (= 2.0.7) 32 + gpgme 33 + sup 34 + xapian-ruby (~> 1.2.15)
+42 -69
pkgs/applications/networking/mailreaders/sup/default.nix
··· 1 - { stdenv, fetchurl, ruby, rake, rubygems, makeWrapper, ncursesw_sup 2 - , xapian_ruby, gpgme, libiconvOrEmpty, mime_types, chronic, trollop, lockfile 3 - , gettext, iconv, locale, text, highline, rmail_sup, unicode, gnupg, which 4 - , bundler, git }: 1 + { stdenv, lib, bundlerEnv, gpgme, ruby, ncurses, writeText, zlib, xapian, pkgconfig, which }: 5 2 6 - stdenv.mkDerivation rec { 7 - version = "0.18.0"; 8 - name = "sup-${version}"; 3 + bundlerEnv { 4 + name = "sup-0.20.0"; 9 5 10 - meta = { 11 - description = "A curses threads-with-tags style email client"; 12 - homepage = http://supmua.org; 13 - license = stdenv.lib.licenses.gpl2; 14 - maintainers = with stdenv.lib.maintainers; [ lovek323 ]; 15 - platforms = stdenv.lib.platforms.unix; 16 - broken = true; 6 + inherit ruby; 7 + gemfile = ./Gemfile; 8 + lockfile = ./Gemfile.lock; 9 + gemset = ./gemset.nix; 10 + 11 + fixes.gpgme = attrs: { 12 + buildInputs = [ gpgme ]; 17 13 }; 18 14 19 - dontStrip = true; 15 + fixes.ncursesw = attrs: { 16 + buildInputs = [ ncurses ]; 17 + buildArgs = [ 18 + "--with-cflags=-I${ncurses}/include" 19 + "--with-ldflags=-L${ncurses}/lib" 20 + ]; 21 + }; 20 22 21 - src = fetchurl { 22 - url = "https://github.com/sup-heliotrope/sup/archive/release-${version}.tar.gz"; 23 - sha256 = "1dhg0i2v0ddhwi32ih5lc56x00kbaikd2wdplgzlshq0nljr9xy0"; 23 + fixes.xapian-ruby = attrs: { 24 + # use the system xapian 25 + buildInputs = [ xapian pkgconfig zlib ]; 26 + postPatch = '' 27 + cp ${./xapian-Rakefile} Rakefile 28 + ''; 29 + preInstall = '' 30 + export XAPIAN_CONFIG=${xapian}/bin/xapian-config 31 + ''; 24 32 }; 25 33 26 - buildInputs = 27 - [ rake ruby rubygems makeWrapper gpgme ncursesw_sup xapian_ruby 28 - libiconvOrEmpty git ]; 34 + fixes.sup = attrs: { 35 + # prevent sup from trying to dynamically install `xapian-ruby`. 36 + postPatch = '' 37 + cp ${./mkrf_conf_xapian.rb} ext/mkrf_conf_xapian.rb 29 38 30 - phases = [ "unpackPhase" "buildPhase" "installPhase" ]; 39 + substituteInPlace lib/sup/crypto.rb \ 40 + --replace 'which gpg2' \ 41 + '${which}/bin/which gpg2' 42 + ''; 43 + }; 31 44 32 - buildPhase = '' 33 - # the builder uses git to get a listing of the files 34 - export EMAIL="nobody@in.here" 35 - git init >/dev/null 36 - git add . 37 - git commit -m "message" >/dev/null 38 - gem build sup.gemspec 39 - ''; 40 - 41 - installPhase = '' 42 - export HOME=$TMP/home; mkdir -pv "$HOME" 43 - 44 - GEM_PATH="$GEM_PATH:$out/${ruby.gemPath}" 45 - GEM_PATH="$GEM_PATH:${chronic}/${ruby.gemPath}" 46 - GEM_PATH="$GEM_PATH:${gettext}/${ruby.gemPath}" 47 - GEM_PATH="$GEM_PATH:${gpgme}/${ruby.gemPath}" 48 - GEM_PATH="$GEM_PATH:${highline}/${ruby.gemPath}" 49 - GEM_PATH="$GEM_PATH:${iconv}/${ruby.gemPath}" 50 - GEM_PATH="$GEM_PATH:${locale}/${ruby.gemPath}" 51 - GEM_PATH="$GEM_PATH:${lockfile}/${ruby.gemPath}" 52 - GEM_PATH="$GEM_PATH:${mime_types}/${ruby.gemPath}" 53 - GEM_PATH="$GEM_PATH:${ncursesw_sup}/${ruby.gemPath}" 54 - GEM_PATH="$GEM_PATH:${rmail_sup}/${ruby.gemPath}" 55 - GEM_PATH="$GEM_PATH:${text}/${ruby.gemPath}" 56 - GEM_PATH="$GEM_PATH:${trollop}/${ruby.gemPath}" 57 - GEM_PATH="$GEM_PATH:${unicode}/${ruby.gemPath}" 58 - GEM_PATH="$GEM_PATH:${xapian_ruby}/${ruby.gemPath}" 59 - 60 - # Don't install some dependencies -- we have already installed 61 - # the dependencies but gem doesn't acknowledge this 62 - gem install --no-verbose --install-dir "$out/${ruby.gemPath}" \ 63 - --bindir "$out/bin" --no-rdoc --no-ri sup-${version}.gem \ 64 - --ignore-dependencies >/dev/null 65 - 66 - # specify ruby interpreter explicitly 67 - sed -i '1 s|^.*$|#!${ruby}/bin/ruby|' bin/sup-sync-back-maildir 68 - 69 - cp bin/sup-sync-back-maildir "$out/bin" 70 - 71 - for prog in $out/bin/*; do 72 - wrapProgram "$prog" --prefix GEM_PATH : "$GEM_PATH" --prefix PATH : "${gnupg}/bin:${which}/bin" 73 - done 74 - 75 - for prog in $out/gems/*/bin/*; do 76 - [[ -e "$out/bin/$(basename $prog)" ]] 77 - done 78 - ''; 45 + meta = with lib; { 46 + description = "A curses threads-with-tags style email client"; 47 + homepage = http://supmua.org; 48 + license = with licenses; gpl2; 49 + maintainers = with maintainers; [ cstrahan lovek323 ]; 50 + platforms = platforms.unix; 51 + }; 79 52 }
+92 -4
pkgs/applications/networking/mailreaders/sup/gemset.nix
··· 1 1 { 2 - gpgme = { 2 + "chronic" = { 3 + version = "0.9.1"; 4 + source = { 5 + type = "gem"; 6 + sha256 = "0kspaxpfy7yvyk1lvpx31w852qfj8wb9z04mcj5bzi70ljb9awqk"; 7 + }; 8 + }; 9 + "gpgme" = { 3 10 version = "2.0.7"; 4 - src = { 11 + source = { 5 12 type = "gem"; 6 13 sha256 = "1p84zhiri2ihcld7py9mwc2kg5xs5da8fk11zhndrhmw05yvf5mr"; 7 14 }; ··· 9 16 "mini_portile" 10 17 ]; 11 18 }; 12 - mini_portile = { 19 + "highline" = { 20 + version = "1.6.21"; 21 + source = { 22 + type = "gem"; 23 + sha256 = "06bml1fjsnrhd956wqq5k3w8cyd09rv1vixdpa3zzkl6xs72jdn1"; 24 + }; 25 + }; 26 + "locale" = { 27 + version = "2.1.0"; 28 + source = { 29 + type = "gem"; 30 + sha256 = "18bb0g24flq9dr8qv4j7pm7w9i2vmvmqrbmry95ibf1r1c4s60yj"; 31 + }; 32 + }; 33 + "lockfile" = { 34 + version = "2.1.3"; 35 + source = { 36 + type = "gem"; 37 + sha256 = "0dij3ijywylvfgrpi2i0k17f6w0wjhnjjw0k9030f54z56cz7jrr"; 38 + }; 39 + }; 40 + "mime-types" = { 41 + version = "1.25.1"; 42 + source = { 43 + type = "gem"; 44 + sha256 = "0mhzsanmnzdshaba7gmsjwnv168r1yj8y0flzw88frw1cickrvw8"; 45 + }; 46 + }; 47 + "mini_portile" = { 13 48 version = "0.6.0"; 14 - src = { 49 + source = { 15 50 type = "gem"; 16 51 sha256 = "09kcn4g63xrdirgwxgjikqg976rr723bkc9bxfr29pk22cj3wavn"; 52 + }; 53 + }; 54 + "ncursesw" = { 55 + version = "1.4.9"; 56 + source = { 57 + type = "gem"; 58 + sha256 = "154cls3b237imdbhih7rni5p85nw6mpbpkzdw08jxzvqaml7q093"; 59 + }; 60 + }; 61 + "rmail-sup" = { 62 + version = "1.0.1"; 63 + source = { 64 + type = "gem"; 65 + sha256 = "1xswk101s560lxqaax3plqh8vjx7jjspnggdwb3q80m358f92q9g"; 66 + }; 67 + }; 68 + "sup" = { 69 + version = "0.20.0"; 70 + source = { 71 + type = "gem"; 72 + sha256 = "1lpqgrqkv29xr1h1142qsbmknlshpgys7fc3w1nkyhib8s3ikamg"; 73 + }; 74 + dependencies = [ 75 + "chronic" 76 + "highline" 77 + "locale" 78 + "lockfile" 79 + "mime-types" 80 + "ncursesw" 81 + "rmail-sup" 82 + "trollop" 83 + "unicode" 84 + ]; 85 + }; 86 + "trollop" = { 87 + version = "2.1.1"; 88 + source = { 89 + type = "gem"; 90 + sha256 = "0z5dvh7glwqjprlihsjx67hfzy4whsjfhqj9akyyrby9q5va1i4k"; 91 + }; 92 + }; 93 + "unicode" = { 94 + version = "0.4.4.2"; 95 + source = { 96 + type = "gem"; 97 + sha256 = "15fggljzan8zvmr8h12b5m7pcj1gvskmmnx367xs4p0rrpnpil8g"; 98 + }; 99 + }; 100 + "xapian-ruby" = { 101 + version = "1.2.19.1"; 102 + source = { 103 + type = "gem"; 104 + sha256 = "1crfrmc8kf6qq1xcfcmgf213zg66badpg4d86n7y9x3i1f5lxlbv"; 17 105 }; 18 106 }; 19 107 }
+14
pkgs/applications/networking/mailreaders/sup/mkrf_conf_xapian.rb
··· 1 + require 'rubygems' 2 + require 'rubygems/command.rb' 3 + require 'rubygems/dependency_installer.rb' 4 + require 'rbconfig' 5 + 6 + begin 7 + Gem::Command.build_args = ARGV 8 + rescue NoMethodError 9 + end 10 + 11 + # create dummy rakefile to indicate success 12 + f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w") 13 + f.write("task :default\n") 14 + f.close
+38
pkgs/applications/networking/mailreaders/sup/xapian-Rakefile
··· 1 + # encoding: utf-8 2 + # Install the xapian binaries into the lib folder of the gem 3 + require 'rbconfig' 4 + 5 + c = RbConfig::CONFIG 6 + 7 + def system!(cmd) 8 + puts cmd 9 + system(cmd) or raise 10 + end 11 + 12 + source_dir = 'xapian_source' 13 + bindings = Dir["#{source_dir}/xapian-bindings-*"].first 14 + bindings = File.basename(bindings, ".tar.xz") 15 + 16 + task :default do 17 + system! "tar -xJf #{source_dir}/#{bindings}.tar.xz" 18 + 19 + prefix = Dir.pwd 20 + ENV['LDFLAGS'] = "-L#{prefix}/lib" 21 + 22 + system! "mkdir -p lib" 23 + 24 + Dir.chdir bindings do 25 + ENV['RUBY'] ||= "#{c['bindir']}/#{c['RUBY_INSTALL_NAME']}" 26 + system! "./configure --prefix=#{prefix} --exec-prefix=#{prefix} --with-ruby" 27 + system! "make clean all" 28 + end 29 + 30 + system! "cp -r #{bindings}/ruby/.libs/_xapian.* lib" 31 + system! "cp #{bindings}/ruby/xapian.rb lib" 32 + 33 + system! "rm lib/*.la" 34 + system! "rm lib/*.lai" 35 + 36 + system! "rm -R #{bindings}" 37 + system! "rm -R #{source_dir}" 38 + end
+21 -9
pkgs/development/interpreters/ruby/bundler-env.nix
··· 1 1 { stdenv, runCommand, writeText, writeScript, writeScriptBin, ruby, lib 2 2 , callPackage , gemFixes, fetchurl, fetchgit, buildRubyGem 3 - #, bundler_PATCHED 4 3 , bundler_HEAD 5 4 , git 6 5 }@defs: ··· 10 9 11 10 { name, gemset, gemfile, lockfile, ruby ? defs.ruby, fixes ? gemFixes 12 11 , enableParallelBuilding ? false # TODO: this might not work, given the env-var shinanigans. 13 - , documentation ? false}@args: 12 + , documentation ? false 13 + , meta ? {} 14 + }@args: 14 15 15 16 let 16 17 ··· 127 128 needsPreInstall = attrs: 128 129 (attrs ? preInstall) || (attrs ? buildInputs) || (attrs ? nativeBuildInputs); 129 130 130 - createPreInstallers = lib.fold (next: acc: 131 + # TODO: support cross compilation? look at stdenv/generic/default.nix. 132 + runPreInstallers = lib.fold (next: acc: 131 133 if !needsPreInstall next 132 134 then acc 133 135 else acc + '' 134 - cp ${writeScript "${next.name}-pre-install" '' 136 + ${writeScript "${next.name}-pre-install" '' 135 137 #!${stdenv.shell} 136 138 137 - buildInputs="${toString (next.buildInputs or [])}" 138 - nativeBuildInputs="${toString (next.nativeBuildInputs or [])}" 139 + export nativeBuildInputs="${toString ((next.nativeBuildInputs or []) ++ (next.buildInputs or []))}" 139 140 140 141 source ${stdenv}/setup 142 + 143 + header "running pre-install script for ${next.name}" 141 144 142 145 ${next.preInstall or ""} 143 146 144 147 ${ruby}/bin/ruby -e 'print ENV.inspect' > env/${next.name} 145 - ''} pre-installers/${next.name} 148 + 149 + stopNest 150 + ''} 146 151 '' 147 152 ) "" (attrValues instantiated); 148 153 ··· 245 250 246 251 stdenv.mkDerivation { 247 252 inherit name; 253 + 248 254 buildInputs = [ 249 255 ruby 250 256 bundler 251 257 git 252 258 ]; 259 + 253 260 phases = [ "installPhase" "fixupPhase" ]; 261 + 254 262 outputs = [ 255 263 "out" # the installed libs/bins 256 264 "bundle" # supporting files for bundler 257 265 ]; 266 + 258 267 installPhase = '' 259 268 # Copy the Gemfile and Gemfile.lock 269 + 260 270 mkdir -p $bundle 261 271 export BUNDLE_GEMFILE=$bundle/Gemfile 262 272 cp ${gemfile} $BUNDLE_GEMFILE ··· 273 283 ${copyGems} 274 284 275 285 mkdir env 276 - mkdir pre-installers 277 - ${createPreInstallers} 286 + ${runPreInstallers} 278 287 279 288 ${allBuildArgs} 280 289 ··· 289 298 export RUBYOPT="-rmonkey_patches.rb -I $(pwd -P)" 290 299 bundler install --frozen --binstubs ${lib.optionalString enableParallelBuilding "--jobs $NIX_BUILD_CORES"} 291 300 ''; 301 + 292 302 passthru = { 293 303 inherit ruby; 294 304 inherit bundler; 295 305 }; 306 + 307 + inherit meta; 296 308 }
+3 -8
pkgs/development/interpreters/ruby/monkey_patches.rb
··· 133 133 # and then set it back to what it was originally. 134 134 alias original_install_gem_from_spec install_gem_from_spec 135 135 def install_gem_from_spec(spec, standalone = false, worker = 0) 136 - pre_installer = "pre-installers/#{spec.name}" 137 - if File.exist?(pre_installer) 138 - system(pre_installer) 139 - unless $?.success? 140 - Bundler.ui.error "The pre-installer script for #{spec.name} failed!" 141 - exit 1 142 - end 143 - env = eval(Bundler.read_file("env/#{spec.name}")) 136 + env_dump = "env/#{spec.name}" 137 + if File.exist?(env_dump) 138 + env = eval(Bundler.read_file(env_dump)) 144 139 unless env 145 140 Bundler.ui.error "The environment variables for #{spec.name} could not be loaded!" 146 141 exit 1
+3 -3
pkgs/development/libraries/xapian/default.nix
··· 1 1 { stdenv, fetchurl, libuuid, zlib }: 2 2 3 3 stdenv.mkDerivation { 4 - name = "xapian-1.2.8"; 4 + name = "xapian-1.2.19"; 5 5 6 6 src = fetchurl { 7 - url = http://oligarchy.co.uk/xapian/1.2.8/xapian-core-1.2.8.tar.gz; 8 - sha256 = "00411ebac66a5592b87fc57ccfeb234c84b929ed23c185befb5df9929df3d4f9"; 7 + url = http://oligarchy.co.uk/xapian/1.2.19/xapian-core-1.2.19.tar.xz; 8 + sha256 = "11a7lm3w3pchk4rx144nc2p31994spyqmldm18ph86zzi01jcy2a"; 9 9 }; 10 10 11 11 buildInputs = [ libuuid zlib ];
+2 -30
pkgs/top-level/all-packages.nix
··· 10643 10643 10644 10644 pcmanfm = callPackage ../applications/misc/pcmanfm { }; 10645 10645 10646 - ruby_gpgme = callPackage ../development/libraries/ruby_gpgme { 10647 - ruby = ruby_1_9_3; 10648 - hoe = rubyPackages.hoe; 10649 - }; 10650 - 10651 - ruby_ncursesw_sup = callPackage ../development/libraries/ruby_ncursesw_sup { }; 10652 - 10653 10646 shotcut = callPackage ../applications/video/shotcut { mlt = mlt-qt5; }; 10654 10647 10655 10648 smplayer = callPackage ../applications/video/smplayer { }; 10656 10649 10657 10650 smtube = callPackage ../applications/video/smtube {}; 10658 10651 10659 - sup = with rubyPackages; callPackage ../applications/networking/mailreaders/sup { 10660 - ruby = ruby_1_9_3.override { 10661 - cursesSupport = true; 10662 - }; 10663 - 10664 - inherit gettext highline iconv locale lockfile 10665 - text trollop xapian_ruby which; 10666 - 10667 - rmail_sup = ""; # missing 10668 - unicode = ""; 10669 - 10670 - # See https://github.com/NixOS/nixpkgs/issues/1804 and 10671 - # https://github.com/NixOS/nixpkgs/issues/2146 10672 - bundler = pkgs.lib.overrideDerivation pkgs.rubyPackages.bundler ( 10673 - oldAttrs: { 10674 - dontPatchShebangs = 1; 10675 - } 10676 - ); 10677 - chronic = chronic; 10678 - gpgme = ruby_gpgme; 10679 - mime_types = mime_types; 10680 - ncursesw_sup = ruby_ncursesw_sup; 10681 - rake = rake; 10652 + sup = callPackage ../applications/networking/mailreaders/sup { 10653 + ruby = ruby_1_9_3.override { cursesSupport = true; }; 10682 10654 }; 10683 10655 10684 10656 synfigstudio = callPackage ../applications/graphics/synfigstudio {