Subject: [bug#78496] [PATCH] gnu: Add sqlitestudio.

From: Philippe SWARTVAGHER <[email-masked]>
Date: Mon, 19 May 2025 21:15:53 +0200

* gnu/packages/databases.scm (sqlitestudio): New variable.

Change-Id: I012a189d37661bf70b140048696ae97647bf0a6f
---
 gnu/packages/databases.scm | 112 +++++++++++++++++++++++++++++++++++++
 1 file changed, 112 insertions(+)

diff --git a/gnu/packages/databases.scm b/gnu/packages/databases.scm
index c3a10efece..16cca632c9 100644
--- a/gnu/packages/databases.scm
+++ b/gnu/packages/databases.scm
@@ -64,6 +64,7 @@
 ;;; Copyright © 2023 Giacomo Leidi <[email-masked]>
 ;;; Copyright © 2024 Troy Figiel <[email-masked]>
 ;;; Copyright © 2024 gemmaro <[email-masked]>
+;;; Copyright © 2025 Philippe Swartvagher <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -5728,6 +5729,117 @@ (define-public sqlitebrowser
      (list license:gpl3+
            license:mpl2.0))))
 
+(define-public sqlitestudio
+  (package
+    (name "sqlitestudio")
+    (version "3.4.17")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/pawelsalawa/sqlitestudio")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1zb1qr88rwkzmrxc0lm99x8h99hpn5c2wfdpvqzs9f9ph8qvasww"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:phases (modify-phases %standard-phases
+                  (replace 'configure
+                    (lambda* (#:key inputs outputs #:allow-other-keys)
+                      (let* ((out (assoc-ref outputs "out"))
+                             (python-version ,(version-major+minor (package-version
+                                                                    python)))
+                             (python-include (string-append (assoc-ref inputs
+                                                             "python")
+                                                            "/include/python"
+                                                            python-version)))
+                        (invoke "qmake"
+                                (string-append
+                                 "QMAKE_LFLAGS_RPATH=-Wl,-rpath," out "/lib:")
+                                (string-append "PREFIX=" out)
+                                "./SQLiteStudio3")
+                        (mkdir-p "Plugins")
+                        (chdir "Plugins")
+                        (invoke "qmake"
+                                (string-append
+                                 "QMAKE_LFLAGS_RPATH=-Wl,-rpath," out "/lib:")
+                                (string-append "PREFIX=" out)
+                                (string-append "INCLUDEPATH+=" python-include)
+                                (string-append "PYTHON_VERSION="
+                                               python-version)
+                                ".")
+                        (chdir ".."))))
+                  (replace 'build
+                    (lambda _
+                      (invoke "make" "-j"
+                              (number->string (parallel-job-count)))
+                      (chdir "Plugins")
+                      (invoke "make") ;building plugins in parallel corrupts them
+                      (chdir "..")))
+                  (replace 'install
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (let* ((out (assoc-ref outputs "out"))
+                             (icons-dir (string-append out
+                                         "/share/icons/hicolor/"))
+                             (src-img-dir (string-append
+                                           "SQLiteStudio3/guiSQLiteStudio/img/")))
+                        (invoke "make" "-j"
+                                (number->string (parallel-job-count))
+                                "install")
+                        (for-each (lambda (size)
+                                    (let ((target-dir (string-append icons-dir
+                                                       size "x" size "/apps/")))
+                                      (mkdir-p target-dir)
+                                      (copy-file (string-append src-img-dir
+                                                  "sqlitestudio_" size ".png")
+                                                 (string-append target-dir
+                                                  "sqlitestudio.png"))))
+                                  '("16" "48" "256"))
+                        (let ((target-dir (string-append icons-dir
+                                                         "scalable/apps/")))
+                          (mkdir-p target-dir)
+                          (install-file (string-append src-img-dir
+                                                       "sqlitestudio.svg")
+                                        target-dir))
+                        (chdir "Plugins")
+                        (invoke "make" "-j"
+                                (number->string (parallel-job-count))
+                                "install")
+                        (chdir ".."))))
+                  (add-after 'install 'install-desktop
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (let* ((out (assoc-ref outputs "out")))
+                        (make-desktop-entry-file (string-append out
+                                                  "/share/applications/"
+                                                  ,name ".desktop")
+                                                 #:name "SQLiteStudio"
+                                                 #:comment ,(package-synopsis
+                                                             this-package)
+                                                 #:exec (string-append ,name
+                                                                       " %f")
+                                                 #:icon ,name
+                                                 #:categories '("Development"
+                                                                "Utility"
+                                                                "Database")
+                                                 #:mime-type
+                                                 "application/vnd.sqlite3")))))))
+    (inputs (list openssl
+                  python
+                  qtbase-5
+                  qtsvg-5
+                  readline
+                  sqlite-next))
+    (native-inputs (list python qttools-5 qtdeclarative-5 tcl))
+    (home-page "https://sqlitestudio.pl/")
+    (synopsis
+     "A free, open source, multi-platform SQLite database manager")
+    (description
+     "SQLiteStudio is desktop application for browsing and editing SQLite
+     database files. It is aimed for people, who know what SQLite is, or what
+     relational databases are in general.")
+    (license license:gpl3+)))
+
 (define-public sqls
   (package
     (name "sqls")

base-commit: 450a361532573a02389530a6a80b7821683ed41b
-- 
2.49.0