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`.
This commit is contained in:
Michael Peyton Jones 2019-07-04 12:39:29 +01:00
parent 73392e79aa
commit 5f0c43dea4
No known key found for this signature in database
GPG Key ID: 86A43C24A728F66D
3 changed files with 49 additions and 54 deletions

View File

@ -24,6 +24,7 @@
, msgpack, qt59, libsodium, snappy, libossp_uuid, lxc, libpcap, xorg, gtk2, buildRubyGem , msgpack, qt59, libsodium, snappy, libossp_uuid, lxc, libpcap, xorg, gtk2, buildRubyGem
, cairo, re2, rake, gobject-introspection, gdk_pixbuf, zeromq, czmq, graphicsmagick, libcxx , cairo, re2, rake, gobject-introspection, gdk_pixbuf, zeromq, czmq, graphicsmagick, libcxx
, file, libvirt, glib, vips, taglib, libopus, linux-pam, libidn, protobuf, fribidi, harfbuzz , file, libvirt, glib, vips, taglib, libopus, linux-pam, libidn, protobuf, fribidi, harfbuzz
, bison, flex, pango, python3, patchelf
, libselinux ? null, libsepol ? null , libselinux ? null, libsepol ? null
}@args: }@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: { magic = attrs: {
buildInputs = [ file ]; buildInputs = [ file ];
postInstall = '' postInstall = ''

View File

@ -1,59 +1,27 @@
{ stdenv, lib, bundlerApp, ruby, bundix, mkShell { lib, bundlerApp, mkShell, bundix, defaultGemConfig }:
# Dependencies of the 'mathematical' package
, cmake, bison, flex, glib, pkgconfig, cairo
, pango, gdk_pixbuf, libxml2, python3, patchelf
}:
bundlerApp rec { let app = bundlerApp {
inherit ruby; pname = "asciidoctor";
pname = "asciidoctor"; gemdir = ./.;
gemdir = ./.;
exes = [ exes = [
"asciidoctor" "asciidoctor"
"asciidoctor-pdf" "asciidoctor-pdf"
"asciidoctor-safe" "asciidoctor-safe"
]; ];
gemConfig = { meta = with lib; {
mathematical = attrs: { description = "A faster Asciidoc processor written in Ruby";
buildInputs = [ homepage = https://asciidoctor.org/;
cmake license = licenses.mit;
bison maintainers = with maintainers; [ gpyh ];
flex platforms = platforms.unix;
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"
'';
}; };
}; };
passthru.updateShell = mkShell { shell = mkShell {
buildInputs = (gemConfig.mathematical {}).buildInputs ++ [ buildInputs =
bundix app.gems.mathematical.buildInputs ++
]; [ bundix ];
}; };
in app.overrideAttrs (attrs: { passthru = attrs.passthru // { updateShell = shell; }; })
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;
};
}

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
rm gemset.nix Gemfile.lock
nix-shell ../../../.. -A asciidoctor.updateShell --run ' nix-shell ../../../.. -A asciidoctor.updateShell --run '
rm gemset.nix Gemfile.lock
bundix -m --bundle-pack-path $TMPDIR/asciidoctor-ruby-bundle bundix -m --bundle-pack-path $TMPDIR/asciidoctor-ruby-bundle
rm -r .bundle
' '
rm -r .bundle