uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead

https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948
this can do it nicely.

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
Anton Arapov 2021-04-03 12:58:10 +02:00 committed by Alan Daniels
commit 56de2bcd43
30691 changed files with 3076956 additions and 0 deletions

View file

@ -0,0 +1,43 @@
{ buildRubyGem, fetchFromGitHub, makeWrapper, lib, bundler, nix,
nix-prefetch-git }:
buildRubyGem rec {
inherit (bundler) ruby;
name = "${gemName}-${version}";
gemName = "bundix";
version = "2.5.1";
src = fetchFromGitHub {
owner = "nix-community";
repo = "bundix";
rev = version;
sha256 = "sha256-iMp6Yj7TSWDqge3Lw855/igOWdTIuFH1LGeIN/cpq7U=";
};
buildInputs = [ ruby bundler ];
nativeBuildInputs = [ makeWrapper ];
preFixup = ''
wrapProgram $out/bin/bundix \
--prefix PATH : "${nix.out}/bin" \
--prefix PATH : "${nix-prefetch-git.out}/bin" \
--prefix PATH : "${bundler.out}/bin" \
--set GEM_HOME "${bundler}/${bundler.ruby.gemPath}" \
--set GEM_PATH "${bundler}/${bundler.ruby.gemPath}"
'';
meta = {
description = "Creates Nix packages from Gemfiles";
longDescription = ''
This is a tool that converts Gemfile.lock files to nix expressions.
The output is then usable by the bundlerEnv derivation to list all the
dependencies of a ruby package.
'';
homepage = "https://github.com/manveru/bundix";
license = "MIT";
maintainers = with lib.maintainers; [ manveru marsam zimbatm ];
platforms = lib.platforms.all;
};
}

View file

