diff options
author | Ashvith Shetty <ashvithshetty0010@zohomail.in> | 2025-04-16 01:19:54 +0530 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2025-05-27 15:14:11 +0200 |
commit | bff04df0032c5d703b1e6d21d4db74ced5dfe49d (patch) | |
tree | 7740e7ca3851f0b5d4b900946b75112be1d192fd | |
parent | a3e0a45b5d4b8944b83107874c50b309ad275c81 (diff) |
gnu: Add dicedb.
* gnu/packages/databases.scm (dicedb): New variable.
* gnu/packages/patches/dicedb-remove-init-from-config-subpkg.patch:
New file.
* gnu/local.mk (dist_patch_DATA): Register patch.
Change-Id: Id5c97d254c35301181593b42c96a83a1ef843131
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r-- | gnu/local.mk | 1 | ||||
-rw-r--r-- | gnu/packages/databases.scm | 93 | ||||
-rw-r--r-- | gnu/packages/patches/dicedb-remove-init-from-config-subpkg.patch | 50 |
3 files changed, 144 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index c8726ce83e..fab64f55eb 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1182,6 +1182,7 @@ dist_patch_DATA = \ %D%/packages/patches/dee-vapi.patch \ %D%/packages/patches/dfu-programmer-fix-libusb.patch \ %D%/packages/patches/dhclient-script-resolvconf-support.patch \ + %D%/packages/patches/dicedb-remove-init-from-config-subpkg.patch \ %D%/packages/patches/directfb-davinci-glibc-228-compat.patch \ %D%/packages/patches/dkimproxy-add-ipv6-support.patch \ %D%/packages/patches/docbook-utils-documentation-edits.patch \ diff --git a/gnu/packages/databases.scm b/gnu/packages/databases.scm index acc35b9b3b..73c8bebe98 100644 --- a/gnu/packages/databases.scm +++ b/gnu/packages/databases.scm @@ -64,6 +64,7 @@ ;;; Copyright © 2023 Giacomo Leidi <goodoldpaul@autistici.org> ;;; Copyright © 2024 Troy Figiel <troy@troyfigiel.com> ;;; Copyright © 2024 gemmaro <gemmaro.dev@gmail.com> +;;; Copyright © 2025 Ashvith Shetty <ashvithshetty0010@zohomail.in> ;;; ;;; This file is part of GNU Guix. ;;; @@ -110,8 +111,10 @@ #:use-module (gnu packages glib) #:use-module (gnu packages gnome) #:use-module (gnu packages gnupg) + #:use-module (gnu packages golang) #:use-module (gnu packages golang-build) #:use-module (gnu packages golang-check) + #:use-module (gnu packages golang-crypto) #:use-module (gnu packages golang-web) #:use-module (gnu packages golang-xyz) #:use-module (gnu packages gperf) @@ -484,6 +487,96 @@ database later.") license:mpl1.1 ; examples/interfaces/0{6,8}*.cpp license:public-domain)))) ; including files without explicit licence +(define-public dicedb + (package + (name "dicedb") + (version "1.0.3") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/DiceDB/dice") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 "19hkr2sqb5vcyrxb17y8586aa9amw2nny2fia7yf2lshigg03va5")) + (patches (search-patches "dicedb-remove-init-from-config-subpkg.patch")))) + (build-system go-build-system) + (arguments + (list + #:go go-1.23 + #:install-source? #f + #:import-path "github.com/dicedb/dice" + #:build-flags + #~(list (format #f "-ldflags=-X config.DiceDBVersion=v~a" + #$version)) + #:test-subdirs + #~(list "internal/auth/..." + ;; "internal/clientio/..." ; matched no packages + "internal/cmd/..." + "internal/comm/..." + "internal/common/..." + "internal/dencoding/..." + "internal/errors/..." + ;; "internal/eval/..." ; build failed + "internal/id/..." + "internal/iomultiplexer/..." + "internal/logger/..." + "internal/object/..." + "internal/observability/..." + "internal/ops/..." + "internal/querymanager/..." + "internal/regex/..." + "internal/server/..." + "internal/shard/..." + ;; "internal/sql/..." ; matched no packages + ;; "internal/store/..." ; build failed + "internal/wal/..." + "internal/watchmanager/..." + ;; "internal/worker/..." ; matched no packages + ) + #:test-flags + #~(list "-skip" + (string-join (list "TestSessionIsActive" "TestSessionActivate" + "TestSessionValidate" "TestDEL") "|")) + #:phases + #~(modify-phases %standard-phases + (add-after 'unpack 'remove-example + (lambda* (#:key tests? import-path #:allow-other-keys) + (with-directory-excursion (string-append "src/" import-path) + (delete-file-recursively "examples"))))))) + (propagated-inputs (list go-google-golang-org-protobuf + go-golang-org-x-crypto + go-github-com-twmb-murmur3 + go-github-com-stretchr-testify + go-github-com-spf13-viper + go-github-com-spf13-pflag + go-github-com-spf13-cobra + go-github-com-rs-zerolog + go-github-com-rs-xid + go-github-com-ohler55-ojg + go-github-com-mmcloughlin-geohash + go-github-com-google-uuid + go-github-com-google-go-cmp + go-github-com-google-btree + go-github-com-gobwas-glob + go-github-com-dicedb-dicedb-go + go-github-com-dgryski-go-farm + go-github-com-cespare-xxhash-v2 + go-github-com-bytedance-sonic + go-github-com-axiomhq-hyperloglog + go-gotest-tools-v3)) + (home-page "https://github.com/dicedb/dice") + (synopsis + "Fast, reactive, in-memory database optimized for modern hardware") + (description + "@code{dicedb} is a fast, reactive, in-memory database optimized +for modern hardware. Commonly used as a cache, it offers a familiar interface +while enabling real-time data updates through query subscriptions. It delivers +higher throughput and lower median latencies, making it ideal for modern +workloads.") + (license license:bsd-3))) + (define-public leveldb (package (name "leveldb") diff --git a/gnu/packages/patches/dicedb-remove-init-from-config-subpkg.patch b/gnu/packages/patches/dicedb-remove-init-from-config-subpkg.patch new file mode 100644 index 0000000000..7834b90f30 --- /dev/null +++ b/gnu/packages/patches/dicedb-remove-init-from-config-subpkg.patch @@ -0,0 +1,50 @@ +If built locally, dicedb works for as long as the build cache in the tmp +directory exists - it looks for a file called VERSION in the project root. +Once cleared, or in the case of downloading from substitute server, the +location of the VERSION file is invalid. Removing this code and instead +providing them through the flag resolves this issue. + +diff --git a/config/config.go b/config/config.go +index b358813..c408096 100644 +--- a/config/config.go ++++ b/config/config.go +@@ -9,8 +9,6 @@ import ( + "os" + "path/filepath" + "reflect" +- "runtime" +- "strings" + + "github.com/spf13/pflag" + "github.com/spf13/viper" +@@ -20,30 +18,6 @@ var ( + DiceDBVersion = "-" + ) + +-// init initializes the DiceDBVersion variable by reading the +-// VERSION file from the project root. +-// This function runs automatically when the package is imported. +-func init() { +- // Get the absolute path of the current file (config.go) +- // using runtime reflection +- _, currentFile, _, _ := runtime.Caller(0) //nolint:dogsled +- +- // Navigate up two directories from config.go to reach the project root +- // (config.go is in the config/ directory, so we need to go up twice) +- projectRoot := filepath.Dir(filepath.Dir(currentFile)) +- +- // Read the VERSION file from the project root +- // This approach works regardless of where the program is executed from +- version, err := os.ReadFile(filepath.Join(projectRoot, "VERSION")) +- if err != nil { +- slog.Error("could not read the version file", slog.String("error", err.Error())) +- os.Exit(1) +- } +- +- // Store the version string in the package-level DiceDBVersion variable +- DiceDBVersion = strings.TrimSpace(string(version)) +-} +- + var Config *DiceDBConfig + + type DiceDBConfig struct { |