Skip to content

Commit

Permalink
discourse.mkDiscoursePlugin: Handle repos with gems directories
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
talyz committed Aug 17, 2021
1 parent f809646 commit 04e6b03
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkgs/servers/web-apps/discourse/default.nix
Expand Up @@ -55,6 +55,7 @@ let
, version ? null
, meta ? null
, bundlerEnvArgs ? {}
, preserveGemsDir ? false
, src
, ...
}@args:
Expand All @@ -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" {
Expand Down

0 comments on commit 04e6b03

Please sign in to comment.