@ -0,0 +1,185 @@
{ stdenv, runCommand, ruby, lib, rsync
, defaultGemConfig, buildRubyGem, buildEnv
, makeBinaryWrapper
, bundler
}@defs:
{
name ? null
, pname ? null
, mainGemName ? null
, gemdir ? null
, gemfile ? null
, lockfile ? null
, gemset ? null
, ruby ? defs.ruby
, copyGemFiles ? false # Copy gem files instead of symlinking
, gemConfig ? defaultGemConfig
, postBuild ? null
, document ? []
, meta ? {}
, groups ? null
, ignoreCollisions ? false
, buildInputs ? []
, ...
}@args:
assert name == null -> pname != null;
with import ./functions.nix { inherit lib gemConfig; };
let
gemFiles = bundlerFiles args;
importedGemset = if builtins.typeOf gemFiles.gemset != "set"
then import gemFiles.gemset
else gemFiles.gemset;
filteredGemset = filterGemset { inherit ruby groups; } importedGemset;
configuredGemset = lib.flip lib.mapAttrs filteredGemset (name: attrs:
applyGemConfigs (attrs // { inherit ruby document; gemName = name; })
);
hasBundler = builtins.hasAttr "bundler" filteredGemset;
bundler =
if hasBundler then gems.bundler
else defs.bundler.override (attrs: { inherit ruby; });
gems = lib.flip lib.mapAttrs configuredGemset (name: attrs: buildGem name attrs);
name' = if name != null then
name
else
let
gem = gems.${pname};
version = gem.version;
in
"${pname}-${version}";
pname' = if pname != null then
pname
else
name;
copyIfBundledByPath = { bundledByPath ? false, ...}:
(if bundledByPath then
assert gemFiles.gemdir != null; "cp -a ${gemFiles.gemdir}/* $out/" #*/
else ""
);
maybeCopyAll = pkgname: if pkgname == null then "" else
let
mainGem = gems.${pkgname} or (throw "bundlerEnv: gem ${pkgname} not found");
in
copyIfBundledByPath mainGem;
# We have to normalize the Gemfile.lock, otherwise bundler tries to be
# helpful by doing so at run time, causing executables to immediately bail
# out. Yes, I'm serious.
confFiles = runCommand "gemfile-and-lockfile" {} ''
mkdir -p $out
${maybeCopyAll mainGemName}
cp ${gemFiles.gemfile} $out/Gemfile || ls -l $out/Gemfile
cp ${gemFiles.lockfile} $out/Gemfile.lock || ls -l $out/Gemfile.lock
'';
buildGem = name: attrs: (
let
gemAttrs = composeGemAttrs ruby gems name attrs;
in
if gemAttrs.type == "path" then
pathDerivation (gemAttrs.source // gemAttrs)
else
buildRubyGem gemAttrs
);
envPaths = lib.attrValues gems ++ lib.optional (!hasBundler) bundler;
basicEnvArgs = {
inherit buildInputs ignoreCollisions;
name = name';
paths = envPaths;
pathsToLink = [ "/lib" ];
postBuild = genStubsScript (defs // args // {
inherit confFiles bundler groups;
binPaths = envPaths;
}) + lib.optionalString (postBuild != null) postBuild;
meta = { platforms = ruby.meta.platforms; } // meta;
passthru = rec {
inherit ruby bundler gems confFiles envPaths;
wrappedRuby = stdenv.mkDerivation {
name = "wrapped-ruby-${pname'}";
nativeBuildInputs = [ makeBinaryWrapper ];
dontUnpack = true;
buildPhase = ''
mkdir -p $out/bin
for i in ${ruby}/bin/*; do
makeWrapper "$i" $out/bin/$(basename "$i") \
--set BUNDLE_GEMFILE ${confFiles}/Gemfile \
--unset BUNDLE_PATH \
--set BUNDLE_FROZEN 1 \
--set GEM_HOME ${basicEnv}/${ruby.gemPath} \
--set GEM_PATH ${basicEnv}/${ruby.gemPath}
done
'';
dontInstall = true;
doCheck = true;
checkPhase = ''
$out/bin/ruby --help > /dev/null
'';
inherit (ruby) meta;
};
env = let
irbrc = builtins.toFile "irbrc" ''
if !(ENV["OLD_IRBRC"].nil? || ENV["OLD_IRBRC"].empty?)
require ENV["OLD_IRBRC"]
end
require 'rubygems'
require 'bundler/setup'
'';
in stdenv.mkDerivation {
name = "${pname'}-interactive-environment";
nativeBuildInputs = [ wrappedRuby basicEnv ];
shellHook = ''
export OLD_IRBRC=$IRBRC
export IRBRC=${irbrc}
'';
buildCommand = ''
echo >&2 ""
echo >&2 "*** Ruby 'env' attributes are intended for interactive nix-shell sessions, not for building! ***"
echo >&2 ""
exit 1
'';
};
};
};
basicEnv =
if copyGemFiles then
runCommand name' basicEnvArgs ''
mkdir -p $out
for i in $paths; do
${rsync}/bin/rsync -a $i/lib $out/
done
eval "$postBuild"
''
else
buildEnv basicEnvArgs;
in
basicEnv

View file

@ -0,0 +1,93 @@
{ lib, gemConfig, ... }:
let
inherit (lib) attrValues concatMap converge filterAttrs getAttrs
intersectLists;
in rec {
bundlerFiles = {
gemfile ? null
, lockfile ? null
, gemset ? null
, gemdir ? null
, ...
}: {
inherit gemdir;
gemfile =
if gemfile == null then assert gemdir != null; gemdir + "/Gemfile"
else gemfile;
lockfile =
if lockfile == null then assert gemdir != null; gemdir + "/Gemfile.lock"
else lockfile;
gemset =
if gemset == null then assert gemdir != null; gemdir + "/gemset.nix"
else gemset;
};
filterGemset = { ruby, groups, ... }: gemset:
let
platformGems = filterAttrs (_: platformMatches ruby) gemset;
directlyMatchingGems = filterAttrs (_: groupMatches groups) platformGems;
expandDependencies = gems:
let
depNames = concatMap (gem: gem.dependencies or []) (attrValues gems);
deps = getAttrs depNames platformGems;
in
gems // deps;
in
converge expandDependencies directlyMatchingGems;
platformMatches = {rubyEngine, version, ...}: attrs: (
!(attrs ? platforms) ||
builtins.length attrs.platforms == 0 ||
builtins.any (platform:
platform.engine == rubyEngine &&
(!(platform ? version) || platform.version == version.majMin)
) attrs.platforms
);
groupMatches = groups: attrs:
groups == null || !(attrs ? groups) ||
(intersectLists (groups ++ [ "default" ]) attrs.groups) != [];
applyGemConfigs = attrs:
(if gemConfig ? ${attrs.gemName}
then attrs // gemConfig.${attrs.gemName} attrs
else attrs);
genStubsScript = { lib, ruby, confFiles, bundler, groups, binPaths, ... }: ''
${ruby}/bin/ruby ${./gen-bin-stubs.rb} \
"${ruby}/bin/ruby" \
"${confFiles}/Gemfile" \
"$out/${ruby.gemPath}" \
"${bundler}/${ruby.gemPath}/gems/bundler-${bundler.version}" \
${lib.escapeShellArg binPaths} \
${lib.escapeShellArg groups}
'';
pathDerivation = { gemName, version, path, ... }:
let
res = {
type = "derivation";
bundledByPath = true;
name = gemName;
version = version;
outPath = "${path}";
outputs = [ "out" ];
out = res;
outputName = "out";
};
in res;
composeGemAttrs = ruby: gems: name: attrs: ((removeAttrs attrs ["platforms"]) // {
inherit ruby;
inherit (attrs.source) type;
source = removeAttrs attrs.source ["type"];
gemName = name;
gemPath = map (gemName: gems.${gemName}) (attrs.dependencies or []);
});
}

View file

@ -0,0 +1,51 @@
require 'rbconfig'
require 'rubygems'
require 'rubygems/specification'
require 'fileutils'
# args/settings
out = ENV["out"]
ruby = ARGV[0]
gemfile = ARGV[1]
bundle_path = ARGV[2]
bundler_path = ARGV[3]
paths = ARGV[4].split
groups = ARGV[5].split
# generate binstubs
FileUtils.mkdir_p("#{out}/bin")
paths.each do |path|
next unless File.directory?("#{path}/nix-support/gem-meta")
name = File.read("#{path}/nix-support/gem-meta/name")
executables = File.read("#{path}/nix-support/gem-meta/executables")
.force_encoding('UTF-8').split
executables.each do |exe|
File.open("#{out}/bin/#{exe}", "w") do |f|
f.write(<<-EOF)
#!#{ruby}
#
# This file was generated by Nix.
#
# The application '#{exe}' is installed as part of a gem, and
# this file is here to facilitate running it.
#
ENV["BUNDLE_GEMFILE"] = #{gemfile.dump}
ENV.delete 'BUNDLE_PATH'
ENV['BUNDLE_FROZEN'] = '1'
ENV['BUNDLE_IGNORE_CONFIG'] = '1'
Gem.paths = { 'GEM_HOME' => #{bundle_path.dump} }
$LOAD_PATH.unshift #{File.join(bundler_path, "/lib").dump}
require 'bundler'
Bundler.setup(#{groups.map(&:dump).join(', ')})
load Gem.bin_path(#{name.dump}, #{exe.dump})
EOF
FileUtils.chmod("+x", "#{out}/bin/#{exe}")
end
end
end

View file

@ -0,0 +1,50 @@
{ lib, ruby, defaultGemConfig, test, should }:
let
testConfigs = {
inherit lib;
gemConfig = defaultGemConfig;
};
functions = (import ./functions.nix testConfigs);
in
builtins.concatLists [
( test.run "All set, no gemdir" (functions.bundlerFiles {
gemfile = test/Gemfile;
lockfile = test/Gemfile.lock;
gemset = test/gemset.nix;
}) {
gemfile = should.equal test/Gemfile;
lockfile = should.equal test/Gemfile.lock;
gemset = should.equal test/gemset.nix;
})
( test.run "Just gemdir" (functions.bundlerFiles {
gemdir = test/.;
}) {
gemfile = should.equal test/Gemfile;
lockfile = should.equal test/Gemfile.lock;
gemset = should.equal test/gemset.nix;
})
( test.run "Gemset and dir" (functions.bundlerFiles {
gemdir = test/.;
gemset = test/extraGemset.nix;
}) {
gemfile = should.equal test/Gemfile;
lockfile = should.equal test/Gemfile.lock;
gemset = should.equal test/extraGemset.nix;
})
( test.run "Filter empty gemset" {} (set: functions.filterGemset {inherit ruby; groups = ["default"]; } set == {}))
( let gemSet = { test = { groups = ["x" "y"]; }; };
in
test.run "Filter matches a group" gemSet (set: functions.filterGemset {inherit ruby; groups = ["y" "z"];} set == gemSet))
( let gemSet = { test = { platforms = []; }; };
in
test.run "Filter matches empty platforms list" gemSet (set: functions.filterGemset {inherit ruby; groups = [];} set == gemSet))
( let gemSet = { test = { platforms = [{engine = ruby.rubyEngine; version = ruby.version.majMin;}]; }; };
in
test.run "Filter matches on platform" gemSet (set: functions.filterGemset {inherit ruby; groups = [];} set == gemSet))
( let gemSet = { test = { groups = ["x" "y"]; }; };
in
test.run "Filter excludes based on groups" gemSet (set: functions.filterGemset {inherit ruby; groups = ["a" "b"];} set == {}))
]

View file

@ -0,0 +1,68 @@
{ lib, callPackage, runCommand, makeWrapper, ruby }@defs:
# Use for simple installation of Ruby tools shipped in a Gem.
# Start with a Gemfile that includes `gem <toolgem>`
# > nix-shell -p bundler bundix
# (shell)> bundle lock
# (shell)> bundix
# Then use rubyTool in the default.nix:
# rubyTool { pname = "gemifiedTool"; gemdir = ./.; exes = ["gemified-tool"]; }
# The 'exes' parameter ensures that a copy of e.g. rake doesn't polute the system.
{
# use the name of the name in question; its version will be picked up from the gemset
pname
# Gemdir is the location of the Gemfile{,.lock} and gemset.nix; usually ./.
# This is required unless gemfile, lockfile, and gemset are all provided
, gemdir ? null
# Exes is the list of executables provided by the gems in the Gemfile
, exes ? []
# Scripts are ruby programs depend on gems in the Gemfile (e.g. scripts/rails)
, scripts ? []
, ruby ? defs.ruby
, gemfile ? null
, lockfile ? null
, gemset ? null
, preferLocalBuild ? false
, allowSubstitutes ? false
, installManpages ? true
, meta ? {}
, buildInputs ? []
, postBuild ? ""
, gemConfig ? null
, passthru ? {}
}@args:
let
basicEnv = (callPackage ../bundled-common {}) args;
cmdArgs = removeAttrs args [ "pname" "postBuild" "gemConfig" "passthru" "gemset" "gemdir" ] // {
inherit preferLocalBuild allowSubstitutes; # pass the defaults
buildInputs = buildInputs ++ lib.optional (scripts != []) makeWrapper;
meta = { platforms = ruby.meta.platforms; } // meta;
passthru = basicEnv.passthru // {
inherit basicEnv;
inherit (basicEnv) env;
} // passthru;
};
in
runCommand basicEnv.name cmdArgs ''
mkdir -p $out/bin
${(lib.concatMapStrings (x: "ln -s '${basicEnv}/bin/${x}' $out/bin/${x};\n") exes)}
${(lib.concatMapStrings (s: "makeWrapper $out/bin/$(basename ${s}) $srcdir/${s} " +
"--set BUNDLE_GEMFILE ${basicEnv.confFiles}/Gemfile "+
"--unset BUNDLE_PATH "+
"--set BUNDLE_FROZEN 1 "+
"--set GEM_HOME ${basicEnv}/${ruby.gemPath} "+
"--set GEM_PATH ${basicEnv}/${ruby.gemPath} "+
"--chdir \"$srcdir\";\n") scripts)}
${lib.optionalString installManpages ''
for section in {1..9}; do
mandir="$out/share/man/man$section"
find -L ${basicEnv}/${ruby.gemPath}/gems/${basicEnv.name} \( -wholename "*/man/*.$section" -o -wholename "*/man/man$section/*.$section" \) -print -execdir mkdir -p $mandir \; -execdir cp '{}' $mandir \;
done
''}
''

View file

@ -0,0 +1,75 @@
{ ruby, lib, callPackage, defaultGemConfig, buildEnv, runCommand
, bundler, rsync
}@defs:
{ name ? null
, pname ? null
, gemdir ? null
, gemfile ? null
, lockfile ? null
, gemset ? null
, groups ? ["default"]
, ruby ? defs.ruby
, copyGemFiles ? false # Copy gem files instead of symlinking
, gemConfig ? defaultGemConfig
, postBuild ? null
, document ? []
, meta ? {}
, ignoreCollisions ? false
, passthru ? {}
, ...
}@args:
let
inherit (import ../bundled-common/functions.nix {inherit lib ruby gemConfig groups; }) genStubsScript;
basicEnv = (callPackage ../bundled-common { inherit bundler; }) (args // { inherit pname name; mainGemName = pname; });
inherit (basicEnv) envPaths;
# Idea here is a mkDerivation that gen-bin-stubs new stubs "as specified" -
# either specific executables or the bin/ for certain gem(s), but
# incorporates the basicEnv as a requirement so that its $out is in our path.
# When stubbing the bins for a gem, we should use the gem expression
# directly, which means that basicEnv should somehow make it available.
# Different use cases should use different variations on this file, rather
# than the expression trying to deduce a use case.
# The basicEnv should be put into passthru so that e.g. nix-shell can use it.
in
if pname == null then
basicEnv // { inherit name basicEnv; }
else
let
bundlerEnvArgs = {
inherit ignoreCollisions;
name = basicEnv.name;
paths = envPaths;
pathsToLink = [ "/lib" ];
postBuild = genStubsScript {
inherit lib ruby bundler groups;
confFiles = basicEnv.confFiles;
binPaths = [ basicEnv.gems.${pname} ];
} + lib.optionalString (postBuild != null) postBuild;
meta = { platforms = ruby.meta.platforms; } // meta;
passthru = basicEnv.passthru // {
inherit basicEnv;
inherit (basicEnv) env;
} // passthru;
};
in
if copyGemFiles then
runCommand basicEnv.name bundlerEnvArgs ''
mkdir -p $out
for i in $paths; do
${rsync}/bin/rsync -a $i/lib $out/
done
eval "$postBuild"
''
else
buildEnv bundlerEnvArgs

View file

@ -0,0 +1,33 @@
{ callPackage, test, stubs, should}:
let
bundlerEnv = callPackage ./default.nix stubs // {
basicEnv = callPackage ../bundled-common stubs;
};
justName = bundlerEnv {
name = "test-0.1.2";
gemset = ./test/gemset.nix;
};
pnamed = bundlerEnv {
pname = "test";
gemdir = ./test;
gemset = ./test/gemset.nix;
gemfile = ./test/Gemfile;
lockfile = ./test/Gemfile.lock;
};
in
builtins.concatLists [
(test.run "bundlerEnv { name }" justName {
name = should.equal "test-0.1.2";
})
(test.run "bundlerEnv { pname }" pnamed
[
(should.haveKeys [ "name" "env" "postBuild" ])
{
name = should.equal "test-0.1.2";
env = should.beASet;
postBuild = should.havePrefix "/nix/store";
}
])
]

View file

@ -0,0 +1,10 @@
{
test = {
source = {
remotes = ["https://rubygems.org"];
sha256 = "1j5r0anj8m4qlf2psnldip4b8ha2bsscv11lpdgnfh4nnchzjnxw";
type = "gem";
};
version = "0.1.2";
};
}

View file

@ -0,0 +1,25 @@
{ runtimeShell, lib, writeScript, bundix, bundler, bundler-audit, coreutils, git, nix }:
attrPath:
let
updateScript = writeScript "bundler-update-script" ''
#!${runtimeShell}
PATH=${lib.makeBinPath [ bundler bundler-audit bundix coreutils git nix ]}
set -o errexit
set -o nounset
set -o pipefail
attrPath=$1
toplevel=$(git rev-parse --show-toplevel)
position=$(nix eval -f "$toplevel" --raw "$attrPath.meta.position")
gemdir=$(dirname "$position")
cd "$gemdir"
bundler lock --update
bundler-audit check --update
bundix
'';
in [ updateScript attrPath ]

View file

@ -0,0 +1,14 @@
{ buildRubyGem, ruby }:
buildRubyGem rec {
inherit ruby;
name = "${gemName}-${version}";
gemName = "bundler";
version = "2.3.9";
source.sha256 = "sha256-VZiKuSDP3sSoBXUPcPmwHR/GbZs47NIF+ZlXtHSZWzg=";
dontPatchShebangs = true;
postFixup = ''
sed -i -e "s/activate_bin_path/bin_path/g" $out/bin/bundle
'';
}

View file

@ -0,0 +1,694 @@
# The standard set of gems in nixpkgs including potential fixes.
#
# The gemset is derived from two points of entry:
# - An attrset describing a gem, including version, source and dependencies
# This is just meta data, most probably automatically generated by a tool
# like Bundix (https://github.com/aflatter/bundix).
# {
# name = "bundler";
# version = "1.6.5";
# sha256 = "1s4x0f5by9xs2y24jk6krq5ky7ffkzmxgr4z1nhdykdmpsi2zd0l";
# dependencies = [ "rake" ];
# }
# - An optional derivation that may override how the gem is built. For popular
# gems that don't behave correctly, fixes are already provided in the form of
# derivations.
#
# This seperates "what to build" (the exact gem versions) from "how to build"
# (to make gems behave if necessary).
{ lib, fetchurl, writeScript, ruby, libkrb5, libxml2, libxslt, python2, stdenv, which
, libiconv, postgresql, v8, clang, sqlite, zlib, imagemagick, lasem
, pkg-config , ncurses, xapian, gpgme, util-linux, tzdata, icu, libffi
, cmake, libssh2, openssl, libmysqlclient, git, perl, pcre, gecode_3, curl
, msgpack, 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, binutils, freetds, wrapGAppsHook, atk
, bundler, libsass, libexif, libselinux, libsepol, shared-mime-info, libthai, libdatrie
, CoreServices, DarwinTools, cctools, libtool, discount, exiv2, libmaxminddb
}@args:
let
rainbow_rake = buildRubyGem {
pname = "rake";
gemName = "rake";
source.sha256 = "01j8fc9bqjnrsxbppncai05h43315vmz9fwg28qdsgcjw9ck1d7n";
type = "gem";
version = "12.0.0";
};
in
{
atk = attrs: {
dependencies = attrs.dependencies ++ [ "gobject-introspection" ];
nativeBuildInputs = [ rake bundler pkg-config ]
++ lib.optionals stdenv.isDarwin [ DarwinTools ];
propagatedBuildInputs = [ gobject-introspection wrapGAppsHook atk ];
};
bundler = attrs:
let
templates = "${attrs.ruby.gemPath}/gems/${attrs.gemName}-${attrs.version}/lib/bundler/templates/";
in {
# patching shebangs would fail on the templates/Executable file, so we
# temporarily remove the executable flag.
preFixup = "chmod -x $out/${templates}/Executable";
postFixup = ''
chmod +x $out/${templates}/Executable
# Allows to load another bundler version
sed -i -e "s/activate_bin_path/bin_path/g" $out/bin/bundle
'';
};
cairo = attrs: {
nativeBuildInputs = [ pkg-config ]
++ lib.optionals stdenv.isDarwin [ DarwinTools ];
buildInputs = [ gtk2 pcre xorg.libpthreadstubs xorg.libXdmcp];
};
cairo-gobject = attrs: {
nativeBuildInputs = [ pkg-config ]
++ lib.optionals stdenv.isDarwin [ DarwinTools ];
buildInputs = [ cairo pcre xorg.libpthreadstubs xorg.libXdmcp ];
};
charlock_holmes = attrs: {
buildInputs = [ which icu zlib ];
};
cld3 = attrs: {
nativeBuildInputs = [ pkg-config ];
buildInputs = [ protobuf ];
};
cocoapods-acknowledgements = attrs: {
dependencies = attrs.dependencies ++ [ "cocoapods" ];
};
cocoapods-deploy = attrs: {
dependencies = [ "cocoapods" ];
};
cocoapods-disable-podfile-validations = attrs: {
dependencies = [ "cocoapods" ];
};
cocoapods-generate = attrs: {
dependencies = attrs.dependencies ++ [ "cocoapods" ];
};
cocoapods-git_url_rewriter = attrs: {
dependencies = [ "cocoapods" ];
};
cocoapods-keys = attrs: {
dependencies = attrs.dependencies ++ [ "cocoapods" ];
};
cocoapods-open = attrs: {
dependencies = [ "cocoapods" ];
};
cocoapods-try-release-fix = attrs: {
dependencies = [ "cocoapods" ];
};
curb = attrs: {
buildInputs = [ curl ];
};
curses = attrs: {
buildInputs = [ ncurses ];
};
dep-selector-libgecode = attrs: {
USE_SYSTEM_GECODE = true;
postInstall = ''
installPath=$(cat $out/nix-support/gem-meta/install-path)
sed -i $installPath/lib/dep-selector-libgecode.rb -e 's@VENDORED_GECODE_DIR =.*@VENDORED_GECODE_DIR = "${gecode_3}"@'
'';
};
digest-sha3 = attrs: {
hardeningDisable = [ "format" ];
};
rdiscount = attrs: {
# Use discount from nixpkgs instead of vendored version
dontBuild = false;
buildInputs = [ discount ];
patches = [
# Adapted from Debian:
# https://sources.debian.org/data/main/r/ruby-rdiscount/2.1.8-1/debian/patches/01_use-system-libmarkdown.patch
./rdiscount-use-nixpkgs-libmarkdown.patch
];
};
ethon = attrs: {
dontBuild = false;
postPatch = ''
substituteInPlace lib/ethon/curls/settings.rb \
--replace "libcurl" "${curl.out}/lib/libcurl${stdenv.hostPlatform.extensions.sharedLibrary}"
'';
};
exiv2 = attrs: {
buildFlags = [ "--with-exiv2-lib=${exiv2}/lib" "--with-exiv2-include=${exiv2.dev}/include" ];
};
fog-dnsimple = attrs:
lib.optionalAttrs (lib.versionOlder attrs.version "1.0.1") {
postInstall = ''
cd $(cat $out/nix-support/gem-meta/install-path)
rm {$out/bin,bin,../../bin}/{setup,console}
'';
};
redis-rack = attrs: {
dontBuild = false;
preBuild = ''
exec 3>&1
output="$(gem build $gemspec | tee >(cat - >&3))"
exec 3>&-
sed -i 's!"rake".freeze!!' $gemspec
'';
};
ffi-rzmq-core = attrs: {
postInstall = ''
installPath=$(cat $out/nix-support/gem-meta/install-path)
sed -i $installPath/lib/ffi-rzmq-core/libzmq.rb -e 's@inside_gem =.*@inside_gem = "${zeromq}/lib"@'
'';
};
mimemagic = attrs: {
FREEDESKTOP_MIME_TYPES_PATH = "${shared-mime-info}/share/mime/packages/freedesktop.org.xml";
};
mini_magick = attrs: {
postInstall = ''
installPath=$(cat $out/nix-support/gem-meta/install-path)
echo -e "\nENV['PATH'] += ':${graphicsmagick}/bin'\n" >> $installPath/lib/mini_magick/configuration.rb
'';
};
do_sqlite3 = attrs: {
buildInputs = [ sqlite ];
};
eventmachine = attrs: {
buildInputs = [ openssl ];
};
exif = attrs: {
buildFlags = [ "--with-exif-dir=${libexif}" ];
buildInputs = [ libexif ];
};
ffi = attrs: {
nativeBuildInputs = [ pkg-config ];
buildInputs = [ libffi ];
};
gdk_pixbuf2 = attrs: {
nativeBuildInputs = [ pkg-config bundler rake ]
++ lib.optionals stdenv.isDarwin [ DarwinTools ];
propagatedBuildInputs = [ gobject-introspection wrapGAppsHook gdk-pixbuf ];
};
gpgme = attrs: {
buildInputs = [ gpgme ];
buildFlags = [ "--use-system-libraries" ];
};
gio2 = attrs: {
nativeBuildInputs = [ pkg-config ]
++ lib.optionals stdenv.isDarwin [ DarwinTools ];
buildInputs = [ gtk2 pcre gobject-introspection ] ++ lib.optionals stdenv.isLinux [ util-linux libselinux libsepol ];
};
gitlab-markup = attrs: { meta.priority = 1; };
gitlab-pg_query = attrs: lib.optionalAttrs (attrs.version == "1.3.1") {
dontBuild = false;
postPatch = ''
sed -i "s;'https://codeload.github.com.*';'${fetchurl {
url = "https://codeload.github.com/lfittl/libpg_query/tar.gz/10-1.0.3";
sha256 = "0jfij8apzxsdabl70j42xgd5f3ka1gdcrk764nccp66164gpcchk";
}}';" ext/pg_query/extconf.rb
'';
};
pg_query = attrs: lib.optionalAttrs (attrs.version == "2.0.2") {
dontBuild = false;
postPatch = ''
sed -i "s;'https://codeload.github.com.*';'${fetchurl {
url = "https://codeload.github.com/lfittl/libpg_query/tar.gz/13-2.0.2";
sha256 = "0ms2s6hmy8qyzv4g1hj4i2p5fws1v8lrj73b2knwbp2ipd45yj7y";
}}';" ext/pg_query/extconf.rb
'';
} // lib.optionalAttrs (attrs.version == "1.3.0") {
# Needed for gitlab
dontBuild = false;
postPatch = ''
sed -i "s;'https://codeload.github.com.*';'${fetchurl {
url = "https://codeload.github.com/lfittl/libpg_query/tar.gz/10-1.0.4";
sha256 = "0f0kshhai0pnkqj0w4kgz3fssnvwidllc31n1fysxjjzdqlr1k48";
}}';" ext/pg_query/extconf.rb
'';
};
glib2 = attrs: {
nativeBuildInputs = [ pkg-config ]
++ lib.optionals stdenv.isDarwin [ DarwinTools ];
buildInputs = [ gtk2 pcre ];
};
gtk2 = attrs: {
nativeBuildInputs = [
binutils pkg-config
] ++ lib.optionals stdenv.isLinux [
util-linux libselinux libsepol
] ++ lib.optionals stdenv.isDarwin [ DarwinTools ];
propagatedBuildInputs = [
atk
gdk-pixbuf
fribidi
gobject-introspection
gtk2
harfbuzz
libdatrie
libthai
pcre
xorg.libpthreadstubs
xorg.libXdmcp
];
dontStrip = stdenv.isDarwin;
};
gobject-introspection = attrs: {
nativeBuildInputs = [ pkg-config pcre ]
++ lib.optionals stdenv.isDarwin [ DarwinTools ];
propagatedBuildInputs = [ gobject-introspection wrapGAppsHook glib ];
};
grpc = attrs: {
nativeBuildInputs = [ pkg-config ] ++ lib.optional stdenv.isDarwin libtool;
buildInputs = [ openssl ];
hardeningDisable = [ "format" ];
NIX_CFLAGS_COMPILE = toString [
"-Wno-error=stringop-overflow"
"-Wno-error=implicit-fallthrough"
"-Wno-error=sizeof-pointer-memaccess"
"-Wno-error=cast-function-type"
"-Wno-error=class-memaccess"
"-Wno-error=ignored-qualifiers"
"-Wno-error=tautological-compare"
"-Wno-error=stringop-truncation"
];
dontBuild = false;
postPatch = ''
substituteInPlace Makefile \
--replace '-Wno-invalid-source-encoding' ""
'' + lib.optionalString stdenv.isDarwin ''
substituteInPlace src/ruby/ext/grpc/extconf.rb \
--replace "ENV['AR'] = 'libtool -o' if RUBY_PLATFORM =~ /darwin/" ""
'';
};
hitimes = attrs: {
buildInputs = lib.optionals stdenv.isDarwin [ CoreServices ];
};
iconv = attrs: {
buildFlags = lib.optional stdenv.isDarwin "--with-iconv-dir=${libiconv}";
};
idn-ruby = attrs: {
buildInputs = [ libidn ];
};
# disable bundle install as it can't install anything in addition to what is
# specified in pkgs/applications/misc/jekyll/Gemfile anyway. Also do chmod_R
# to compensate for read-only files in site_template in nix store.
jekyll = attrs: {
postInstall = ''
installPath=$(cat $out/nix-support/gem-meta/install-path)
sed -i $installPath/lib/jekyll/commands/new.rb \
-e 's@Exec.run("bundle", "install"@Exec.run("true"@' \
-e 's@FileUtils.cp_r site_template + "/.", path@FileUtils.cp_r site_template + "/.", path; FileUtils.chmod_R "u+w", path@'
'';
};
# note that you need version >= v3.16.14.8,
# otherwise the gem will fail to link to the libv8 binary.
# see: https://github.com/cowboyd/libv8/pull/161
libv8 = attrs: {
buildInputs = [ which v8 python2 ];
buildFlags = [ "--with-system-v8=true" ];
dontBuild = false;
postPatch = ''
substituteInPlace ext/libv8/extconf.rb \
--replace "location = Libv8::Location::Vendor.new" \
"location = Libv8::Location::System.new"
'';
};
execjs = attrs: {
propagatedBuildInputs = [ v8 ];
};
libxml-ruby = attrs: {
buildFlags = [
"--with-xml2-lib=${libxml2.out}/lib"
"--with-xml2-include=${libxml2.dev}/include/libxml2"
];
};
mathematical = attrs: {
nativeBuildInputs = [
ruby
cmake
bison
flex
pkg-config
python3
patchelf
];
buildInputs = [
cairo
fribidi
gdk-pixbuf
glib
libxml2
pango
];
strictDeps = true;
# The ruby build script takes care of this
dontUseCmakeConfigure = true;
postInstall = ''
# Reduce output size by a lot, and remove some unnecessary references.
# The ext directory should only be required at build time, so
# can be deleted now.
rm -r $out/${ruby.gemPath}/gems/mathematical-${attrs.version}/ext \
$out/${ruby.gemPath}/extensions/*/*/mathematical-${attrs.version}/gem_make.out
'';
# For some reason 'mathematical.so' is missing cairo, glib, and
# lasem in its RPATH, add them explicitly here
postFixup = lib.optionalString stdenv.isLinux ''
soPath="$out/${ruby.gemPath}/gems/mathematical-${attrs.version}/lib/mathematical/mathematical.so"
rpath="$(patchelf --print-rpath "$soPath")"
patchelf --set-rpath "${lib.makeLibraryPath [ lasem glib cairo ]}:$rpath" "$soPath"
patchelf --replace-needed liblasem.so liblasem-0.4.so "$soPath"
'';
};
magic = attrs: {
buildInputs = [ file ];
postInstall = ''
installPath=$(cat $out/nix-support/gem-meta/install-path)
sed -e 's@ENV\["MAGIC_LIB"\] ||@ENV\["MAGIC_LIB"\] || "${file}/lib/libmagic.so" ||@' -i $installPath/lib/magic/api.rb
'';
};
maxmind_geoip2 = attrs: {
buildFlags = [ "--with-maxminddb-lib=${libmaxminddb}/lib" "--with-maxminddb-include=${libmaxminddb}/include" ];
};
metasploit-framework = attrs: {
preInstall = ''
export HOME=$TMPDIR
'';
};
msgpack = attrs: {
buildInputs = [ msgpack ];
};
mysql = attrs: {
buildInputs = [ libmysqlclient zlib openssl ];
};
mysql2 = attrs: {
buildInputs = [ libmysqlclient zlib openssl ];
};
ncursesw = attrs: {
buildInputs = [ ncurses ];
buildFlags = [
"--with-cflags=-I${ncurses.dev}/include"
"--with-ldflags=-L${ncurses.out}/lib"
];
};
nokogiri = attrs: {
buildFlags = [
"--use-system-libraries"
"--with-zlib-lib=${zlib.out}/lib"
"--with-zlib-include=${zlib.dev}/include"
"--with-xml2-lib=${libxml2.out}/lib"
"--with-xml2-include=${libxml2.dev}/include/libxml2"
"--with-xslt-lib=${libxslt.out}/lib"
"--with-xslt-include=${libxslt.dev}/include"
"--with-exslt-lib=${libxslt.out}/lib"
"--with-exslt-include=${libxslt.dev}/include"
] ++ lib.optionals stdenv.isDarwin [
"--with-iconv-dir=${libiconv}"
"--with-opt-include=${libiconv}/include"
];
};
openssl = attrs: {
buildInputs = [ openssl ];
};
opus-ruby = attrs: {
dontBuild = false;
postPatch = ''
substituteInPlace lib/opus-ruby.rb \
--replace "ffi_lib 'opus'" \
"ffi_lib '${libopus}/lib/libopus${stdenv.hostPlatform.extensions.sharedLibrary}'"
'';
};
ovirt-engine-sdk = attrs: {
buildInputs = [ curl libxml2 ];
};
pango = attrs: {
nativeBuildInputs = [
pkg-config
fribidi
harfbuzz
pcre
xorg.libpthreadstubs
xorg.libXdmcp
] ++ lib.optionals stdenv.isDarwin [ DarwinTools ];
buildInputs = [ libdatrie libthai ]
++ lib.optionals stdenv.isLinux [ libselinux libsepol util-linux ];
propagatedBuildInputs = [ gobject-introspection wrapGAppsHook gtk2 ];
};
patron = attrs: {
buildInputs = [ curl ];
};
pcaprub = attrs: {
buildInputs = [ libpcap ];
};
pg = attrs: {
buildFlags = [
"--with-pg-config=${postgresql}/bin/pg_config"
];
};
puma = attrs: {
buildInputs = [ openssl ];
};
rainbow = attrs: {
buildInputs = [ rainbow_rake ];
};
rbczmq = { ... }: {
buildInputs = [ zeromq czmq ];
buildFlags = [ "--with-system-libs" ];
};
rbnacl = spec:
if lib.versionOlder spec.version "6.0.0" then {
postInstall = ''
sed -i $(cat $out/nix-support/gem-meta/install-path)/lib/rbnacl.rb -e "2a \
RBNACL_LIBSODIUM_GEM_LIB_PATH = '${libsodium.out}/lib/libsodium${stdenv.hostPlatform.extensions.sharedLibrary}'
"
'';
} else {
dontBuild = false;
postPatch = ''
substituteInPlace lib/rbnacl/sodium.rb \
--replace 'ffi_lib ["sodium"' \
'ffi_lib ["${libsodium}/lib/libsodium${stdenv.hostPlatform.extensions.sharedLibrary}"'
'';
};
re2 = attrs: {
buildInputs = [ re2 ];
};
rmagick = attrs: {
nativeBuildInputs = [ pkg-config ];
buildInputs = [ imagemagick which ];
};
rpam2 = attrs: {
buildInputs = [ linux-pam ];
};
ruby-libvirt = attrs: {
buildInputs = [ libvirt pkg-config ];
buildFlags = [
"--with-libvirt-include=${libvirt}/include"
"--with-libvirt-lib=${libvirt}/lib"
];
};
ruby-lxc = attrs: {
buildInputs = [ lxc ];
};
ruby-terminfo = attrs: {
buildInputs = [ ncurses ];
buildFlags = [
"--with-cflags=-I${ncurses.dev}/include"
"--with-ldflags=-L${ncurses.out}/lib"
];
};
ruby-vips = attrs: {
postInstall = ''
cd "$(cat $out/nix-support/gem-meta/install-path)"
substituteInPlace lib/vips.rb \
--replace 'library_name("vips", 42)' '"${lib.getLib vips}/lib/libvips${stdenv.hostPlatform.extensions.sharedLibrary}"' \
--replace 'library_name("glib-2.0", 0)' '"${glib.out}/lib/libglib-2.0${stdenv.hostPlatform.extensions.sharedLibrary}"' \
--replace 'library_name("gobject-2.0", 0)' '"${glib.out}/lib/libgobject-2.0${stdenv.hostPlatform.extensions.sharedLibrary}"'
'';
};
rugged = attrs: {
nativeBuildInputs = [ cmake pkg-config which ] ++ lib.optional stdenv.isDarwin libiconv;
buildInputs = [ openssl libssh2 zlib ];
dontUseCmakeConfigure = true;
};
sassc = attrs: {
nativeBuildInputs = [ rake ];
dontBuild = false;
SASS_LIBSASS_PATH = toString libsass;
postPatch = ''
substituteInPlace lib/sassc/native.rb \
--replace 'gem_root = spec.gem_dir' 'gem_root = File.join(__dir__, "../../")'
'';
} // (lib.optionalAttrs stdenv.isDarwin {
# https://github.com/NixOS/nixpkgs/issues/19098
buildFlags = [ "--disable-lto" ];
});
scrypt = attrs: lib.optionalAttrs stdenv.isDarwin {
dontBuild = false;
postPatch = ''
sed -i -e "s/-arch i386//" Rakefile ext/scrypt/Rakefile
'';
};
semian = attrs: {
buildInputs = [ openssl ];
};
sequel_pg = attrs: {
buildInputs = [ postgresql ];
};
snappy = attrs: {
buildInputs = [ args.snappy ];
};
sqlite3 = attrs: {
buildFlags = [
"--with-sqlite3-include=${sqlite.dev}/include"
"--with-sqlite3-lib=${sqlite.out}/lib"
];
};
rb-readline = attrs: {
dontBuild = false;
postPatch = ''
substituteInPlace lib/rbreadline.rb \
--replace 'infocmp' '${ncurses}/bin/infocmp'
'';
};
taglib-ruby = attrs: {
buildInputs = [ taglib ];
};
timfel-krb5-auth = attrs: {
buildInputs = [ libkrb5 ];
};
tiny_tds = attrs: {
nativeBuildInputs = [ pkg-config openssl ];
buildInputs = [ freetds ];
};
typhoeus = attrs: {
buildInputs = [ curl ];
};
tzinfo = attrs: lib.optionalAttrs (lib.versionAtLeast attrs.version "1.0") {
dontBuild = false;
postPatch =
let
path = if lib.versionAtLeast attrs.version "2.0"
then "lib/tzinfo/data_sources/zoneinfo_data_source.rb"
else "lib/tzinfo/zoneinfo_data_source.rb";
in
''
substituteInPlace ${path} \
--replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo"
'';
};
uuid4r = attrs: {
buildInputs = [ which libossp_uuid ];
};
xapian-ruby = attrs: {
# use the system xapian
dontBuild = false;
nativeBuildInputs = [ rake pkg-config bundler ];
buildInputs = [ xapian zlib ];
postPatch = ''
cp ${./xapian-Rakefile} Rakefile
'';
preInstall = ''
export XAPIAN_CONFIG=${xapian}/bin/xapian-config
'';
};
zlib = attrs: {
buildInputs = [ zlib ];
};
zookeeper = attrs: {
buildInputs = lib.optionals stdenv.isDarwin [ cctools ];
};
}

View file

@ -0,0 +1,14 @@
diff --git a/ext/extconf.rb b/ext/extconf.rb
index 30764cb..b87ac2b 100644
--- a/ext/extconf.rb
+++ b/ext/extconf.rb
@@ -46,4 +46,9 @@ if /mswin/.match RbConfig::CONFIG['host_os']
$defs.push("-Dinline=__inline")
end
+$srcs = %w[
+ rdiscount.c
+]
+have_library('markdown')
+
create_makefile('rdiscount')

View file

@ -0,0 +1,33 @@
# encoding: utf-8
# Install the xapian binaries into the lib folder of the gem
require 'rbconfig'
c = RbConfig::CONFIG
source_dir = 'xapian_source'
bindings = Dir["#{source_dir}/xapian-bindings-*"].first
bindings = File.basename(bindings, ".tar.xz")
task :default do
sh "tar -xJf #{source_dir}/#{bindings}.tar.xz"
prefix = Dir.pwd
ENV['LDFLAGS'] = "-L#{prefix}/lib"
sh "mkdir -p lib"
Dir.chdir bindings do
ENV['RUBY'] ||= "#{c['bindir']}/#{c['RUBY_INSTALL_NAME']}"
sh "./configure --prefix=#{prefix} --exec-prefix=#{prefix} --with-ruby"
sh "make clean all"
end
sh "cp -r #{bindings}/ruby/.libs/_xapian.* lib"
sh "cp #{bindings}/ruby/xapian.rb lib"
sh "rm lib/*.la"
sh "rm lib/*.lai"
sh "rm -R #{bindings}"
sh "rm -R #{source_dir}"
end

