diff options
author | Alyssa Ross <hi@alyssa.is> | 2018-12-11 21:18:22 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2018-12-11 21:26:07 +0000 |
commit | 67b1265fb3d38ead5a57fee838405a2d997777c2 (patch) | |
tree | 0c127dd8432ca416db5c56f3460ec12e8cfaf746 /pkgs/development/ruby-modules/bundled-common | |
parent | ac19d5e34f384c66b71aecb921433acc5447bc51 (diff) | |
download | nixlib-67b1265fb3d38ead5a57fee838405a2d997777c2.tar nixlib-67b1265fb3d38ead5a57fee838405a2d997777c2.tar.gz nixlib-67b1265fb3d38ead5a57fee838405a2d997777c2.tar.bz2 nixlib-67b1265fb3d38ead5a57fee838405a2d997777c2.tar.lz nixlib-67b1265fb3d38ead5a57fee838405a2d997777c2.tar.xz nixlib-67b1265fb3d38ead5a57fee838405a2d997777c2.tar.zst nixlib-67b1265fb3d38ead5a57fee838405a2d997777c2.zip |
bundlerEnv: ensure dependencies always included
Suppose I have a Gemfile like this: source "https://rubygems.org" gem "actioncable" gem "websocket-driver", group: :test The gemset.nix generated by Bundix 2.4.1 will set ActionCable's groups to [ "default" ], and websocket-driver's to [ "test" ]. This means that the generated bundlerEnv wouldn't include websocket-driver unless the test group was included, even though it's required by the default group. This is arguably a bug in Bundix (websocket-driver's groups should probably be [ "default" "test" ] or just [ "default" ]), but there's no reason bundlerEnv should omit dependencies even given such an input -- it won't necessarily come from Bundix, and it would be good for bundlerEnv to do the right thing. To fix this, filterGemset is now a recursive function, that adds dependencies of gems in the group to the filtered gemset until it stabilises on the gems that match the required groups, and all of their recursive dependencies.
Diffstat (limited to 'pkgs/development/ruby-modules/bundled-common')
-rw-r--r-- | pkgs/development/ruby-modules/bundled-common/functions.nix | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/pkgs/development/ruby-modules/bundled-common/functions.nix b/pkgs/development/ruby-modules/bundled-common/functions.nix index b8e666a92f9a..81e2fa353295 100644 --- a/pkgs/development/ruby-modules/bundled-common/functions.nix +++ b/pkgs/development/ruby-modules/bundled-common/functions.nix @@ -1,5 +1,9 @@ { lib, gemConfig, ... }: -rec { + +let + inherit (lib) attrValues concatMap converge filterAttrs getAttrs; + +in rec { bundlerFiles = { gemfile ? null , lockfile ? null @@ -22,7 +26,19 @@ rec { else gemset; }; - filterGemset = {ruby, groups,...}: gemset: lib.filterAttrs (name: attrs: platformMatches ruby attrs && groupMatches groups attrs) 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") || |