Skip to content

Commit 8dd01fa

Browse files
Maxim CournoyerGusted
authored andcommitted
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 <mfenniak@noreply.codeberg.org>
1 parent 4131cc4 commit 8dd01fa

1 file changed

Lines changed: 49 additions & 15 deletions

File tree

manifest.scm

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,62 @@
1111
;;; made available to fetch required Go and Node dependencies.
1212
;;;
1313
#|
14+
1415
guix shell -CNF --share=$HOME -m manifest.scm
1516
export GOTOOLCHAIN=local # to use the Go binary from Guix
1617
export CC=gcc CGO_ENABLED=1
18+
# The following is to preserve debug info symbols:
19+
export STRIP=0 CGO_CFLAGS='-O0 -g' EXTRA_GOFLAGS='-gcflags="all=-N -l"'
1720
export TAGS="timetzdata sqlite sqlite_unlock_notify"
1821
make clean
1922
make -j$(nproc)
2023
make test -j$(nproc) # run unit tests
2124
make test-sqlite -j$(nproc) # run integration tests
2225
make watch # run an instance/rebuild on changes
26+
27+
# For debugging, you can either attach the delve debugger like this:
28+
dlv attach $(pgrep gitea)
29+
30+
# Or start Forgejo directly with it:
31+
dlv exec ./gitea
32+
2333
|#
24-
(specifications->manifest
25-
(list "bash-minimal"
26-
"coreutils"
27-
"findutils"
28-
"gcc-toolchain"
29-
"git" ;libpcre support is required
30-
"git-lfs"
31-
"gnupg"
32-
"go"
33-
"grep"
34-
"make"
35-
"node"
36-
"nss-certs"
37-
"openssh"
38-
"sed"))
34+
35+
(use-modules (guix packages)
36+
(guix utils))
37+
38+
(define go-1.26 ;minimal version required by Forgejo
39+
(specification->package "go@1.26"))
40+
41+
(define (package-with-go base go)
42+
"Return a variant of BASE, a Guix package object built with GO, another
43+
package."
44+
(package/inherit base
45+
(arguments (ensure-keyword-arguments (package-arguments base)
46+
(list #:go go)))))
47+
48+
(define packages-for-debugging
49+
(list (specification->package "procps") ;pgrep
50+
(package-with-go (specification->package "delve") go-1.26) ;debugger
51+
(package-with-go (specification->package "gomacro") go-1.26))) ;Go REPL
52+
53+
(concatenate-manifests
54+
(list
55+
(packages->manifest
56+
(append (list go-1.26)
57+
packages-for-debugging))
58+
(specifications->manifest
59+
(list "bash-minimal"
60+
"coreutils"
61+
"diffutils"
62+
"findutils"
63+
"gcc-toolchain"
64+
"git" ;libpcre support is required
65+
"git-lfs"
66+
"gnupg"
67+
"grep"
68+
"make"
69+
"node"
70+
"nss-certs"
71+
"openssh"
72+
"sed"))))

0 commit comments

Comments
 (0)