discourse.mkDiscoursePlugin: Handle repos with gems directories

Some plugin repos already have a `gems` directory. This lets the
packager choose whether it should be kept and the nix packaged ruby
gems should be copied into it or if it should be removed in favor of
our ruby gems.
This commit is contained in:
talyz 2021-08-13 18:53:18 +02:00
parent f8096460bd
commit 04e6b03fa9
No known key found for this signature in database
GPG Key ID: 2DED2151F4671A2B

View File

@ -55,6 +55,7 @@ let
, version ? null
, meta ? null
, bundlerEnvArgs ? {}
, preserveGemsDir ? false
, src
, ...
}@args:
@ -71,11 +72,20 @@ let
runHook preInstall
mkdir -p $out
cp -r * $out/
'' + lib.optionalString (bundlerEnvArgs != {}) ''
ln -sf ${rubyEnv}/lib/ruby/gems $out/gems
'' + ''
'' + lib.optionalString (bundlerEnvArgs != {}) (
if preserveGemsDir then ''
cp -r ${rubyEnv}/lib/ruby/gems/* $out/gems/
''
else ''
if [[ -e $out/gems ]]; then
echo "Warning: The repo contains a 'gems' directory which will be removed!"
echo " If you need to preserve it, set 'preserveGemsDir = true'."
rm -r $out/gems
fi
ln -sf ${rubyEnv}/lib/ruby/gems $out/gems
'' + ''
runHook postInstall
'';
'');
});
rake = runCommand "discourse-rake" {