lol

Starting to add tool builder. Extracting bundler file computation.

Judson c4fc70f5 e4bb4d47

+90 -11
+1 -1
pkgs/development/ruby-modules/bundled-common/default.nix
··· 7 7 { 8 8 name 9 9 , pname ? name 10 + , gemdir 10 11 , gemfile 11 12 , lockfile 12 13 , gemset 13 - , gemdir 14 14 , ruby ? defs.ruby 15 15 , gemConfig ? defaultGemConfig 16 16 , postBuild ? null
+20
pkgs/development/ruby-modules/bundled-common/functions.nix
··· 1 1 { lib, gemConfig, ... }: 2 2 rec { 3 + bundlerFiles = { 4 + gemfile ? null 5 + , lockfile ? null 6 + , gemset ? null 7 + , gemdir ? null 8 + , ... 9 + }: { 10 + gemfile = 11 + if gemfile == null then assert gemdir != null; gemdir + "/Gemfile" 12 + else gemfile; 13 + 14 + lockfile = 15 + if lockfile == null then assert gemdir != null; gemdir + "/Gemfile.lock" 16 + else lockfile; 17 + 18 + gemset = 19 + if gemset == null then assert gemdir != null; gemdir + "/gemset.nix" 20 + else gemset; 21 + }; 22 + 3 23 filterGemset = {ruby, groups,...}@env: gemset: lib.filterAttrs (name: attrs: platformMatches ruby attrs && groupMatches groups attrs) gemset; 4 24 5 25 platformMatches = {rubyEngine, version, ...}@ruby: attrs: (
+28 -1
pkgs/development/ruby-modules/bundled-common/test.nix
··· 7 7 functions = (import ./functions.nix testConfigs); 8 8 in 9 9 builtins.concatLists [ 10 - (test.run "Filter empty gemset" {} (set: functions.filterGemset {inherit ruby; groups = ["default"]; } set == {})) 10 + ( test.run "All set, no gemdir" (functions.bundlerFiles { 11 + gemfile = test/Gemfile; 12 + lockfile = test/Gemfile.lock; 13 + gemset = test/gemset.nix; 14 + }) { 15 + gemfile = should.equal test/Gemfile; 16 + lockfile = should.equal test/Gemfile.lock; 17 + gemset = should.equal test/gemset.nix; 18 + }) 19 + 20 + ( test.run "Just gemdir" (functions.bundlerFiles { 21 + gemdir = test/.; 22 + }) { 23 + gemfile = should.equal test/Gemfile; 24 + lockfile = should.equal test/Gemfile.lock; 25 + gemset = should.equal test/gemset.nix; 26 + }) 27 + 28 + ( test.run "Gemset and dir" (functions.bundlerFiles { 29 + gemdir = test/.; 30 + gemset = test/extraGemset.nix; 31 + }) { 32 + gemfile = should.equal test/Gemfile; 33 + lockfile = should.equal test/Gemfile.lock; 34 + gemset = should.equal test/extraGemset.nix; 35 + }) 36 + 37 + ( test.run "Filter empty gemset" {} (set: functions.filterGemset {inherit ruby; groups = ["default"]; } set == {})) 11 38 ( let gemSet = { test = { groups = ["x" "y"]; }; }; 12 39 in 13 40 test.run "Filter matches a group" gemSet (set: functions.filterGemset {inherit ruby; groups = ["y" "z"];} set == gemSet))
+2 -6
pkgs/development/ruby-modules/bundler-env/default.nix
··· 1 1 { stdenv, runCommand, writeText, writeScript, writeScriptBin, ruby, lib 2 2 , callPackage, defaultGemConfig, fetchurl, fetchgit, buildRubyGem, buildEnv 3 - , linkFarm 4 - , git 5 - , makeWrapper 6 - , bundler 7 - , tree 3 + , linkFarm, git, makeWrapper, bundler, tree 8 4 }@defs: 9 5 10 6 { name ? null ··· 13 9 , gemfile ? null 14 10 , lockfile ? null 15 11 , gemset ? null 12 + , groups ? ["default"] 16 13 , ruby ? defs.ruby 17 14 , gemConfig ? defaultGemConfig 18 15 , postBuild ? null 19 16 , document ? [] 20 17 , meta ? {} 21 - , groups ? ["default"] 22 18 , ignoreCollisions ? false 23 19 , ... 24 20 }@args:
+6 -2
pkgs/development/ruby-modules/testing/assertions.nix
··· 3 3 equal = expected: actual: 4 4 if actual == expected then 5 5 (test.passed "= ${toString expected}") else 6 - (test.failed "'${toString actual}'(${builtins.typeOf actual}) != '${toString expected}'(${builtins.typeOf expected})"); 6 + (test.failed ( 7 + "expected '${toString expected}'(${builtins.typeOf expected})" 8 + + " != "+ 9 + "actual '${toString actual}'(${builtins.typeOf actual})" 10 + )); 7 11 8 12 beASet = actual: 9 13 if builtins.isAttrs actual then ··· 15 19 (ex: builtins.any (ac: ex == ac) (builtins.attrNames actual)) 16 20 expected then 17 21 (test.passed "has expected keys") else 18 - (test.failed "keys differ: expected [${lib.concatStringsSep ";" expected}] have [${lib.concatStringsSep ";" (builtins.attrNames actual)}]"); 22 + (test.failed "keys differ: expected: [${lib.concatStringsSep ";" expected}] actual: [${lib.concatStringsSep ";" (builtins.attrNames actual)}]"); 19 23 20 24 havePrefix = expected: actual: 21 25 if lib.hasPrefix expected actual then
+1 -1
pkgs/development/ruby-modules/testing/tap-support.nix
··· 2 2 let 3 3 withIndexes = list: genList (idx: (elemAt list idx) // {index = idx;}) (length list); 4 4 5 - testLine = report: "${okStr report} ${toString report.index} ${report.description}" + testDirective report + testYaml report; 5 + testLine = report: "${okStr report} ${toString (report.index + 1)} ${report.description}" + testDirective report + testYaml report; 6 6 7 7 testDirective = report: ""; 8 8
+32
pkgs/development/ruby-modules/tool/default.nix
··· 1 + { stdenv }@defs: 2 + 3 + { 4 + name 5 + , gemdir 6 + , exes ? [] 7 + , scripts ? [] 8 + , postBuild 9 + }@args: 10 + 11 + let 12 + basicEnv = (callPackage ../bundled-common {}) (args // { inherit name gemdir; 13 + gemfile = gemfile'; 14 + lockfile = lockfile'; 15 + gemset = gemset'; 16 + }); 17 + 18 + args = removeAttrs args_ [ "name" "postBuild" ] 19 + // { inherit preferLocalBuild allowSubstitutes; }; # pass the defaults 20 + in 21 + runCommand name args '' 22 + mkdir -p $out; cd $out; 23 + ${(lib.concatMapStrings (x: "ln -s '${basicEnv}/bin/${x}' '${x}';\n") exes)} 24 + ${(lib.concatMapStrings (s: "makeWrapper ${out}/bin/$(basename ${s}) $srcdir/${s} " + 25 + "--set BUNDLE_GEMFILE ${basicEnv.confFiles}/Gemfile "+ 26 + "--set BUNDLE_PATH ${basicEnv}/${ruby.gemPath} "+ 27 + "--set BUNDLE_FROZEN 1 "+ 28 + "--set GEM_HOME ${basicEnv}/${ruby.gemPath} "+ 29 + "--set GEM_PATH ${basicEnv}/${ruby.gemPath} "+ 30 + "--run \"cd $srcdir\";\n") scripts)} 31 + ${postBuild} 32 + ''