Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

discourse: 2.7.9 -> 2.8.0.beta9 #147506

Merged
merged 5 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions nixos/modules/services/web-apps/discourse.nix
Original file line number Diff line number Diff line change
Expand Up @@ -621,12 +621,13 @@ in

max_user_api_reqs_per_minute = 20;
max_user_api_reqs_per_day = 2880;
max_admin_api_reqs_per_key_per_minute = 60;
max_admin_api_reqs_per_minute = 60;
max_reqs_per_ip_per_minute = 200;
max_reqs_per_ip_per_10_seconds = 50;
max_asset_reqs_per_ip_per_10_seconds = 200;
max_reqs_per_ip_mode = "block";
max_reqs_rate_limit_on_private = false;
skip_per_ip_rate_limit_trust_level = 1;
force_anonymous_min_queue_seconds = 1;
force_anonymous_min_per_10_seconds = 3;
background_requests_max_queue_length = 0.5;
Expand All @@ -646,6 +647,9 @@ in
enable_email_sync_demon = false;
max_digests_enqueued_per_30_mins_per_site = 10000;
cluster_name = null;
multisite_config_path = "config/multisite.yml";
enable_long_polling = null;
long_polling_interval = null;
};

services.redis.enable = lib.mkDefault (cfg.redis.host == "localhost");
Expand Down Expand Up @@ -825,7 +829,7 @@ in

appendHttpConfig = ''
# inactive means we keep stuff around for 1440m minutes regardless of last access (1 week)
# levels means it is a 2 deep heirarchy cause we can have lots of files
# levels means it is a 2 deep hierarchy cause we can have lots of files
# max_size limits the size of the cache
proxy_cache_path /var/cache/nginx inactive=1440m levels=1:2 keys_zone=discourse:10m max_size=600m;

Expand All @@ -837,7 +841,7 @@ in
inherit (cfg) sslCertificate sslCertificateKey enableACME;
forceSSL = lib.mkDefault tlsEnabled;

root = "/run/discourse/public";
root = "${cfg.package}/share/discourse/public";

