Starting to add tool builder. Extracting bundler file computation.
This commit is contained in:
parent
e4bb4d4788
commit
c4fc70f53c
@ -7,10 +7,10 @@
|
|||||||
{
|
{
|
||||||
name
|
name
|
||||||
, pname ? name
|
, pname ? name
|
||||||
|
, gemdir
|
||||||
, gemfile
|
, gemfile
|
||||||
, lockfile
|
, lockfile
|
||||||
, gemset
|
, gemset
|
||||||
, gemdir
|
|
||||||
, ruby ? defs.ruby
|
, ruby ? defs.ruby
|
||||||
, gemConfig ? defaultGemConfig
|
, gemConfig ? defaultGemConfig
|
||||||
, postBuild ? null
|
, postBuild ? null
|
||||||
|
@ -1,5 +1,25 @@
|
|||||||
{ lib, gemConfig, ... }:
|
{ lib, gemConfig, ... }:
|
||||||
rec {
|
rec {
|
||||||
|
bundlerFiles = {
|
||||||
|
gemfile ? null
|
||||||
|
, lockfile ? null
|
||||||
|
, gemset ? null
|
||||||
|
, gemdir ? null
|
||||||
|
, ...
|
||||||
|
}: {
|
||||||
|
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,...}@env: gemset: lib.filterAttrs (name: attrs: platformMatches ruby attrs && groupMatches groups attrs) gemset;
|
filterGemset = {ruby, groups,...}@env: gemset: lib.filterAttrs (name: attrs: platformMatches ruby attrs && groupMatches groups attrs) gemset;
|
||||||
|
|
||||||
platformMatches = {rubyEngine, version, ...}@ruby: attrs: (
|
platformMatches = {rubyEngine, version, ...}@ruby: attrs: (
|
||||||
|
@ -7,7 +7,34 @@ let
|
|||||||
functions = (import ./functions.nix testConfigs);
|
functions = (import ./functions.nix testConfigs);
|
||||||
in
|
in
|
||||||
builtins.concatLists [
|
builtins.concatLists [
|
||||||
(test.run "Filter empty gemset" {} (set: functions.filterGemset {inherit ruby; groups = ["default"]; } set == {}))
|
( 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"]; }; };
|
( let gemSet = { test = { groups = ["x" "y"]; }; };
|
||||||
in
|
in
|
||||||
test.run "Filter matches a group" gemSet (set: functions.filterGemset {inherit ruby; groups = ["y" "z"];} set == gemSet))
|
test.run "Filter matches a group" gemSet (set: functions.filterGemset {inherit ruby; groups = ["y" "z"];} set == gemSet))
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
{ stdenv, runCommand, writeText, writeScript, writeScriptBin, ruby, lib
|
{ stdenv, runCommand, writeText, writeScript, writeScriptBin, ruby, lib
|
||||||
, callPackage, defaultGemConfig, fetchurl, fetchgit, buildRubyGem, buildEnv
|
, callPackage, defaultGemConfig, fetchurl, fetchgit, buildRubyGem, buildEnv
|
||||||
, linkFarm
|
, linkFarm, git, makeWrapper, bundler, tree
|
||||||
, git
|
|
||||||
, makeWrapper
|
|
||||||
, bundler
|
|
||||||
, tree
|
|
||||||
}@defs:
|
}@defs:
|
||||||
|
|
||||||
{ name ? null
|
{ name ? null
|
||||||
@ -13,12 +9,12 @@
|
|||||||
, gemfile ? null
|
, gemfile ? null
|
||||||
, lockfile ? null
|
, lockfile ? null
|
||||||
, gemset ? null
|
, gemset ? null
|
||||||
|
, groups ? ["default"]
|
||||||
, ruby ? defs.ruby
|
, ruby ? defs.ruby
|
||||||
, gemConfig ? defaultGemConfig
|
, gemConfig ? defaultGemConfig
|
||||||
, postBuild ? null
|
, postBuild ? null
|
||||||
, document ? []
|
, document ? []
|
||||||
, meta ? {}
|
, meta ? {}
|
||||||
, groups ? ["default"]
|
|
||||||
, ignoreCollisions ? false
|
, ignoreCollisions ? false
|
||||||
, ...
|
, ...
|
||||||
}@args:
|
}@args:
|
||||||
|
@ -3,7 +3,11 @@
|
|||||||
equal = expected: actual:
|
equal = expected: actual:
|
||||||
if actual == expected then
|
if actual == expected then
|
||||||
(test.passed "= ${toString expected}") else
|
(test.passed "= ${toString expected}") else
|
||||||
(test.failed "'${toString actual}'(${builtins.typeOf actual}) != '${toString expected}'(${builtins.typeOf expected})");
|
(test.failed (
|
||||||
|
"expected '${toString expected}'(${builtins.typeOf expected})"
|
||||||
|
+ " != "+
|
||||||
|
"actual '${toString actual}'(${builtins.typeOf actual})"
|
||||||
|
));
|
||||||
|
|
||||||
beASet = actual:
|
beASet = actual:
|
||||||
if builtins.isAttrs actual then
|
if builtins.isAttrs actual then
|
||||||
@ -15,7 +19,7 @@
|
|||||||
(ex: builtins.any (ac: ex == ac) (builtins.attrNames actual))
|
(ex: builtins.any (ac: ex == ac) (builtins.attrNames actual))
|
||||||
expected then
|
expected then
|
||||||
(test.passed "has expected keys") else
|
(test.passed "has expected keys") else
|
||||||
(test.failed "keys differ: expected [${lib.concatStringsSep ";" expected}] have [${lib.concatStringsSep ";" (builtins.attrNames actual)}]");
|
(test.failed "keys differ: expected: [${lib.concatStringsSep ";" expected}] actual: [${lib.concatStringsSep ";" (builtins.attrNames actual)}]");
|
||||||
|
|
||||||
havePrefix = expected: actual:
|
havePrefix = expected: actual:
|
||||||
if lib.hasPrefix expected actual then
|
if lib.hasPrefix expected actual then
|
||||||
|
@ -2,7 +2,7 @@ with builtins;
|
|||||||
let
|
let
|
||||||
withIndexes = list: genList (idx: (elemAt list idx) // {index = idx;}) (length list);
|
withIndexes = list: genList (idx: (elemAt list idx) // {index = idx;}) (length list);
|
||||||
|
|
||||||
testLine = report: "${okStr report} ${toString report.index} ${report.description}" + testDirective report + testYaml report;
|
testLine = report: "${okStr report} ${toString (report.index + 1)} ${report.description}" + testDirective report + testYaml report;
|
||||||
|
|
||||||
testDirective = report: "";
|
testDirective = report: "";
|
||||||
|
|
||||||
|
32
pkgs/development/ruby-modules/tool/default.nix
Normal file
32
pkgs/development/ruby-modules/tool/default.nix
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{ stdenv }@defs:
|
||||||
|
|
||||||
|
{
|
||||||
|
name
|
||||||
|
, gemdir
|
||||||
|
, exes ? []
|
||||||
|
, scripts ? []
|
||||||
|
, postBuild
|
||||||
|
}@args:
|
||||||
|
|
||||||
|
let
|
||||||
|
basicEnv = (callPackage ../bundled-common {}) (args // { inherit name gemdir;
|
||||||
|
gemfile = gemfile';
|
||||||
|
lockfile = lockfile';
|
||||||
|
gemset = gemset';
|
||||||
|
});
|
||||||
|
|
||||||
|
args = removeAttrs args_ [ "name" "postBuild" ]
|
||||||
|
// { inherit preferLocalBuild allowSubstitutes; }; # pass the defaults
|
||||||
|
in
|
||||||
|
runCommand name args ''
|
||||||
|
mkdir -p $out; cd $out;
|
||||||
|
${(lib.concatMapStrings (x: "ln -s '${basicEnv}/bin/${x}' '${x}';\n") exes)}
|
||||||
|
${(lib.concatMapStrings (s: "makeWrapper ${out}/bin/$(basename ${s}) $srcdir/${s} " +
|
||||||
|
"--set BUNDLE_GEMFILE ${basicEnv.confFiles}/Gemfile "+
|
||||||
|
"--set BUNDLE_PATH ${basicEnv}/${ruby.gemPath} "+
|
||||||
|
"--set BUNDLE_FROZEN 1 "+
|
||||||
|
"--set GEM_HOME ${basicEnv}/${ruby.gemPath} "+
|
||||||
|
"--set GEM_PATH ${basicEnv}/${ruby.gemPath} "+
|
||||||
|
"--run \"cd $srcdir\";\n") scripts)}
|
||||||
|
${postBuild}
|
||||||
|
''
|
Loading…
x
Reference in New Issue
Block a user