View file

@ -0,0 +1,251 @@
# This builds gems in a way that is compatible with bundler.
#
# Bundler installs gems from git sources _very_ differently from how RubyGems
# installes gem packages, though they both install gem packages similarly.
#
# We monkey-patch Bundler to remove any impurities and then drive its internals
# to install git gems.
#
# For the sake of simplicity, gem packages are installed with the standard `gem`
# program.
#
# Note that bundler does not support multiple prefixes; it assumes that all
# gems are installed in a common prefix, and has no support for specifying
# otherwise. Therefore, if you want to be able to use the resulting derivations
# with bundler, you need to create a symlink forrest first, which is what
# `bundlerEnv` does for you.
#
# Normal gem packages can be used outside of bundler; a binstub is created in
# $out/bin.
{ lib, fetchurl, fetchgit, makeWrapper, gitMinimal, darwin
, ruby, bundler
} @ defs:
lib.makeOverridable (
{ name ? null
, gemName
, version ? null
, type ? "gem"
, document ? [] # e.g. [ "ri" "rdoc" ]
, platform ? "ruby"
, ruby ? defs.ruby
, stdenv ? ruby.stdenv
, namePrefix ? (let
rubyName = builtins.parseDrvName ruby.name;
in "${rubyName.name}${rubyName.version}-")
, buildInputs ? []
, meta ? {}
, patches ? []
, gemPath ? []
, dontStrip ? false
# Assume we don't have to build unless strictly necessary (e.g. the source is a
# git checkout).
# If you need to apply patches, make sure to set `dontBuild = false`;
, dontBuild ? true
, dontInstallManpages ? false
, propagatedBuildInputs ? []
, propagatedUserEnvPkgs ? []
, buildFlags ? []
, passthru ? {}
# bundler expects gems to be stored in the cache directory for certain actions
# such as `bundler install --redownload`.
# At the cost of increasing the store size, you can keep the gems to have closer
# alignment with what Bundler expects.
, keepGemCache ? false
, ...} @ attrs:
let
src = attrs.src or (
if type == "gem" then
fetchurl {
urls = map (
remote: "${remote}/gems/${gemName}-${version}.gem"
) (attrs.source.remotes or [ "https://rubygems.org" ]);
inherit (attrs.source) sha256;
}
else if type == "git" then
fetchgit {
inherit (attrs.source) url rev sha256 fetchSubmodules;
}
else if type == "url" then
fetchurl attrs.source
else
throw "buildRubyGem: don't know how to build a gem of type \"${type}\""
);
documentFlag =
if document == []
then "-N"
else "--document ${lib.concatStringsSep "," document}";
in
stdenv.mkDerivation ((builtins.removeAttrs attrs ["source"]) // {
inherit ruby;
inherit dontBuild;
inherit dontStrip;
inherit type;
buildInputs = [
ruby makeWrapper
] ++ lib.optionals (type == "git") [ gitMinimal ]
++ lib.optionals (type != "gem") [ bundler ]
++ lib.optional stdenv.isDarwin darwin.libobjc
++ buildInputs;
#name = builtins.trace (attrs.name or "no attr.name" ) "${namePrefix}${gemName}-${version}";
name = attrs.name or "${namePrefix}${gemName}-${version}";
inherit src;
unpackPhase = attrs.unpackPhase or ''
runHook preUnpack
if [[ -f $src && $src == *.gem ]]; then
if [[ -z "''${dontBuild-}" ]]; then
# we won't know the name of the directory that RubyGems creates,
# so we'll just use a glob to find it and move it over.
gempkg="$src"
sourceRoot=source
gem unpack $gempkg --target=container
cp -r container/* $sourceRoot
rm -r container
# copy out the original gemspec, for convenience during patching /
# overrides.
gem specification $gempkg --ruby > original.gemspec
gemspec=$(readlink -f .)/original.gemspec
else
gempkg="$src"
fi
else
# Fall back to the original thing for everything else.
dontBuild=""
preUnpack="" postUnpack="" unpackPhase
fi
runHook postUnpack
'';
# As of ruby 3.0, ruby headers require -fdeclspec when building with clang
# Introduced in https://github.com/ruby/ruby/commit/0958e19ffb047781fe1506760c7cbd8d7fe74e57
NIX_CFLAGS_COMPILE = lib.optionals (stdenv.cc.isClang && lib.versionAtLeast ruby.version.major "3") [
"-fdeclspec"
];
buildPhase = attrs.buildPhase or ''
runHook preBuild
if [[ "$type" == "gem" ]]; then
if [[ -z "$gemspec" ]]; then
gemspec="$(find . -name '*.gemspec')"
echo "found the following gemspecs:"
echo "$gemspec"
gemspec="$(echo "$gemspec" | head -n1)"
fi
exec 3>&1
output="$(gem build $gemspec | tee >(cat - >&3))"
exec 3>&-
gempkg=$(echo "$output" | grep -oP 'File: \K(.*)')
echo "gem package built: $gempkg"
elif [[ "$type" == "git" ]]; then
git init
# remove variations to improve the likelihood of a bit-reproducible output
rm -rf .git/logs/ .git/hooks/ .git/index .git/FETCH_HEAD .git/ORIG_HEAD .git/refs/remotes/origin/HEAD .git/config
# support `git ls-files`
git add .
fi
runHook postBuild
'';
# Note:
# We really do need to keep the $out/${ruby.gemPath}/cache.
# This is very important in order for many parts of RubyGems/Bundler to not blow up.
# See https://github.com/bundler/bundler/issues/3327
installPhase = attrs.installPhase or ''
runHook preInstall
export GEM_HOME=$out/${ruby.gemPath}
mkdir -p $GEM_HOME
echo "buildFlags: $buildFlags"
${lib.optionalString (type == "url") ''
ruby ${./nix-bundle-install.rb} \
"path" \
'${gemName}' \
'${version}' \
'${lib.escapeShellArgs buildFlags}'
''}
${lib.optionalString (type == "git") ''
ruby ${./nix-bundle-install.rb} \
"git" \
'${gemName}' \
'${version}' \
'${lib.escapeShellArgs buildFlags}' \
'${attrs.source.url}' \
'.' \
'${attrs.source.rev}'
''}
${lib.optionalString (type == "gem") ''
if [[ -z "$gempkg" ]]; then
echo "failure: \$gempkg path unspecified" 1>&2
exit 1
elif [[ ! -f "$gempkg" ]]; then
echo "failure: \$gempkg path invalid" 1>&2
exit 1
fi
gem install \
--local \
--force \
--http-proxy 'http://nodtd.invalid' \
--ignore-dependencies \
--install-dir "$GEM_HOME" \
--build-root '/' \
--backtrace \
--no-env-shebang \
${documentFlag} \
$gempkg $gemFlags -- $buildFlags
# looks like useless files which break build repeatability and consume space
pushd $out/${ruby.gemPath}
find doc/ -iname created.rid -delete -print
find gems/*/ext/ extensions/ \( -iname Makefile -o -iname mkmf.log -o -iname gem_make.out \) -delete -print
${if keepGemCache then "" else "rm -fvr cache"}
popd
# write out metadata and binstubs
spec=$(echo $out/${ruby.gemPath}/specifications/*.gemspec)
ruby ${./gem-post-build.rb} "$spec"
''}
${lib.optionalString (!dontInstallManpages) ''
for section in {1..9}; do
mandir="$out/share/man/man$section"
find $out/lib \( -wholename "*/man/*.$section" -o -wholename "*/man/man$section/*.$section" \) \
-execdir mkdir -p $mandir \; -execdir cp '{}' $mandir \;
done
''}
runHook postInstall
'';
propagatedBuildInputs = gemPath ++ propagatedBuildInputs;
propagatedUserEnvPkgs = gemPath ++ propagatedUserEnvPkgs;
passthru = passthru // { isRubyGem = true; };
meta = {
# default to Ruby's platforms
platforms = ruby.meta.platforms;
} // meta;
})
)

View file

@ -0,0 +1,81 @@
require 'rbconfig'
require 'rubygems'
require 'rubygems/specification'
require 'fileutils'
ruby = File.join(ENV["ruby"], "bin", RbConfig::CONFIG['ruby_install_name'])
out = ENV["out"]
bin_path = File.join(ENV["out"], "bin")
gem_home = ENV["GEM_HOME"]
gem_path = ENV["GEM_PATH"].split(File::PATH_SEPARATOR).uniq
install_path = Dir.glob("#{gem_home}/gems/*").first
gemspec_path = ARGV[0]
if defined?(Encoding.default_internal)
Encoding.default_internal = Encoding::UTF_8
Encoding.default_external = Encoding::UTF_8
end
gemspec_content = File.read(gemspec_path)
spec = nil
if gemspec_content[0..2] == "---" # YAML header
spec = Gem::Specification.from_yaml(gemspec_content)
else
spec = Gem::Specification.load(gemspec_path)
end
FileUtils.mkdir_p("#{out}/nix-support")
# write meta-data
meta = "#{out}/nix-support/gem-meta"
FileUtils.mkdir_p(meta)
FileUtils.ln_s(gemspec_path, "#{meta}/spec")
File.open("#{meta}/name", "w") do |f|
f.write(spec.name)
end
File.open("#{meta}/install-path", "w") do |f|
f.write(install_path)
end
File.open("#{meta}/require-paths", "w") do |f|
f.write(spec.require_paths.join(" "))
end
File.open("#{meta}/executables", "w") do |f|
f.write(spec.executables.join(" "))
end
# add this gem to the GEM_PATH for dependencies
File.open("#{out}/nix-support/setup-hook", "a") do |f|
f.puts("addToSearchPath GEM_PATH #{gem_home}")
spec.require_paths.each do |dir|
f.puts("addToSearchPath RUBYLIB #{install_path}/#{dir}")
end
end
# create regular rubygems binstubs
FileUtils.mkdir_p(bin_path)
spec.executables.each do |exe|
File.open("#{bin_path}/#{exe}", "w") do |f|
f.write(<<-EOF)
#!#{ruby}
#
# This file was generated by Nix.
#
# The application '#{exe}' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
Gem.paths = {
'GEM_PATH' => (
ENV['GEM_PATH'].to_s.split(File::PATH_SEPARATOR) +
#{([gem_home] + gem_path).to_s}
).join(File::PATH_SEPARATOR)
}
load Gem.activate_bin_path(#{spec.name.inspect}, #{exe.inspect}, #{spec.version.to_s.inspect})
EOF
end
FileUtils.chmod("+x", "#{bin_path}/#{exe}")
end

View file

@ -0,0 +1,181 @@
require 'rbconfig'
require 'bundler/vendored_thor'
require 'bundler'
require 'rubygems/command'
require 'fileutils'
require 'pathname'
require 'tmpdir'
require 'shellwords'
if defined?(Encoding.default_internal)
Encoding.default_internal = Encoding::UTF_8
Encoding.default_external = Encoding::UTF_8
end
# Options:
#
# type - installation type, either "git" or "path"
# name - the gem name
# version - gem version
# build-flags - build arguments
#
# Git-only options:
#
# uri - git repo uri
# repo - path to local checkout
# ref - the commit hash
ruby = File.join(ENV["ruby"], "bin", RbConfig::CONFIG['ruby_install_name'])
out = ENV["out"]
bin_dir = File.join(ENV["out"], "bin")
type = ARGV[0]
name = ARGV[1]
version = ARGV[2]
build_flags = Shellwords.split(ARGV[3])
if type == "git"
uri = ARGV[4]
REPO = ARGV[5]
ref = ARGV[6]
end
# options to pass to bundler
options = {
"name" => name,
"version" => version,
}
if type == "path"
options.merge!({
"path" => Dir.pwd,
})
elsif type == "git"
options.merge!({
"uri" => uri,
"ref" => ref,
})
end
# Monkey-patch Bundler to use our local checkout.
# I wish we didn't have to do this, but bundler does not expose an API to do
# these kinds of things.
Bundler.module_eval do
def self.requires_sudo?
false
end
def self.root
# we don't have a Gemfile, so it doesn't make sense to try to make paths
# relative to the (non existent) parent directory thereof, so we give a
# nonsense path here.
Pathname.new("/no-root-path")
end
def self.bundle_path
Pathname.new(ENV["GEM_HOME"])
end
def self.locked_gems
nil
end
end
if type == "git"
Bundler::Source::Git.class_eval do
def allow_git_ops?
true
end
end
Bundler::Source::Git::GitProxy.class_eval do
def checkout
unless path.exist?
FileUtils.mkdir_p(path.dirname)
FileUtils.cp_r(File.join(REPO, ".git"), path)
system("chmod -R +w #{path}")
end
end
def copy_to(destination, submodules=false)
unless File.exist?(destination.join(".git"))
FileUtils.mkdir_p(destination.dirname)
FileUtils.cp_r(REPO, destination)
system("chmod -R +w #{destination}")
end
end
end
end
# UI
verbose = false
no_color = false
Bundler.ui = Bundler::UI::Shell.new({"no-color" => no_color})
Bundler.ui.level = "debug" if verbose
# Install
if type == "git"
source = Bundler::Source::Git.new(options)
else
source = Bundler::Source::Path.new(options)
end
spec = source.specs.search_all(name).first
source.install(spec, :build_args => build_flags)
msg = spec.post_install_message
if msg
Bundler.ui.confirm "Post-install message from #{name}:"
Bundler.ui.info msg
end
# Write out the binstubs
if spec.executables.any?
FileUtils.mkdir_p(bin_dir)
spec.executables.each do |exe|
wrapper = File.join(bin_dir, exe)
File.open(wrapper, "w") do |f|
f.write(<<-EOF)
#!#{ruby}
#
# This file was generated by Nix.
#
# The application '#{exe}' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path(#{spec.name.inspect}, #{exe.inspect})
EOF
end
FileUtils.chmod("+x", wrapper)
end
end
# Write out metadata
meta = "#{out}/nix-support/gem-meta"
FileUtils.mkdir_p(meta)
FileUtils.ln_s(spec.loaded_from.to_s, "#{meta}/spec")
File.open("#{meta}/name", "w") do |f|
f.write spec.name
end
if type == "git"
File.open("#{meta}/install-path", "w") do |f|
f.write source.install_path.to_s
end
end
File.open("#{meta}/require-paths", "w") do |f|
f.write spec.require_paths.join(" ")
end
File.open("#{meta}/executables", "w") do |f|
f.write spec.executables.join(" ")
end
# make the lib available during bundler/git installs
if type == "git"
File.open("#{out}/nix-support/setup-hook", "a") do |f|
spec.require_paths.each do |dir|
f.puts("addToSearchPath RUBYLIB #{source.install_path}/#{dir}")
end
end
end

View file

@ -0,0 +1,41 @@
{ lib, stdenv, fetchFromGitHub, bash, installShellFiles }:
stdenv.mkDerivation rec {
pname = "rbenv";
version = "1.2.0";
nativeBuildInputs = [ installShellFiles ];
src = fetchFromGitHub {
owner = "rbenv";
repo = "rbenv";
rev = "v${version}";
sha256 = "sha256-m/Yy5EK8pLTBFcsgKCrNvQrPFFIlYklXXZbjN4Nmm9c=";
};
postPatch = ''
patchShebangs src/configure
pushd src
'';
installPhase = ''
popd
mkdir -p $out/bin
mv libexec $out
ln -s $out/libexec/rbenv $out/bin/rbenv
installShellCompletion completions/rbenv.{bash,zsh}
'';
meta = with lib; {
description = "Groom your apps Ruby environment";
longDescription = ''
Use rbenv to pick a Ruby version for your application and guarantee that your development environment matches production.
Put rbenv to work with Bundler for painless Ruby upgrades and bulletproof deployments.
'';
homepage = "https://github.com/rbenv/rbenv";
license = licenses.mit;
maintainers = with maintainers; [ fzakaria ];
platforms = platforms.all;
};
}

View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -o xtrace
cd $(dirname $0)
find . -name text.nix
testfiles=$(find . -name test.nix)
nix-build -E "with import <nixpkgs> {}; callPackage testing/driver.nix { testFiles = [ $testfiles ]; }" --show-trace && cat result

View file

@ -0,0 +1,28 @@
{ test, lib, ...}:
{
equal = expected: actual:
if actual == expected then
(test.passed "= ${toString expected}") else
(test.failed (
"expected '${toString expected}'(${builtins.typeOf expected})"
+ " != "+
"actual '${toString actual}'(${builtins.typeOf actual})"
));
beASet = actual:
if builtins.isAttrs actual then
(test.passed "is a set") else
(test.failed "is not a set, was ${builtins.typeOf actual}: ${toString actual}");
haveKeys = expected: actual:
if builtins.all
(ex: builtins.any (ac: ex == ac) (builtins.attrNames actual))
expected then
(test.passed "has expected keys") else
(test.failed "keys differ: expected: [${lib.concatStringsSep ";" expected}] actual: [${lib.concatStringsSep ";" (builtins.attrNames actual)}]");
havePrefix = expected: actual:
if lib.hasPrefix expected actual then
(test.passed "has prefix '${expected}'") else
(test.failed "prefix '${expected}' not found in '${actual}'");
}

View file

@ -0,0 +1,20 @@
/*
Run with:
nix-build -E 'with import <nixpkgs> { }; callPackage ./test.nix {}' --show-trace; and cat result
Confusingly, the ideal result ends with something like:
error: build of /nix/store/3245f3dcl2wxjs4rci7n069zjlz8qg85-test-results.tap.drv failed
*/
{ writeText, lib, callPackage, testFiles, ruby }@defs:
let
testTools = rec {
test = import ./testing.nix;
stubs = import ./stubs.nix defs;
should = import ./assertions.nix { inherit test lib; };
};
tap = import ./tap-support.nix;
results = builtins.concatLists (map (file: callPackage file testTools) testFiles);
in
writeText "test-results.tap" (tap.output results)

View file

@ -0,0 +1,30 @@
{ stdenv, lib, ruby, callPackage, ... }:
let
mkDerivation = {name, ...}@argSet:
derivation {
inherit name;
text = (builtins.toJSON (lib.filterAttrs ( n: v: builtins.any (x: x == n) ["name" "system"]) argSet));
builder = stdenv.shell;
args = [ "-c" "echo $(<$textPath) > $out"];
system = stdenv.hostPlatform.system;
passAsFile = ["text"];
};
fetchurl = {url?"", urls ? [],...}: "fetchurl:${if urls == [] then url else builtins.head urls}";
stdenv' = stdenv // {
inherit mkDerivation;
stubbed = true;
};
ruby' = ruby // {
stdenv = stdenv';
stubbed = true;
};
in
{
ruby = ruby';
buildRubyGem = callPackage ../gem {
inherit fetchurl;
ruby = ruby';
};
stdenv = stdenv';
}

View file

@ -0,0 +1,21 @@
with builtins;
let
withIndexes = list: genList (idx: (elemAt list idx) // {index = idx;}) (length list);
testLine = report: "${okStr report} ${toString (report.index + 1)} ${report.description}" + testDirective report + testYaml report;
# These are part of the TAP spec, not yet implemented.
#c.f. https://github.com/NixOS/nixpkgs/issues/27071
testDirective = report: "";
testYaml = report: "";
okStr = { result, ...}: if result == "pass" then "ok" else "not ok";
in
{
output = reports: ''
TAP version 13
1..${toString (length reports)}'' + (foldl' (l: r: l + "\n" + r) "" (map testLine (withIndexes reports))) + ''
# Finished at ${toString currentTime}
'';
}

View file

@ -0,0 +1,62 @@
with builtins;
let
/*
underTest = {
x = {
a = 1;
b = "2";
};
};
tests = [
(root: false)
{
x = [
(set: true)
{
a = (a: a > 1);
b = (b: b == "3");
}
];
}
];
results = run "Examples" underTest tests;
*/
passed = desc: {
result = "pass";
description = desc;
};
failed = desc: {
result = "failed";
description = desc;
};
prefixName = name: res: {
inherit (res) result;
description = "${name}: ${res.description}";
};
run = name: under: tests: if isList tests then
(concatLists (map (run name under) tests))
else if isAttrs tests then
(concatLists (map (
subName: run (name + "." + subName) (if hasAttr subName under then getAttr subName under else "<MISSING!>") (getAttr subName tests)
) (attrNames tests)))
else if isFunction tests then
let
res = tests under;
in
if isBool res then
[
(prefixName name (if tests under then passed "passed" else failed "failed"))
]
else
[ (prefixName name res) ]
else [
failed (name ": not a function, list or set")
];
in
{ inherit run passed failed; }

View file

@ -0,0 +1,152 @@
source 'https://rubygems.org' do
gem 'addressable'
gem 'ansi'
gem 'atk'
gem 'awesome_print'
gem 'bacon'
# gem 'bundler' already got a package for that
gem 'byebug'
gem 'cairo'
gem 'cairo-gobject'
gem 'camping'
# gem 'capybara-webkit' takes too long to build right now since webkit depends on ruby
gem 'charlock_holmes'
gem 'cld3'
gem 'cocoapods'
gem 'cocoapods-acknowledgements'
gem 'cocoapods-art'
gem 'cocoapods-browser'
gem 'cocoapods-clean'
gem 'cocoapods-clean_build_phases_scripts'
gem 'cocoapods-coverage'
gem 'cocoapods-deintegrate'
gem 'cocoapods-dependencies'
gem 'cocoapods-deploy'
gem 'cocoapods-downloader'
gem 'cocoapods-expert-difficulty'
gem 'cocoapods-fix-react-native'
gem 'cocoapods-generate'
gem 'cocoapods-git_url_rewriter'
gem 'cocoapods-keys'
gem 'cocoapods-open'
gem 'cocoapods-plugins'
gem 'cocoapods-search'
gem 'cocoapods-testing'
gem 'cocoapods-trunk'
gem 'cocoapods-try'
gem 'cocoapods-try-release-fix'
gem 'cocoapods-update-if-you-dare'
gem 'cocoapods-whitelist'
gem 'cocoapods-wholemodule'
gem 'coderay'
gem 'concurrent-ruby'
gem 'curb'
gem 'curses'
gem 'daemons'
gem 'dep-selector-libgecode'
gem 'digest-sha3'
gem 'domain_name'
gem 'do_sqlite3'
gem 'ethon'
gem 'eventmachine'
gem 'excon'
gem 'faraday'
gem 'ffi'
gem 'ffi-rzmq-core'
gem 'fog-dnsimple'
gem 'gdk_pixbuf2'
gem 'gio2'
gem 'github-pages'
gem 'gitlab-markup'
gem 'glib2'
# gem 'gobject-introspection' fails on require
gem 'gpgme'
# gem 'grpc' fails to build
gem 'gtk2'
gem 'hashie'
gem 'highline'
gem 'hike'
gem 'hitimes'
gem 'hpricot'
gem 'httpclient'
gem 'http-cookie'
gem 'iconv'
gem 'idn-ruby'
gem 'jbuilder'
gem 'jekyll'
gem 'jmespath'
gem 'jwt'
gem 'kramdown-rfc2629'
gem 'libv8'
gem 'libxml-ruby'
gem 'magic'
gem 'markaby'
gem 'method_source'
gem 'mini_magick'
gem 'msgpack'
gem 'mysql2'
# gem 'mysql' deprecated
gem 'ncursesw'
gem 'netrc'
gem 'net-scp'
gem 'net-ssh'
gem 'nokogiri'
gem 'opus-ruby'
gem 'ovirt-engine-sdk'
gem 'pandocomatic'
gem 'pango'
gem 'patron'
gem 'pcaprub'
gem 'pg'
gem 'prettier'
gem 'pry'
gem 'pry-byebug'
gem 'pry-doc'
gem 'public_suffix'
gem 'puma'
gem 'rails'
gem 'rainbow'
# gem 'rbczmq' deprecated
gem 'rbnacl'
gem 'rb-readline'
gem 're2'
gem 'redis'
gem 'redis-rack'
gem 'rest-client'
gem 'rmagick'
gem 'rpam2'
gem 'rspec'
gem 'rubocop'
gem 'rubocop-performance'
gem 'ruby-libvirt'
gem 'ruby-lxc'
gem 'ruby-progressbar'
gem 'ruby-terminfo'
gem 'ruby-vips'
gem 'rubyzip'
gem 'rugged'
gem 'sassc'
gem 'scrypt'
gem 'semian'
gem 'sequel'
gem 'sequel_pg'
gem 'solargraph'
gem 'simplecov'
gem 'sinatra'
gem 'slop'
gem 'snappy'
gem 'snmp'
gem 'sqlite3'
gem 'taglib-ruby'
gem 'thrift'
gem 'tilt'
gem 'tiny_tds'
gem 'treetop'
gem 'typhoeus'
gem 'tzinfo'
gem 'unf_ext'
gem 'uuid4r'
gem 'whois'
# gem 'xapian-ruby' doesn't contain ruby code
gem 'zookeeper'
end

View file

@ -0,0 +1,77 @@
{ stdenv, lib, buildEnv, buildRubyGem, ruby, gemConfig, makeWrapper }:
/*
Example usage:
nix-shell -E "(import <nixpkgs> {}).ruby.withPackages (pkgs: with pkgs; [ pry nokogiri ])"
You can also use this for writing ruby scripts that run anywhere that has nix
using a nix-shell shebang:
#!/usr/bin/env nix-shell
#!nix-shell -i ruby -p "ruby.withPackages (pkgs: with pkgs; [ pry nokogiri ])"
Run the following in the nixpkgs root directory to update the ruby-packages.nix:
./maintainers/scripts/update-ruby-packages
*/
let
functions = import ../bundled-common/functions.nix { inherit lib gemConfig; };
buildGems = gemset:
let
realGemset = if builtins.isAttrs gemset then gemset else import gemset;
builtGems =
lib.mapAttrs (name: initialAttrs:
let
attrs = functions.applyGemConfigs ({ inherit ruby; gemName = name; } // initialAttrs);
in
buildRubyGem (functions.composeGemAttrs ruby builtGems name attrs)
) realGemset;
in builtGems;
gems = buildGems (import ../../../top-level/ruby-packages.nix);
withPackages = selector:
let
selected = selector gems;
gemEnv = buildEnv {
name = "ruby-gems";
paths = selected;
pathsToLink = [ "/lib" "/bin" "/nix-support" ];
};
wrappedRuby = stdenv.mkDerivation {
name = "wrapped-${ruby.name}";
nativeBuildInputs = [ makeWrapper ];
buildCommand = ''
mkdir -p $out/bin
for i in ${ruby}/bin/*; do
makeWrapper "$i" $out/bin/$(basename "$i") --set GEM_PATH ${gemEnv}/${ruby.gemPath}
done
'';
};
in stdenv.mkDerivation {
name = "${ruby.name}-with-packages";
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ selected ruby ];
dontUnpack = true;
installPhase = ''
for i in ${ruby}/bin/* ${gemEnv}/bin/*; do
rm -f $out/bin/$(basename "$i")
makeWrapper "$i" $out/bin/$(basename "$i") --set GEM_PATH ${gemEnv}/${ruby.gemPath}
done
ln -s ${ruby}/nix-support $out/nix-support
'';
passthru = {
inherit wrappedRuby;
gems = selected;
};
};
in { inherit withPackages gems buildGems; }

View file

@ -0,0 +1,84 @@
let
cocoapod-plugin = name: ''
require "cocoapods"
require "#{Gem::Specification.find_by_name(%(${name})).gem_dir}/lib/cocoapods_plugin"
'';
in {
actioncable = [ "action_cable" ];
actionmailer = [ "action_mailer" ];
actionpack = [ "action_pack" ];
actionview = [ "action_view" ];
activejob = [ "active_job" ];
activemodel = [ "active_model" ];
activerecord = [ "active_record" ];
activestorage = [ "active_storage" ];
activesupport = [ "active_support" ];
atk = [ "atk" ];
CFPropertyList = [ "cfpropertylist" ];
cocoapods-acknowledgements = [ "cocoapods" "cocoapods_acknowledgements" ];
cocoapods-art = [ "cocoapods_art" ];
cocoapods-browser = [ "cocoapods" "cocoapods_plugin" ];
cocoapods-bugsnag = cocoapod-plugin "cocoapods-bugsnag";
cocoapods-clean = [ "cocoapods_clean" ];
cocoapods-coverage = [ "cocoapods_coverage" ];
cocoapods-deintegrate = [ ]; # used by cocoapods
cocoapods-dependencies = [ "cocoapods_dependencies" ];
cocoapods-deploy = cocoapod-plugin "cocoapods-deploy";
cocoapods-generate = cocoapod-plugin "cocoapods-generate";
cocoapods-git_url_rewriter = cocoapod-plugin "cocoapods-git_url_rewriter";
cocoapods-keys = []; # osx only cocoapod-plugin "cocoapods-keys";
cocoapods-open = [ "cocoapods" "cocoapods_plugin" ];
cocoapods-packager = [ "cocoapods_packager" ];
cocoapods-packager-pro = [ ]; # requires osx
cocoapods-plugins = [ "cocoapods_plugins" ];
cocoapods-sorted-search = [ ]; # requires osx
cocoapods-check = cocoapod-plugin "cocoapods-check";
cocoapods-disable-podfile-validations = cocoapod-plugin "cocoapods-disable-podfile-validations";
cocoapods-stats = [ "cocoapods_stats" ];
cocoapods-testing = [ "cocoapods_testing" ];
cocoapods-trunk = [ "cocoapods_trunk" ];
cocoapods-try = [ "cocoapods_try" ];
cocoapods-try-release-fix = cocoapod-plugin "cocoapods-try-release-fix";
digest-sha3 = [ "digest/sha3" ];
ffi-compiler = [ "ffi-compiler/loader" ];
fog-core = [ "fog/core" ];
fog-dnsimple = [ "fog/dnsimple" ];
fog-json = [ "fog/json" ];
forwardable-extended = [ "forwardable/extended" ];
gdk_pixbuf2 = [ "gdk_pixbuf2" ];
gitlab-markup = [ "github/markup" ];
gobject-introspection = [ "gobject-introspection" ];
gtk2 = [ ]; # requires display
idn-ruby = [ "idn" ];
jekyll-sass-converter = []; # tested through jekyll
libxml-ruby = [ "libxml" ];
multipart-post = [ "multipart_post" ];
unicode-display_width = [ "unicode/display_width" ];
nap = [ "rest" ];
net-scp = [ "net/scp" ];
net-ssh = [ "net/ssh" ];
nio4r = [ "nio" ];
osx_keychain = [ ]; # requires osx
ovirt-engine-sdk = [ "ovirtsdk4" ];
pango = [ "pango" ];
rack-test = [ "rack/test" ];
railties = [ "rails" ];
rspec-core = [ "rspec/core" ];
rspec-expectations = [ "rspec/expectations" ];
rspec-mocks = [ "rspec/mocks" ];
rspec-support = [ "rspec/support" ];
RubyInline = [ "inline" ];
ruby-libvirt = [ "libvirt" ];
ruby-lxc = [ "lxc" ];
ruby-macho = [ "macho" ];
ruby-terminfo = [ "terminfo" ];
rubyzip = [ "zip" ];
sequel_pg = [ "pg" "sequel" "sequel/adapters/postgresql" "sequel_pg" ];
simplecov-html = [ ]; # tested through simplecov
sinatra = [ "sinatra/base" ];
sprockets-rails = [ "sprockets/rails" ];
taglib-ruby = [ "taglib" ];
websocket-driver = [ "websocket/driver" ];
websocket-extensions = [ "websocket/extensions" ];
ZenTest = [ "zentest" ];
}

View file

@ -0,0 +1,46 @@
# a generic test suite for all gems for all ruby versions.
# use via nix-build.
let
pkgs = import ../../../.. {};
lib = pkgs.lib;
stdenv = pkgs.stdenv;
rubyVersions = with pkgs; [
ruby_2_7
];
gemTests =
(lib.mapAttrs
(name: gem: [ name ])
pkgs.ruby.gems) //
(import ./require_exceptions.nix);
tests = ruby:
lib.mapAttrs (name: gem:
let
test =
if builtins.isList gemTests.${name}
then pkgs.writeText "${name}.rb" ''
puts "${name} GEM_HOME: #{ENV['GEM_HOME']}"
${lib.concatStringsSep "\n" (map (n: "require '${n}'") gemTests.${name})}
''
else pkgs.writeText "${name}.rb" gemTests.${name};
deps = ruby.withPackages (g: [ g.${name} ]);
in stdenv.mkDerivation {
name = "test-gem-${ruby.name}-${name}";
buildInputs = [ deps ];
buildCommand = ''
INLINEDIR=$PWD ruby ${test}
touch $out
'';
}
) ruby.gems;
in
stdenv.mkDerivation {
name = "test-all-ruby-gems";
buildInputs = builtins.foldl' (sum: ruby: sum ++ ( builtins.attrValues (tests ruby) )) [] rubyVersions;
buildCommand = ''
touch $out
'';
}

View file

@ -0,0 +1,76 @@
#!/usr/bin/env ruby
# this is a quick and dirty test suite for easier analyzing of breakages in a
# manual testing.
# For automated testing use the test.nix
require 'fileutils'
class FakeGemfile
attr_reader :gems
def initialize
@gems = []
end
def source(_source, &block)
instance_exec(&block)
end
def gem(name)
@gems << name
end
end
gemfile = File.expand_path(File.join(__dir__, 'Gemfile'))
packages = FakeGemfile.new.instance_eval(File.read(gemfile), gemfile)
test_cases = packages.map { |pkg| [pkg, "require '#{pkg}'"] }.to_h
test_cases.merge!(
'digest-sha3' => "require 'digest/sha3'",
'gitlab-markup' => "require 'github/markup'",
'idn-ruby' => "require 'idn'",
'net-scp' => "require 'net/scp'",
'taglib-ruby' => "require 'taglib'",
'net-ssh' => "require 'net/ssh'",
'ruby-libvirt' => "require 'libvirt'",
'ruby-lxc' => "require 'lxc'",
'rubyzip' => "require 'zip'",
'sinatra' => "require 'sinatra/base'",
'libxml-ruby' => "require 'libxml'",
'ruby-terminfo' => "require 'terminfo'",
'ovirt-engine-sdk' => "require 'ovirtsdk4'",
'fog-dnsimple' => "require 'fog/dnsimple'"
)
test_cases['sequel_pg'] = <<~TEST
require 'pg'
require 'sequel'
require 'sequel/adapters/postgresql'
require 'sequel_pg'
TEST
tmpdir = File.expand_path(File.join(__dir__, 'tests'))
FileUtils.rm_rf(tmpdir)
FileUtils.mkdir_p(tmpdir)
failing = test_cases.reject do |name, test_case|
test_case = <<~SHELL
#!/usr/bin/env nix-shell
#!nix-shell -i ruby -E "(import ../../../.. {}).ruby.withPackages (r: [ r.#{name} ] )"
#{test_case}
SHELL
file = File.join(tmpdir, "#{name}_test.rb")
File.write(file, test_case)
FileUtils.chmod('u=wrx', file)
system(file) && FileUtils.rm(file)
end
exit if failing.empty?
puts "Following gems failed: #{failing.keys.join(' ')}"
puts "tests for failing gems remain in #{tmpdir}"
exit 1