locations =
let
Expand Down Expand Up @@ -889,7 +893,7 @@ in
"~ ^/uploads/" = proxy {
extraConfig = cache_1y + ''
proxy_set_header X-Sendfile-Type X-Accel-Redirect;
proxy_set_header X-Accel-Mapping /run/discourse/public/=/downloads/;
proxy_set_header X-Accel-Mapping ${cfg.package}/share/discourse/public/=/downloads/;

# custom CSS
location ~ /stylesheet-cache/ {
Expand All @@ -911,7 +915,7 @@ in
"~ ^/admin/backups/" = proxy {
extraConfig = ''
proxy_set_header X-Sendfile-Type X-Accel-Redirect;
proxy_set_header X-Accel-Mapping /run/discourse/public/=/downloads/;
proxy_set_header X-Accel-Mapping ${cfg.package}/share/discourse/public/=/downloads/;
'';
};
"~ ^/(svg-sprite/|letter_avatar/|letter_avatar_proxy/|user_avatar|highlight-js|stylesheets|theme-javascripts|favicon/proxied|service-worker)" = proxy {
Expand All @@ -938,7 +942,7 @@ in
};
"/downloads/".extraConfig = ''
internal;
alias /run/discourse/public/;
alias ${cfg.package}/share/discourse/public/;
'';
};
};
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/web-apps/discourse.xml
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ services.discourse = {
the script:
<programlisting language="bash">
./update.py update-plugins
</programlisting>.
</programlisting>
</para>

<para>
Expand Down
33 changes: 33 additions & 0 deletions pkgs/development/web/nodejs/nodejs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ let
nativeBuildInputs = [ which pkg-config python ]
++ optionals stdenv.isDarwin [ xcbuild ];

outputs = [ "out" "libv8" ];
setOutputFlags = false;
moveToDev = false;

configureFlags = let
isCross = stdenv.hostPlatform != stdenv.buildPlatform;
inherit (stdenv.hostPlatform) gcc isAarch32;
Expand Down Expand Up @@ -130,6 +134,35 @@ let

# install the missing headers for node-gyp
cp -r ${concatStringsSep " " copyLibHeaders} $out/include/node

# assemble a static v8 library and put it in the 'libv8' output
mkdir -p $libv8/lib
pushd out/Release/obj.target
find . -path "./torque_*/**/*.o" -or -path "./v8*/**/*.o" | sort -u >files
${if stdenv.buildPlatform.isGnu then ''
ar -cqs $libv8/lib/libv8.a @files
'' else ''
cat files | while read -r file; do
ar -cqS $libv8/lib/libv8.a $file
done
''}
popd

# copy v8 headers
cp -r deps/v8/include $libv8/

# create a pkgconfig file for v8
major=$(grep V8_MAJOR_VERSION deps/v8/include/v8-version.h | cut -d ' ' -f 3)
minor=$(grep V8_MINOR_VERSION deps/v8/include/v8-version.h | cut -d ' ' -f 3)
patch=$(grep V8_PATCH_LEVEL deps/v8/include/v8-version.h | cut -d ' ' -f 3)
mkdir -p $libv8/lib/pkgconfig
cat > $libv8/lib/pkgconfig/v8.pc << EOF
Name: v8
Description: V8 JavaScript Engine
Version: $major.$minor.$patch
Libs: -L$libv8/lib -lv8 -pthread -licui18n
Cflags: -I$libv8/include
EOF
'' + optionalString (stdenv.isDarwin && enableNpm) ''
sed -i 's/raise.*No Xcode or CLT version detected.*/version = "7.0.0"/' $out/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py
'';
Expand Down
4 changes: 2 additions & 2 deletions pkgs/servers/web-apps/discourse/auto_generated_path.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb
index 380a63e987..b2ce7fa982 100644
index e59a6fbc05..c773a1356e 100644
--- a/lib/plugin/instance.rb
+++ b/lib/plugin/instance.rb
@@ -403,7 +403,7 @@ class Plugin::Instance
@@ -447,7 +447,7 @@ class Plugin::Instance
end

def auto_generated_path
Expand Down
37 changes: 15 additions & 22 deletions pkgs/servers/web-apps/discourse/default.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{ stdenv, pkgs, makeWrapper, runCommand, lib, writeShellScript
, fetchFromGitHub, bundlerEnv, callPackage

, ruby, replace, gzip, gnutar, git, cacert, util-linux, gawk
, ruby, replace, gzip, gnutar, git, cacert, util-linux, gawk, nettools
, imagemagick, optipng, pngquant, libjpeg, jpegoptim, gifsicle, jhead
, libpsl, redis, postgresql, which, brotli, procps, rsync
, nodePackages, v8
, libpsl, redis, postgresql, which, brotli, procps, rsync, icu
, nodePackages, nodejs-16_x

, plugins ? []
}@args:

let
version = "2.7.9";
version = "2.8.0.beta9";

src = fetchFromGitHub {
owner = "discourse";
repo = "discourse";
rev = "v${version}";
sha256 = "sha256-SOERjFbG4l/tUfOl51XEW0nVbza3L4adjiPhz4Hj0YU=";
sha256 = "sha256-cTedMbf0N50ysRQqA9Fm1WQmI5J5hsqDSi2JZIa49jg=";
};

runtimeDeps = [
Expand All @@ -33,6 +33,7 @@ let
procps # For ps and kill
util-linux # For renice
gawk
nettools # For hostname

# Image optimization
imagemagick
Expand Down Expand Up @@ -110,16 +111,21 @@ let
gems = import ./rubyEnv/gemset.nix;
in
gems // {
mini_racer = gems.mini_racer // {
buildInputs = [ icu ];
dontBuild = false;
NIX_LDFLAGS = "-licui18n";
};
libv8-node =
let
noopScript = writeShellScript "noop" "exit 0";
linkFiles = writeShellScript "link-files" ''
cd ../..

mkdir -p vendor/v8/out.gn/libv8/obj/
ln -s "${v8}/lib/libv8.a" vendor/v8/out.gn/libv8/obj/libv8_monolith.a
mkdir -p vendor/v8/${stdenv.hostPlatform.system}/libv8/obj/
ln -s "${nodejs-16_x.libv8}/lib/libv8.a" vendor/v8/${stdenv.hostPlatform.system}/libv8/obj/libv8_monolith.a

ln -s ${v8}/include vendor/v8/include
ln -s ${nodejs-16_x.libv8}/include vendor/v8/include

mkdir -p ext/libv8-node
echo '--- !ruby/object:Libv8::Node::Location::Vendor {}' >ext/libv8-node/.location.yml
Expand Down Expand Up @@ -155,13 +161,9 @@ let
pname = "discourse-assets";
inherit version src;

nativeBuildInputs = [
rubyEnv.wrappedRuby
nativeBuildInputs = runtimeDeps ++ [
postgresql
redis
which
brotli
procps
nodePackages.uglify-js
nodePackages.terser
];
Expand Down Expand Up @@ -255,22 +257,13 @@ let
# one constructed by bundlerEnv
./plugin_gem_api_version.patch

# Use mv instead of rename, since rename doesn't work across
# device boundaries
./use_mv_instead_of_rename.patch

# Change the path to the auto generated plugin assets, which
# defaults to the plugin's directory and isn't writable at the
# time of asset generation
./auto_generated_path.patch

# Make sure the notification email setting applies
./notification_email.patch

# Change the path to the public directory reported by Discourse
# to its real path instead of the symlink in the store, since
# the store path won't be matched by any nginx rules
./public_dir_path.patch
];

postPatch = ''
Expand Down
4 changes: 4 additions & 0 deletions pkgs/servers/web-apps/discourse/plugins/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Run the nixpkgs/pkgs/servers/web-apps/discourse/update.py script to
update plugins! See the Plugins section of the Discourse chapter in
the NixOS manual (https://nixos.org/manual/nixos/unstable/index.html#module-services-discourse)
for more info.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-assign";
rev = "5124ba0f67e26a075f0a0fc8993273f1211d1c28";
sha256 = "1zd2irp5siza0vd5rlwzmjfvcdfw785988jc526xc741flazk1lr";
rev = "91d0712b0440b6bb0c2fedbf6c31191cdeb991fe";
sha256 = "sha256-ATWLu0vJZFquRcAUpFKaU8mqjjVOv3PziAsHR3aemWk=";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-docs";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ GEM
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
concurrent-ruby (1.1.9)
i18n (1.8.10)
i18n (1.8.11)
concurrent-ruby (~> 1.0)
minitest (5.14.4)
rrule (0.4.2)
activesupport (>= 4.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
zeitwerk (2.4.2)
zeitwerk (2.5.1)

PLATFORMS
ruby
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-calendar";
rev = "2f76cdd3064735d484be1df77f43100aca21aea6";
sha256 = "1skpc8p5br1jkii1rksha1q95ias6xxyvi5bnli3q41w7fz1h5j2";
rev = "fbc617a5fa9f3a22bcc72bc2b32ea3cbdf6087c5";
sha256 = "sha256-qBtq8IvxdKYIFNL9DwdRqZceMMO/qgd6jTr3kk3so3Y=";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-calendar";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0g2fnag935zn2ggm5cn6k4s4xvv53v2givj1j90szmvavlpya96a";
sha256 = "0vdd1kii40qhbr9n8qx71k2gskq6rkl8ygy8hw5hfj8bb5a364xf";
type = "gem";
};
version = "1.8.10";
version = "1.8.11";
};
minitest = {
groups = ["default"];
Expand Down Expand Up @@ -68,9 +68,9 @@
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1746czsjarixq0x05f7p3hpzi38ldg6wxnxxw74kbjzh1sdjgmpl";
sha256 = "18l4r6layck0d80ydc692mv1lxak5xbf6w2paj1x7m2ggbggzxgj";
type = "gem";
};
version = "2.4.2";
version = "2.5.1";
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-chat-integration";
rev = "8ade892b387f0ce843d5e78ef4a271b0d35847ff";
sha256 = "1qn1bm09i9gzmh74ws32zgc89hrqzyhmh63qvmv0h00r52rmgxvx";
rev = "ae0389ca89f26401a6c4cffaaae6adcf14af0e15";
sha256 = "sha256-wT9S2mMz2MOpWpYv/FrHYhZibStRIGC4P2Vrqs04bkA=";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-chat-integration";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-checklist";
rev = "48855d81b7c3a3274f7f78a64312125c344d92d1";
sha256 = "0139v5wpyglfzvd07ka6gic1ssfysisgfiq09dsbjy519gnc9kjw";
rev = "d8012abd3d6dccb72eec83e6a96ef4809dcad681";
sha256 = "1ngjql65939c571gyaqj8ydcxy5kkril2qlkxqf579vvwzpvxw13";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-checklist";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-data-explorer";
rev = "23287ece952cb45203819e7b470ebc194c58cb13";
sha256 = "1vc2072r72fkvcfpy6vpn9x4gl9lpjk29pnj8095xs22im8j5in1";
rev = "3ce778ec6d96a300a06ffe0581f4681fbed8df7f";
sha256 = "1555k1anrijfbm0qfraby3ivh6h76177d541nxhnarj85mjx0hjb";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-data-explorer";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-docs";
rev = "72cdd8d415ae3f797c0d5e2c857370714a42c54a";
sha256 = "07hvw8lpg8873vhwh8rrbml3s5hq606b7sw93r2xv38gxfhmx5lq";
rev = "d3eee7008b7a703774331808e302e36f2f8b4eae";
sha256 = "1p3aqfpv207pvlbis43znwgw56yqsn41320yaw1gdcaakf5s2rsx";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-docs";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-github";
rev = "9aaf4350968fb758f9bff3588f78e3ad24ddb4b0";
sha256 = "0nmpkh1rr0jv68a655f5610v2mn09xriiqv049a0gklap2lgv7p8";
rev = "8cd8c0703991c16cb2fa8cb1fd22a9c3849c7ae2";
sha256 = "17ga31a10sm3fqjpf40mz7fk62vynyng2a243pia9fjdq9py8slx";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-github";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

source "https://rubygems.org"

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

# gem "rails"
gem 'pyu-ruby-sasl', '0.0.3.3', require: false
gem 'rubyntlm', '0.3.4', require: false
gem 'net-ldap', '0.14.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
hashie (4.1.0)
hashie (5.0.0)
net-ldap (0.14.0)
omniauth (1.9.1)
hashie (>= 3.4.6)
Expand All @@ -16,7 +16,7 @@ GEM
rubyntlm (0.3.4)

PLATFORMS
x86_64-linux
ruby

DEPENDENCIES
net-ldap (= 0.14.0)
Expand All @@ -25,4 +25,4 @@ DEPENDENCIES
rubyntlm (= 0.3.4)

BUNDLED WITH
2.2.20
2.2.24
Loading