build-system: Add go-vendored-build-system.

* modules/rosenthal/utils/download.scm (go-mod-vendor): Sync with Nonguix.
* modules/rosenthal/build/go-vendored-build-system.scm
* modules/rosenthal/build-system/go-vendored.scm: New files.
* modules/rosenthal/packages/networking.scm (cloudflared, mihomo, sing-box)
(tailscale): Use go-vendored-build-system.
* modules/rosenthal/packages/web.scm (anubis-anti-crawler, caddy, caddy/dolly)
(forgejo): Likewise.
This commit is contained in:
Hilton Chain committed 2026-06-28 19:41:05 +08:00
1 parent ffce98cafe
commit 8bf6002818
5 files changed
+377 -152

No files matched your search

+26 -88
View File
@@ -12,6 +12,7 @@
#:use-module (rosenthal utils download)
;; Guix build systems
#:use-module (guix build-system go)
#:use-module (rosenthal build-system go-vendored)
;; Guix packages
#:use-module (gnu packages base)
#:use-module (gnu packages dns)
@@ -36,12 +37,11 @@
(sha256
(base32
"092745jrmq6cqgad0cbkq9jiybq9s9by22y7fbr5y2rj7gw01cyy"))))
(build-system go-build-system)
(build-system go-vendored-build-system)
(arguments
(list #:go go-1.26
#:install-source? #f
#:import-path "github.com/cloudflare/cloudflared/cmd/cloudflared"
#:unpack-path "github.com/cloudflare/cloudflared"
#:import-path "./cmd/cloudflared"
#:build-flags
#~(list (string-append
"-ldflags="
@@ -49,12 +49,9 @@
" -X github.com/cloudflare/cloudflared/cmd/cloudflared/updater.BuiltForPackageManager=Guix"))
#:phases
#~(modify-phases %standard-phases
(add-before 'build 'disable-cgo
(lambda _
(setenv "CGO_ENABLED" "0")))
(add-after 'install 'install-documentation
(lambda _
(let ((src "src/github.com/cloudflare/cloudflared/cloudflared_man_template")
(let ((src "cloudflared_man_template")
(dst (string-append #$output "/share/man/man1/cloudflared.1")))
(substitute* src
(("\\$\\{VERSION\\}") #$(package-version this-package)))
@@ -84,35 +81,21 @@ origin can remain as closed as possible.")
(sha256
(base32
"16vhaq2h67al39k1757vvfgzav8bdkhsa5m5z6km3cw7h6l0rk82"))))
(build-system go-build-system)
(build-system go-vendored-build-system)
(arguments
(list
#:tests? (not (%current-target-system)) ;TODO: Run test suite.
#:go go-1.26
#:vendor-hash (base32 "0kz38byz4q18234z8i9gbc6728dch8lfzw54spng736x3wql2an9")
#:tests? (not (%current-target-system)) ;TODO: Run test suite.
#:install-source? #f
#:import-path "."
#:build-flags
#~(list "-tags" "with_gvisor"
(string-append
"-ldflags="
" -X github.com/metacubex/mihomo/constant.Version="
#$(package-version this-package)))
#:modules
'((ice-9 match)
((guix build gnu-build-system) #:prefix gnu:)
(guix build go-build-system)
(guix build utils))
#:phases
#~(modify-phases %standard-phases
(replace 'unpack
(lambda args
(unsetenv "GO111MODULE")
(apply (assoc-ref gnu:%standard-phases 'unpack) args)
(copy-recursively
#+(this-package-native-input "vendored-go-dependencies")
"vendor")))
(replace 'install-license-files
(assoc-ref gnu:%standard-phases 'install-license-files))
(delete 'check)
(add-after 'install 'check
(lambda* (#:key tests? #:allow-other-keys)
@@ -121,17 +104,9 @@ origin can remain as closed as possible.")
(invoke mihomo "--help")
(invoke mihomo "-v"))))))))
(native-inputs
(append
(list (origin
(method (go-mod-vendor #:go go-1.26))
(uri (package-source this-package))
(file-name "vendored-go-dependencies")
(sha256
(base32
"0kz38byz4q18234z8i9gbc6728dch8lfzw54spng736x3wql2an9"))))
(if (%current-target-system)
(list this-package)
'())))
(if (%current-target-system)
(list this-package)
'()))
(home-page "https://wiki.metacubex.one/")
(synopsis "Rule-based proxy")
(description
@@ -154,10 +129,11 @@ bypass network restrictions." )
(sha256
(base32
"0b5hp696dsh0sl1640726wg36cssdllpc903k7v3sn0q6p9zysq0"))))
(build-system go-build-system)
(build-system go-vendored-build-system)
(arguments
(list
#:go go-1.26
#:vendor-hash (base32 "0gzjdjq94vkbsyr2m37wjpd37m4whksgsp4kcmh6j293vfwc83ll")
#:install-source? #f
#:import-path "./cmd/sing-box"
#:build-flags
@@ -175,22 +151,11 @@ bypass network restrictions." )
" -X github.com/sagernet/sing-box/constant.Version="
#$(package-version this-package)))
#:modules
'((ice-9 match)
((guix build gnu-build-system) #:prefix gnu:)
(guix build go-build-system)
(guix build utils))
(cons '(ice-9 match)
%default-go-vendored-modules)
#:phases
#~(modify-phases %standard-phases
(replace 'unpack
(lambda args
(unsetenv "GO111MODULE")
(apply (assoc-ref gnu:%standard-phases 'unpack) args)
(copy-recursively
#+(this-package-native-input "vendored-go-dependencies")
"vendor")))
(replace 'install-license-files
(assoc-ref gnu:%standard-phases 'install-license-files))
(add-after 'unpack 'set-tailscale-default-wireguard-port
(add-after 'unpack-vendored-dependencies 'set-tailscale-default-wireguard-port
(lambda _
;; See also: https://tailscale.com/kb/1082/firewall-ports
;; https://github.com/tailscale/tailscale/blob/51c11a864b1241d1cf1a736fbc94b0f8c76da563/cmd/tailscaled/tailscaled.go#L102
@@ -213,17 +178,9 @@ bypass network restrictions." )
("fish" . "share/fish/vendor_completions.d/sing-box.fish")
("zsh" . "share/zsh/site-functions/_sing-box")))))))))
(native-inputs
(append
(list (origin
(method (go-mod-vendor #:go go-1.26))
(uri (package-source this-package))
(file-name "vendored-go-dependencies")
(sha256
(base32
"0gzjdjq94vkbsyr2m37wjpd37m4whksgsp4kcmh6j293vfwc83ll"))))
(if (%current-target-system)
(list this-package)
'())))
(if (%current-target-system)
(list this-package)
'()))
(home-page "https://sing-box.sagernet.org/")
(synopsis "Universal proxy platform")
(description
@@ -280,13 +237,13 @@ a SOCKS5 proxy.")
(delete-file-recursively "tool")
(substitute* "net/tstun/tun_linux.go"
(("/sbin/(modprobe)" _ cmd) cmd))))))
(build-system go-build-system)
(build-system go-vendored-build-system)
(arguments
(list
#:tests? (not (%current-target-system)) ;TODO: Run test suite.
#:go go-1.26
#:vendor-hash (base32 "1ffhpdb5lyfgdb1n7sps8zxs85g725ijx7sir6q0h1lk3mflpg4r")
#:tests? (not (%current-target-system)) ;TODO: Run test suite.
#:install-source? #f
#:import-path "."
#:build-flags
#~(list "-tags" "ts_include_cli"
(string-append
@@ -296,21 +253,10 @@ a SOCKS5 proxy.")
" -X tailscale.com/version.shortStamp="
#$(package-version this-package)))
#:modules
'((ice-9 match)
((guix build gnu-build-system) #:prefix gnu:)
(guix build go-build-system)
(guix build utils))
(cons '(ice-9 match)
%default-go-vendored-modules)
#:phases
#~(modify-phases %standard-phases
(replace 'unpack
(lambda args
(unsetenv "GO111MODULE")
(apply (assoc-ref gnu:%standard-phases 'unpack) args)
(copy-recursively
#+(this-package-native-input "vendored-go-dependencies")
"vendor")))
(replace 'install-license-files
(assoc-ref gnu:%standard-phases 'install-license-files))
(add-after 'unpack 'patch-references
(lambda* (#:key inputs #:allow-other-keys)
(substitute* "client/systray/startup-creator.go"
@@ -373,17 +319,9 @@ a SOCKS5 proxy.")
"tailscaled"
"tsidp"))))))))
(native-inputs
(append
(list (origin
(method (go-mod-vendor #:go go-1.26))
(uri (package-source this-package))
(file-name "vendored-go-dependencies")
(sha256
(base32
"1ffhpdb5lyfgdb1n7sps8zxs85g725ijx7sir6q0h1lk3mflpg4r"))))
(if (%current-target-system)
(list this-package)
'())))
(if (%current-target-system)
(list this-package)
'()))
(inputs
(list desktop-file-utils
findutils
+11 -56
View File
@@ -16,6 +16,7 @@
#:use-module (guix build-system cargo)
#:use-module (guix build-system copy)
#:use-module (guix build-system go)
#:use-module (rosenthal build-system go-vendored)
;; Guix packages
#:use-module (gnu packages golang)
#:use-module (gnu packages image)
@@ -66,7 +67,7 @@ website owners block unwanted AI crawlers from accessing their sites.")
(sha256
(base32
"0kqp5j0739lpdw55gx4bnnda1b90qlavcdlp8vh9bp014xx84yqj"))))
(build-system go-build-system)
(build-system go-vendored-build-system)
(arguments
(list #:tests? (not (%current-target-system)) ;FIXME
#:go go-1.26
@@ -77,18 +78,8 @@ website owners block unwanted AI crawlers from accessing their sites.")
"-ldflags="
" -X github.com/TecharoHQ/anubis.Version="
#$(package-version this-package)))
#:modules
'(((guix build gnu-build-system) #:prefix gnu:)
(guix build go-build-system)
(guix build utils))
#:phases
#~(modify-phases %standard-phases
(replace 'unpack
(lambda args
(unsetenv "GO111MODULE")
(apply (assoc-ref gnu:%standard-phases 'unpack) args)))
(replace 'install-license-files
(assoc-ref gnu:%standard-phases 'install-license-files))
(delete 'check)
(add-after 'install 'check
(lambda* (#:key tests? #:allow-other-keys)
@@ -117,9 +108,10 @@ order to protect upstream resources from web crawlers.")
(sha256
(base32
"1a0w7i99p277kwbxfd5zf8d55n24z27i377njzqdc3jxp6ijcy7c"))))
(build-system go-build-system)
(build-system go-vendored-build-system)
(arguments
(list #:go go-1.26
#:vendor-hash (base32 "1vnqildhrrmicq9zazk8c2b3d7jqj197r4wxczg4j58qig2mj9j2")
#:tests? (not (%current-target-system)) ;TODO: Run test suite.
#:install-source? #f
#:import-path
@@ -133,21 +125,10 @@ order to protect upstream resources from web crawlers.")
" -X github.com/caddyserver/caddy/v2.CustomVersion="
#$(package-version this-package)))
#:modules
'((ice-9 match)
((guix build gnu-build-system) #:prefix gnu:)
(guix build go-build-system)
(guix build utils))
(cons '(ice-9 match)
%default-go-vendored-modules)
#:phases
#~(modify-phases %standard-phases
(replace 'unpack
(lambda args
(unsetenv "GO111MODULE")
(apply (assoc-ref gnu:%standard-phases 'unpack) args)
(copy-recursively
#+(this-package-native-input "vendored-go-dependencies")
"vendor")))
(replace 'install-license-files
(assoc-ref gnu:%standard-phases 'install-license-files))
(add-after 'install 'install-extras
(lambda _
(let ((caddy
@@ -173,14 +154,6 @@ order to protect upstream resources from web crawlers.")
(let ((caddy (in-vicinity #$output "bin/caddy")))
(invoke caddy "help")
(invoke caddy "version"))))))))
(native-inputs
(list (origin
(method (go-mod-vendor #:go go-1.26))
(uri (package-source this-package))
(file-name "vendored-go-dependencies")
(sha256
(base32
"1vnqildhrrmicq9zazk8c2b3d7jqj197r4wxczg4j58qig2mj9j2")))))
(home-page "https://caddyserver.com/")
(synopsis "Extensible HTTP web server with automatic HTTPS")
(description
@@ -205,16 +178,10 @@ from serving static websites to running dynamic web applications.")
(sha256
(base32
"1b8606rbg57ylxz2q88335s04q8yvg6b33qkq3hk9895vwd74mq0"))))
(native-inputs
(modify-inputs native-inputs
(replace "vendored-go-dependencies"
(origin
(method (go-mod-vendor #:go go-1.26))
(uri (package-source this-package))
(file-name "vendored-go-dependencies")
(sha256
(base32
"0bwpayz2yf18cycffy02iiq88cl0smljimsf0yrdzrn1l3flg37s"))))))
(arguments
(substitute-keyword-arguments arguments
((#:vendor-hash _ #f)
(base32 "0bwpayz2yf18cycffy02iiq88cl0smljimsf0yrdzrn1l3flg37s"))))
(home-page "https://git.guix.moe/hako/caddy")
(properties '((disable-updater? . #t)))))
@@ -231,12 +198,11 @@ from serving static websites to running dynamic web applications.")
(sha256
(base32
"0mjmns7yqhhkqc3jcg8bffs64zj4b52hy2v1lvr14pq162r6wcil"))))
(build-system go-build-system)
(build-system go-vendored-build-system)
(arguments
(list #:tests? (not (%current-target-system)) ;TODO: Run test suite.
#:go go-1.26
#:install-source? #f
#:import-path "."
#:build-flags
#~(list (string-append
"-ldflags="
@@ -246,19 +212,8 @@ from serving static websites to running dynamic web applications.")
" -X forgejo.org/modules/setting.AppWorkPath=/var/lib/forgejo"
" -X forgejo.org/modules/setting.CustomPath=" #$output "/etc/forgejo"
" -X forgejo.org/modules/setting.CustomConf=/etc/forgejo/app.ini"))
#:modules
'(((guix build gnu-build-system) #:prefix gnu:)
(guix build go-build-system)
(guix build union)
(guix build utils))
#:phases
#~(modify-phases %standard-phases
(replace 'unpack
(lambda args
(unsetenv "GO111MODULE")
(apply (assoc-ref gnu:%standard-phases 'unpack) args)))
(replace 'install-license-files
(assoc-ref gnu:%standard-phases 'install-license-files))
(add-after 'install 'rename-binary
(lambda _
(rename-file (in-vicinity #$output "bin/forgejo.org")