discourse: Fix plugin support
For plugins to work properly, their assets need to be precompiled along with the rest of Discourse's assets. This means we need to build new packages when the list of plugins change.
This commit is contained in:
@@ -30,6 +30,9 @@ in
|
|||||||
package = lib.mkOption {
|
package = lib.mkOption {
|
||||||
type = lib.types.package;
|
type = lib.types.package;
|
||||||
default = pkgs.discourse;
|
default = pkgs.discourse;
|
||||||
|
apply = p: p.override {
|
||||||
|
plugins = lib.unique (p.enabledPlugins ++ cfg.plugins);
|
||||||
|
};
|
||||||
defaultText = "pkgs.discourse";
|
defaultText = "pkgs.discourse";
|
||||||
description = ''
|
description = ''
|
||||||
The discourse package to use.
|
The discourse package to use.
|
||||||
@@ -731,8 +734,6 @@ in
|
|||||||
|
|
||||||
cp -r ${cfg.package}/share/discourse/config.dist/* /run/discourse/config/
|
cp -r ${cfg.package}/share/discourse/config.dist/* /run/discourse/config/
|
||||||
cp -r ${cfg.package}/share/discourse/public.dist/* /run/discourse/public/
|
cp -r ${cfg.package}/share/discourse/public.dist/* /run/discourse/public/
|
||||||
cp -r ${cfg.package}/share/discourse/plugins.dist/* /run/discourse/plugins/
|
|
||||||
${lib.concatMapStringsSep "\n" (p: "ln -sf ${p} /run/discourse/plugins/") cfg.plugins}
|
|
||||||
ln -sf /var/lib/discourse/uploads /run/discourse/public/uploads
|
ln -sf /var/lib/discourse/uploads /run/discourse/public/uploads
|
||||||
ln -sf /var/lib/discourse/backups /run/discourse/public/backups
|
ln -sf /var/lib/discourse/backups /run/discourse/public/backups
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
, util-linux, gawk, imagemagick, optipng, pngquant, libjpeg, jpegoptim
|
, util-linux, gawk, imagemagick, optipng, pngquant, libjpeg, jpegoptim
|
||||||
, gifsicle, libpsl, redis, postgresql, which, brotli, procps, rsync
|
, gifsicle, libpsl, redis, postgresql, which, brotli, procps, rsync
|
||||||
, nodePackages, v8
|
, nodePackages, v8
|
||||||
|
|
||||||
|
, plugins ? []
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
@@ -148,6 +150,8 @@ let
|
|||||||
mkdir $NIX_BUILD_TOP/tmp_home
|
mkdir $NIX_BUILD_TOP/tmp_home
|
||||||
export HOME=$NIX_BUILD_TOP/tmp_home
|
export HOME=$NIX_BUILD_TOP/tmp_home
|
||||||
|
|
||||||
|
${lib.concatMapStringsSep "\n" (p: "cp -r ${p} plugins/") plugins}
|
||||||
|
|
||||||
export RAILS_ENV=production
|
export RAILS_ENV=production
|
||||||
|
|
||||||
bundle exec rake db:migrate >/dev/null
|
bundle exec rake db:migrate >/dev/null
|
||||||
@@ -212,7 +216,6 @@ let
|
|||||||
|
|
||||||
mv config config.dist
|
mv config config.dist
|
||||||
mv public public.dist
|
mv public public.dist
|
||||||
mv plugins plugins.dist
|
|
||||||
|
|
||||||
runHook postBuild
|
runHook postBuild
|
||||||
'';
|
'';
|
||||||
@@ -230,6 +233,7 @@ let
|
|||||||
ln -sf /run/discourse/public $out/share/discourse/public
|
ln -sf /run/discourse/public $out/share/discourse/public
|
||||||
ln -sf /run/discourse/plugins $out/share/discourse/plugins
|
ln -sf /run/discourse/plugins $out/share/discourse/plugins
|
||||||
ln -sf ${assets} $out/share/discourse/public.dist/assets
|
ln -sf ${assets} $out/share/discourse/public.dist/assets
|
||||||
|
${lib.concatMapStringsSep "\n" (p: "ln -sf ${p} $out/share/discourse/plugins/") plugins}
|
||||||
|
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
@@ -244,6 +248,7 @@ let
|
|||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit rubyEnv runtimeEnv runtimeDeps rake;
|
inherit rubyEnv runtimeEnv runtimeDeps rake;
|
||||||
|
enabledPlugins = plugins;
|
||||||
ruby = rubyEnv.wrappedRuby;
|
ruby = rubyEnv.wrappedRuby;
|
||||||
tests = nixosTests.discourse;
|
tests = nixosTests.discourse;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user