From 5f0c43dea417cf3b3d8d4a5c268fc49fc4141296 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Thu, 4 Jul 2019 12:39:29 +0100 Subject: [PATCH] asciidoctor: move mathematical gem config to default gemset config This has two benefits: - Anyone else using the `mathematical` gem will benefit from the config. - The gem config overrides the default one, so we were losing the fixes for other gems. I had to change how the update script works. Now it looks at the `gems` passthru from `bundlerApp`. --- .../ruby-modules/gem-config/default.nix | 27 +++++++ .../tools/typesetting/asciidoctor/default.nix | 72 ++++++------------- pkgs/tools/typesetting/asciidoctor/update.sh | 4 +- 3 files changed, 49 insertions(+), 54 deletions(-) diff --git a/pkgs/development/ruby-modules/gem-config/default.nix b/pkgs/development/ruby-modules/gem-config/default.nix index 115739bd404..eb136d4c243 100644 --- a/pkgs/development/ruby-modules/gem-config/default.nix +++ b/pkgs/development/ruby-modules/gem-config/default.nix @@ -24,6 +24,7 @@ , msgpack, qt59, libsodium, snappy, libossp_uuid, lxc, libpcap, xorg, gtk2, buildRubyGem , cairo, re2, rake, gobject-introspection, gdk_pixbuf, zeromq, czmq, graphicsmagick, libcxx , file, libvirt, glib, vips, taglib, libopus, linux-pam, libidn, protobuf, fribidi, harfbuzz +, bison, flex, pango, python3, patchelf , libselinux ? null, libsepol ? null }@args: @@ -245,6 +246,32 @@ in ]; }; + mathematical = attrs: { + buildInputs = [ + cmake + bison + flex + glib + pkgconfig + cairo + pango + gdk_pixbuf + libxml2 + python3 + ]; + + # The ruby build script takes care of this + dontUseCmakeConfigure = true; + + # For some reason 'mathematical.so' is missing cairo and glib in its RPATH, add them explicitly here + postFixup = lib.optionalString stdenv.isLinux '' + soPath="$out/${ruby.gemPath}/gems/mathematical-${attrs.version}/lib/mathematical/mathematical.so" + ${patchelf}/bin/patchelf \ + --set-rpath "${lib.makeLibraryPath [ glib cairo ]}:$(${patchelf}/bin/patchelf --print-rpath "$soPath")" \ + "$soPath" + ''; + }; + magic = attrs: { buildInputs = [ file ]; postInstall = '' diff --git a/pkgs/tools/typesetting/asciidoctor/default.nix b/pkgs/tools/typesetting/asciidoctor/default.nix index 0f9bb0ef7de..9da0d291727 100644 --- a/pkgs/tools/typesetting/asciidoctor/default.nix +++ b/pkgs/tools/typesetting/asciidoctor/default.nix @@ -1,59 +1,27 @@ -{ stdenv, lib, bundlerApp, ruby, bundix, mkShell - # Dependencies of the 'mathematical' package -, cmake, bison, flex, glib, pkgconfig, cairo -, pango, gdk_pixbuf, libxml2, python3, patchelf -}: +{ lib, bundlerApp, mkShell, bundix, defaultGemConfig }: -bundlerApp rec { - inherit ruby; - pname = "asciidoctor"; - gemdir = ./.; +let app = bundlerApp { + pname = "asciidoctor"; + gemdir = ./.; - exes = [ - "asciidoctor" - "asciidoctor-pdf" - "asciidoctor-safe" - ]; + exes = [ + "asciidoctor" + "asciidoctor-pdf" + "asciidoctor-safe" + ]; - gemConfig = { - mathematical = attrs: { - buildInputs = [ - cmake - bison - flex - glib - pkgconfig - cairo - pango - gdk_pixbuf - libxml2 - python3 - ]; - - # The ruby build script takes care of this - dontUseCmakeConfigure = true; - - # For some reason 'mathematical.so' is missing cairo and glib in its RPATH, add them explicitly here - postFixup = lib.optionalString stdenv.isLinux '' - soPath="$out/${ruby.gemPath}/gems/mathematical-${attrs.version}/lib/mathematical/mathematical.so" - ${patchelf}/bin/patchelf \ - --set-rpath "${lib.makeLibraryPath [ glib cairo ]}:$(${patchelf}/bin/patchelf --print-rpath "$soPath")" \ - "$soPath" - ''; + meta = with lib; { + description = "A faster Asciidoc processor written in Ruby"; + homepage = https://asciidoctor.org/; + license = licenses.mit; + maintainers = with maintainers; [ gpyh ]; + platforms = platforms.unix; }; }; - passthru.updateShell = mkShell { - buildInputs = (gemConfig.mathematical {}).buildInputs ++ [ - bundix - ]; + shell = mkShell { + buildInputs = + app.gems.mathematical.buildInputs ++ + [ bundix ]; }; - - meta = with lib; { - description = "A faster Asciidoc processor written in Ruby"; - homepage = https://asciidoctor.org/; - license = licenses.mit; - maintainers = with maintainers; [ gpyh ]; - platforms = platforms.unix; - }; -} +in app.overrideAttrs (attrs: { passthru = attrs.passthru // { updateShell = shell; }; }) diff --git a/pkgs/tools/typesetting/asciidoctor/update.sh b/pkgs/tools/typesetting/asciidoctor/update.sh index db7511330be..1f7e5541cee 100755 --- a/pkgs/tools/typesetting/asciidoctor/update.sh +++ b/pkgs/tools/typesetting/asciidoctor/update.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -rm gemset.nix Gemfile.lock nix-shell ../../../.. -A asciidoctor.updateShell --run ' + rm gemset.nix Gemfile.lock bundix -m --bundle-pack-path $TMPDIR/asciidoctor-ruby-bundle + rm -r .bundle ' -rm -r .bundle