diff --git a/pkgs/servers/web-apps/discourse/plugins/all-plugins.nix b/pkgs/servers/web-apps/discourse/plugins/all-plugins.nix index 947e0ff9196c..e36f1416456a 100644 --- a/pkgs/servers/web-apps/discourse/plugins/all-plugins.nix +++ b/pkgs/servers/web-apps/discourse/plugins/all-plugins.nix @@ -3,16 +3,22 @@ let callPackage = newScope args; in { + discourse-assign = callPackage ./discourse-assign {}; discourse-calendar = callPackage ./discourse-calendar {}; discourse-canned-replies = callPackage ./discourse-canned-replies {}; + discourse-chat-integration = callPackage ./discourse-chat-integration {}; discourse-checklist = callPackage ./discourse-checklist {}; discourse-data-explorer = callPackage ./discourse-data-explorer {}; + discourse-docs = callPackage ./discourse-docs {}; discourse-github = callPackage ./discourse-github {}; discourse-ldap-auth = callPackage ./discourse-ldap-auth {}; discourse-math = callPackage ./discourse-math {}; discourse-migratepassword = callPackage ./discourse-migratepassword {}; discourse-openid-connect = callPackage ./discourse-openid-connect {}; + discourse-prometheus = callPackage ./discourse-prometheus {}; + discourse-saved-searches = callPackage ./discourse-saved-searches {}; discourse-solved = callPackage ./discourse-solved {}; discourse-spoiler-alert = callPackage ./discourse-spoiler-alert {}; + discourse-voting = callPackage ./discourse-voting {}; discourse-yearly-review = callPackage ./discourse-yearly-review {}; } diff --git a/pkgs/servers/web-apps/discourse/plugins/discourse-assign/default.nix b/pkgs/servers/web-apps/discourse/plugins/discourse-assign/default.nix new file mode 100644 index 000000000000..a514425c4031 --- /dev/null +++ b/pkgs/servers/web-apps/discourse/plugins/discourse-assign/default.nix @@ -0,0 +1,17 @@ +{ lib, mkDiscoursePlugin, fetchFromGitHub }: + +mkDiscoursePlugin { + name = "discourse-assign"; + src = fetchFromGitHub { + owner = "discourse"; + repo = "discourse-assign"; + rev = "5124ba0f67e26a075f0a0fc8993273f1211d1c28"; + sha256 = "1zd2irp5siza0vd5rlwzmjfvcdfw785988jc526xc741flazk1lr"; + }; + meta = with lib; { + homepage = "https://github.com/discourse/discourse-docs"; + maintainers = with maintainers; [ dpausp ]; + license = licenses.mit; + description = "Discourse Plugin for assigning users to a topic"; + }; +} diff --git a/pkgs/servers/web-apps/discourse/plugins/discourse-chat-integration/default.nix b/pkgs/servers/web-apps/discourse/plugins/discourse-chat-integration/default.nix new file mode 100644 index 000000000000..3079447dbb0a --- /dev/null +++ b/pkgs/servers/web-apps/discourse/plugins/discourse-chat-integration/default.nix @@ -0,0 +1,17 @@ +{ lib, mkDiscoursePlugin, fetchFromGitHub }: + +mkDiscoursePlugin { + name = "discourse-chat-integration"; + src = fetchFromGitHub { + owner = "discourse"; + repo = "discourse-chat-integration"; + rev = "8ade892b387f0ce843d5e78ef4a271b0d35847ff"; + sha256 = "1qn1bm09i9gzmh74ws32zgc89hrqzyhmh63qvmv0h00r52rmgxvx"; + }; + meta = with lib; { + homepage = "https://github.com/discourse/discourse-chat-integration"; + maintainers = with maintainers; [ dpausp ]; + license = licenses.mit; + description = "This plugin integrates Discourse with a number of external chatroom systems"; + }; +} diff --git a/pkgs/servers/web-apps/discourse/plugins/discourse-docs/default.nix b/pkgs/servers/web-apps/discourse/plugins/discourse-docs/default.nix new file mode 100644 index 000000000000..1206fb0cd6ad --- /dev/null +++ b/pkgs/servers/web-apps/discourse/plugins/discourse-docs/default.nix @@ -0,0 +1,17 @@ +{ lib, mkDiscoursePlugin, fetchFromGitHub }: + +mkDiscoursePlugin { + name = "discourse-docs"; + src = fetchFromGitHub { + owner = "discourse"; + repo = "discourse-docs"; + rev = "72cdd8d415ae3f797c0d5e2c857370714a42c54a"; + sha256 = "07hvw8lpg8873vhwh8rrbml3s5hq606b7sw93r2xv38gxfhmx5lq"; + }; + meta = with lib; { + homepage = "https://github.com/discourse/discourse-docs"; + maintainers = with maintainers; [ dpausp ]; + license = licenses.mit; + description = "Find and filter knowledge base topics"; + }; +} diff --git a/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/Gemfile b/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/Gemfile new file mode 100644 index 000000000000..3a73fc55839d --- /dev/null +++ b/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/Gemfile @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } + +# gem "rails" +gem 'prometheus_exporter', '0.5.0' diff --git a/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/Gemfile.lock b/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/Gemfile.lock new file mode 100644 index 000000000000..75c139cbfc0e --- /dev/null +++ b/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/Gemfile.lock @@ -0,0 +1,13 @@ +GEM + remote: https://rubygems.org/ + specs: + prometheus_exporter (0.5.0) + +PLATFORMS + ruby + +DEPENDENCIES + prometheus_exporter (= 0.5.0) + +BUNDLED WITH + 2.1.4 diff --git a/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/default.nix b/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/default.nix new file mode 100644 index 000000000000..4c6c12f22b3f --- /dev/null +++ b/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/default.nix @@ -0,0 +1,26 @@ +{ lib, stdenv, mkDiscoursePlugin, fetchFromGitHub }: + + mkDiscoursePlugin { + bundlerEnvArgs.gemdir = ./.; + name = "discourse-prometheus"; + src = fetchFromGitHub { + owner = "discourse"; + repo = "discourse-prometheus"; + rev = "46260710e8770344af438f86b47409d864a1c499"; + sha256 = "0nmpi0nysp59x4hyn1c3niypvxw1jkz86acb6m8acacw0c6682k2"; + }; + + patches = [ + # The metrics collector tries to run git to get the commit id but fails + # because we don't run Discourse from a Git repository. + ./no-git-version.patch + ./spec-import-fix-abi-version.patch + ]; + + meta = with lib; { + homepage = "https://github.com/discourse/discourse-prometheus"; + maintainers = with maintainers; [ dpausp ]; + license = licenses.mit; + description = "Official Discourse Plugin for Prometheus Monitoring"; + }; +} diff --git a/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/gemset.nix b/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/gemset.nix new file mode 100644 index 000000000000..e62e01926837 --- /dev/null +++ b/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/gemset.nix @@ -0,0 +1,12 @@ +{ + prometheus_exporter = { + groups = ["default"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "1kmabnxz466zqnyqlzc693ny4l7i0rxvmc0znswvizc0zg4pri80"; + type = "gem"; + }; + version = "0.5.0"; + }; +} diff --git a/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/no-git-version.patch b/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/no-git-version.patch new file mode 100644 index 000000000000..416386f4ecd3 --- /dev/null +++ b/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/no-git-version.patch @@ -0,0 +1,36 @@ +diff --git a/lib/internal_metric/global.rb b/lib/internal_metric/global.rb +index 682571b..7bdd431 100644 +--- a/lib/internal_metric/global.rb ++++ b/lib/internal_metric/global.rb +@@ -30,30 +30,7 @@ module DiscoursePrometheus::InternalMetric + @active_app_reqs = 0 + @queued_app_reqs = 0 + @fault_logged = {} +- +- begin +- @@version = nil +- +- out, error, status = Open3.capture3('git rev-parse HEAD') +- +- if status.success? +- @@version ||= out.chomp +- else +- raise error +- end +- rescue => e +- if defined?(::Discourse) +- Discourse.warn_exception(e, message: "Failed to calculate discourse_version_info metric") +- else +- STDERR.puts "Failed to calculate discourse_version_info metric: #{e}\n#{e.backtrace.join("\n")}" +- end +- +- @@retries ||= 10 +- @@retries -= 1 +- if @@retries < 0 +- @@version = -1 +- end +- end ++ @@version = -1 + end + + def collect diff --git a/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/spec-import-fix-abi-version.patch b/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/spec-import-fix-abi-version.patch new file mode 100644 index 000000000000..7b1159d0a800 --- /dev/null +++ b/pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/spec-import-fix-abi-version.patch @@ -0,0 +1,16 @@ +diff --git a/bin/collector b/bin/collector +index 4fec65e..e59eac7 100755 +--- a/bin/collector ++++ b/bin/collector +@@ -3,8 +3,10 @@ + + Process.setproctitle("discourse prometheus-collector") + ++# We need the ABI version {MAJOR}.{MINOR}.0 here. ++abi_version = ENV['GEM_PATH'].split("/")[-1] + version = File.read(File.expand_path("../../prometheus_exporter_version", __FILE__)).strip +-spec_file = File.expand_path("../../gems/#{RUBY_VERSION}/specifications/prometheus_exporter-#{version}.gemspec", __FILE__) ++spec_file = File.expand_path("../../gems/#{abi_version}/specifications/prometheus_exporter-#{version}.gemspec", __FILE__) + + spec = Gem::Specification.load spec_file + spec.activate diff --git a/pkgs/servers/web-apps/discourse/plugins/discourse-saved-searches/default.nix b/pkgs/servers/web-apps/discourse/plugins/discourse-saved-searches/default.nix new file mode 100644 index 000000000000..a641d51f040e --- /dev/null +++ b/pkgs/servers/web-apps/discourse/plugins/discourse-saved-searches/default.nix @@ -0,0 +1,17 @@ +{ lib, mkDiscoursePlugin, fetchFromGitHub }: + +mkDiscoursePlugin { + name = "discourse-saved-searches"; + src = fetchFromGitHub { + owner = "discourse"; + repo = "discourse-saved-searches"; + rev = "b59e0b60afdd5133e60c5cc6169f42f1edd746be"; + sha256 = "0yhr7gx35q2nshvfxkplplkq73l7sgqlm8r3g1apniqicpk5flqy"; + }; + meta = with lib; { + homepage = "https://github.com/discourse/discourse-saved-searches"; + maintainers = with maintainers; [ dpausp ]; + license = licenses.mit; + description = "Allow users to save searches and be notified of new results"; + }; +} diff --git a/pkgs/servers/web-apps/discourse/plugins/discourse-voting/default.nix b/pkgs/servers/web-apps/discourse/plugins/discourse-voting/default.nix new file mode 100644 index 000000000000..f7748f5a52d3 --- /dev/null +++ b/pkgs/servers/web-apps/discourse/plugins/discourse-voting/default.nix @@ -0,0 +1,17 @@ +{ lib, mkDiscoursePlugin, fetchFromGitHub }: + +mkDiscoursePlugin { + name = "discourse-voting"; + src = fetchFromGitHub { + owner = "discourse"; + repo = "discourse-voting"; + rev = "fc4d23174eba1a57ddcba93eaf4a4e75d469d4a4"; + sha256 = "07mj667qn387kaafg475f36pgnannsrb2bdqi0zj487av43252qb"; + }; + meta = with lib; { + homepage = "https://github.com/discourse/discourse-voting"; + maintainers = with maintainers; [ dpausp ]; + license = licenses.gpl2Only; + description = "Adds the ability for voting on a topic within a specified category in Discourse"; + }; +} diff --git a/pkgs/servers/web-apps/discourse/update.py b/pkgs/servers/web-apps/discourse/update.py index a207b0ebf318..8352ac09f367 100755 --- a/pkgs/servers/web-apps/discourse/update.py +++ b/pkgs/servers/web-apps/discourse/update.py @@ -201,16 +201,24 @@ def update_plugins(): """ plugins = [ + {'name': 'discourse-assign'}, {'name': 'discourse-calendar'}, {'name': 'discourse-canned-replies'}, + {'name': 'discourse-chat-integration'}, {'name': 'discourse-checklist'}, {'name': 'discourse-data-explorer'}, + {'name': 'discourse-docs'}, {'name': 'discourse-github'}, {'name': 'discourse-ldap-auth', 'owner': 'jonmbake'}, {'name': 'discourse-math'}, {'name': 'discourse-migratepassword', 'owner': 'discoursehosting'}, + # We can't update this automatically at the moment because the plugin.rb + # tries to load a version number which breaks bundler called by this script. + # {'name': 'discourse-prometheus'}, + {'name': 'discourse-saved-searches'}, {'name': 'discourse-solved'}, {'name': 'discourse-spoiler-alert'}, + {'name': 'discourse-voting'}, {'name': 'discourse-yearly-review'}, ]