From 8dd01fa86119e1af27d5a3ffd709feebd239f32a Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Fri, 22 May 2026 11:09:11 +0200 Subject: [PATCH] chore: add delve Go debugger to Guix manifest (#12662) I did some research and experiments to get a working `delve` debugger using Guix, which could step Forgejo and inspect variables/call procedures. This suggested change captures the details in the Guix manifest to make that knowledge easier for others to reuse. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12662 Reviewed-by: Mathieu Fenniak --- manifest.scm | 64 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 15 deletions(-) diff --git a/manifest.scm b/manifest.scm index f9605bc2d9..6f801a5eef 100644 --- a/manifest.scm +++ b/manifest.scm @@ -11,28 +11,62 @@ ;;; made available to fetch required Go and Node dependencies. ;;; #| + guix shell -CNF --share=$HOME -m manifest.scm export GOTOOLCHAIN=local # to use the Go binary from Guix export CC=gcc CGO_ENABLED=1 +# The following is to preserve debug info symbols: +export STRIP=0 CGO_CFLAGS='-O0 -g' EXTRA_GOFLAGS='-gcflags="all=-N -l"' export TAGS="timetzdata sqlite sqlite_unlock_notify" make clean make -j$(nproc) make test -j$(nproc) # run unit tests make test-sqlite -j$(nproc) # run integration tests make watch # run an instance/rebuild on changes + +# For debugging, you can either attach the delve debugger like this: +dlv attach $(pgrep gitea) + +# Or start Forgejo directly with it: +dlv exec ./gitea + |# -(specifications->manifest - (list "bash-minimal" - "coreutils" - "findutils" - "gcc-toolchain" - "git" ;libpcre support is required - "git-lfs" - "gnupg" - "go" - "grep" - "make" - "node" - "nss-certs" - "openssh" - "sed")) + +(use-modules (guix packages) + (guix utils)) + +(define go-1.26 ;minimal version required by Forgejo + (specification->package "go@1.26")) + +(define (package-with-go base go) + "Return a variant of BASE, a Guix package object built with GO, another +package." + (package/inherit base + (arguments (ensure-keyword-arguments (package-arguments base) + (list #:go go))))) + +(define packages-for-debugging + (list (specification->package "procps") ;pgrep + (package-with-go (specification->package "delve") go-1.26) ;debugger + (package-with-go (specification->package "gomacro") go-1.26))) ;Go REPL + +(concatenate-manifests + (list + (packages->manifest + (append (list go-1.26) + packages-for-debugging)) + (specifications->manifest + (list "bash-minimal" + "coreutils" + "diffutils" + "findutils" + "gcc-toolchain" + "git" ;libpcre support is required + "git-lfs" + "gnupg" + "grep" + "make" + "node" + "nss-certs" + "openssh" + "sed"))))