diff options
author | wrobell <wrobell@riseup.net> | 2025-06-18 21:39:50 +0100 |
---|---|---|
committer | Sharlatan Hellseher <sharlatanus@gmail.com> | 2025-07-19 01:43:44 +0100 |
commit | 27c3c7c4ed6c2ad027d0a45c1a8cd77abe984f41 (patch) | |
tree | ed687b0f43da0a703649930cf55bff8e539ea554 | |
parent | 6adf07be4253173176d2c7d72f70be7ba1f2c419 (diff) |
gnu: Add rabbitmq.
* gnu/packages/high-availability.scm (rabbitmq): New variable.
* gnu/packages/patches/rabbitmq-defaults.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register new patch.
Change-Id: Ib8e18f37529024bc54b386390fa998337e150771
Co-authored-by: Christopher Baines <mail@cbaines.net>
Reviewed-by: Ludovic Courtès <ludo@gnu.org>
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
-rw-r--r-- | gnu/local.mk | 1 | ||||
-rw-r--r-- | gnu/packages/high-availability.scm | 124 | ||||
-rw-r--r-- | gnu/packages/patches/rabbitmq-defaults.patch | 12 |
3 files changed, 137 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index cf8ac34c1c..da69d6c6c1 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -2220,6 +2220,7 @@ dist_patch_DATA = \ %D%/packages/patches/qtwayland-dont-recreate-callbacks.patch \ %D%/packages/patches/qtwayland-cleanup-callbacks.patch \ %D%/packages/patches/qtwayland-update-wayland-xml.patch \ + %D%/packages/patches/rabbitmq-defaults.patch \ %D%/packages/patches/ragel-char-signedness.patch \ %D%/packages/patches/randomjungle-disable-static-build.patch \ %D%/packages/patches/rapidcheck-fix-libs.patch \ diff --git a/gnu/packages/high-availability.scm b/gnu/packages/high-availability.scm index ed09909251..9951acb1f5 100644 --- a/gnu/packages/high-availability.scm +++ b/gnu/packages/high-availability.scm @@ -1,10 +1,12 @@ ;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2018 Christopher Baines <mail@cbaines.net> ;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; Copyright © 2020, 2022 Tobias Geerinckx-Rice <me@tobias.gr> ;;; Copyright © 2022, 2024 Sharlatan Hellseher <sharlatanus@gmail.com> ;;; Copyright © 2023 Benjamin <benjamin@uvy.fr> ;;; Copyright © 2024 jgart <jgart@dismail.de> ;;; Copyright © 2024 Jordan Moore <lockbox@struct.foo> +;;; Copyright © 2025 Artur Wroblewski <wrobell@riseup.net> ;;; ;;; This file is part of GNU Guix. ;;; @@ -31,10 +33,14 @@ (define-module (gnu packages high-availability) #:use-module (gnu packages autotools) + #:use-module (gnu packages base) + #:use-module (gnu packages bash) #:use-module (gnu packages check) #:use-module (gnu packages compression) #:use-module (gnu packages crypto) #:use-module (gnu packages documentation) + #:use-module (gnu packages elixir) + #:use-module (gnu packages erlang) #:use-module (gnu packages gcc) #:use-module (gnu packages gettext) #:use-module (gnu packages glib) @@ -439,3 +445,121 @@ relationships (both ordering and location) between the cluster resources. Virtually anything that can be scripted can be managed as part of a Pacemaker cluster.") (license (list license:cc-by4.0 license:gpl2+ license:lgpl2.1+)))) + +(define-public rabbitmq + (package + (name "rabbitmq") + (version "4.1.2") + (source + (origin + (method url-fetch) + (uri (string-append + "https://github.com/rabbitmq/rabbitmq-server/releases/download/v" + version "/rabbitmq-server-" version ".tar.xz")) + (file-name (string-append name "-" version ".tar.xz")) + (sha256 + (base32 "1dl2x5v4bj6sl51gw50aj9nch9sy03qhrfjap3k9x9jpkhm6g946")) + (patches (search-patches "rabbitmq-defaults.patch")))) + (build-system gnu-build-system) + (arguments + (list + ;; Using parallel build leads to random build crashes. + #:parallel-build? #f + ;; The release page advises to use .tar.xz archive, but this file does not + ;; contain files required to run RabbitMQ tests (i.e. + ;; deps/rabbitmq_ct_helpers is missing). If we change to the .tar.gz + ;; archive, then we can run the tests, but that can take even few hours if + ;; a machine is slow. We might need to pick a subset of the tests. See + ;; RabbitMQ Arch Linux package for a candidate of a subset of tests. + #:tests? #f + #:make-flags + #~(list (string-append "RMQ_ROOTDIR=" + #$output) + (string-append "RABBITMQ_VERSION=" + #$version)) + #:phases + #~(modify-phases %standard-phases + ;; erlang.mk contains the entries + ;; + ;; ELIXIR_BIN ?= $(shell readlink -f `which elixir`) + ;; ELIXIR_LIBS ?= $(abspath $(dir $(ELIXIR_BIN))/../lib) + ;; + ;; but fails to find elixir.app when building plugins. + ;; + ;; Despite the failures, the build is reported successful while some + ;; plugins are not built. For example, running rabbitmqctl + ;; command-line utility gives error + ;; + ;; undefined function Elixir.RabbitMQCtl':main/1 + ;; + ;; After changing `dir` to `dirname`, all plugins build successfully + ;; and it is possible to use the command-line utilities. + (add-after 'unpack 'extract-rabbitmq-sources + (lambda _ + (substitute* "erlang.mk" + (("dir \\$\\(ELIXIR_BIN\\)") + "shell dirname \\$\\(ELIXIR_BIN\\)")))) + (add-after 'install 'wrap-rabbitmq + (lambda* (#:key outputs inputs #:allow-other-keys) + (let ((sbindir (string-append #$output "/lib/rabbitmq_server-" + #$version "/sbin")) + (rabbitmq-programs (list "rabbitmqctl" + "rabbitmq-diagnostics" + "rabbitmq-plugins" + "rabbitmq-queues" + "rabbitmq-server" + "rabbitmq-streams" + "rabbitmq-upgrade"))) + ;; Starting RabbitMQ server requires: getconf, df, erl. + (wrap-program (string-append sbindir "/rabbitmq-server") + `("PATH" ":" prefix + (,(dirname (search-input-file inputs "bin/getconf")) + ,(dirname (search-input-file inputs "bin/df")) + ,(dirname (search-input-file inputs "bin/erl"))))) + ;; Each of the RabbitMQ programs requires Erlang cookie + ;; stored in RabbitMQ'S user home directory. + (for-each (lambda (prog) + (wrap-program (string-append sbindir "/" prog) + `("PATH" suffix + (,(string-append #$erlang "/bin"))) + `("HOME" = + ("/var/lib/rabbitmq")))) rabbitmq-programs)))) + (delete 'configure) + (add-after 'install 'patch-scripts + (lambda* (#:key inputs outputs #:allow-other-keys) + (substitute* (string-append #$output "/lib/rabbitmq_server-" + #$version "/sbin/rabbitmq-env") + (("basename") + (which "basename")) + (("dirname") + (which "dirname")) + (("readlink") + (which "readlink"))))) + (add-after 'install 'install-bin + (lambda* (#:key inputs outputs #:allow-other-keys) + (let ((target (string-append #$output "/sbin")) + (sbindir (string-append #$output "/lib/rabbitmq_server-" + #$version "/sbin")) + (rabbitmq-programs (list "rabbitmqctl" + "rabbitmq-diagnostics" + "rabbitmq-plugins" + "rabbitmq-queues" + "rabbitmq-server" + "rabbitmq-streams" + "rabbitmq-upgrade"))) + (mkdir-p target) + (for-each (lambda (prog) + (symlink (string-append sbindir "/" prog) + (string-append target "/" prog))) + rabbitmq-programs))))))) + (inputs (list bash-minimal)) + (native-inputs (list erlang elixir python-wrapper which p7zip)) + (synopsis + "Messaging and streaming broker supporting multiple open protocols") + (description + "RabbitMQ is a messaging and streaming broker that supports multiple +messaging protocols, including AMQP 1.0 and MQTT 5.0. It offers features +such as message routing, filtering, streaming, federation, and clustering. +It is designed for reliability and flexibility.") + (home-page "https://www.rabbitmq.com/") + (license license:asl2.0))) diff --git a/gnu/packages/patches/rabbitmq-defaults.patch b/gnu/packages/patches/rabbitmq-defaults.patch new file mode 100644 index 0000000000..22e7004914 --- /dev/null +++ b/gnu/packages/patches/rabbitmq-defaults.patch @@ -0,0 +1,12 @@ +Change the location of the rabbitmq-env.conf file to the current profile +directory. +diff -Nur rabbitmq-server-4.1.1.orig/deps/rabbit/scripts/rabbitmq-defaults rabbitmq-server-4.1.1/deps/rabbit/scripts/rabbitmq-defaults +--- rabbitmq-server-4.1.1.orig/deps/rabbit/scripts/rabbitmq-defaults 2025-06-04 17:59:02.000000000 +0100 ++++ rabbitmq-server-4.1.1/deps/rabbit/scripts/rabbitmq-defaults 2025-06-10 10:38:46.598968381 +0100 +@@ -14,5 +14,5 @@ + BOOT_MODULE="rabbit" + + if test -z "$CONF_ENV_FILE" && test -z "$RABBITMQ_CONF_ENV_FILE"; then +- CONF_ENV_FILE=${SYS_PREFIX}/etc/rabbitmq/rabbitmq-env.conf ++ CONF_ENV_FILE=/run/current-system/profile/etc/rabbitmq/rabbitmq-env.conf + fi |