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:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
185
pkgs/development/ruby-modules/bundled-common/default.nix
Normal file
185
pkgs/development/ruby-modules/bundled-common/default.nix
Normal 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
|
||||
93
pkgs/development/ruby-modules/bundled-common/functions.nix
Normal file
93
pkgs/development/ruby-modules/bundled-common/functions.nix
Normal 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 []);
|
||||
});
|
||||
}
|
||||
|
|
@ -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
|
||||
50
pkgs/development/ruby-modules/bundled-common/test.nix
Normal file
50
pkgs/development/ruby-modules/bundled-common/test.nix
Normal 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 == {}))
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue