mirror of
https://codeberg.org/hako/Rosenthal.git
synced 2025-10-14 17:34:35 +00:00
utils: Update ‘go mod vendor’ based fetch implementation.
This commit is contained in:
parent
975db02439
commit
3d4b11edc7
@ -9,8 +9,11 @@
|
|||||||
#:use-module (guix git-download)
|
#:use-module (guix git-download)
|
||||||
#:use-module (guix packages)
|
#:use-module (guix packages)
|
||||||
#:use-module (rosenthal utils download)
|
#:use-module (rosenthal utils download)
|
||||||
|
#:use-module (gnu packages base)
|
||||||
|
#:use-module (gnu packages dns)
|
||||||
#:use-module (gnu packages golang)
|
#:use-module (gnu packages golang)
|
||||||
#:use-module (gnu packages golang-build))
|
#:use-module (gnu packages golang-build)
|
||||||
|
#:use-module (gnu packages linux))
|
||||||
|
|
||||||
(define-public cloudflared
|
(define-public cloudflared
|
||||||
(package
|
(package
|
||||||
@ -92,10 +95,7 @@ a SOCKS5 proxy.")
|
|||||||
(package
|
(package
|
||||||
(name "tailscale")
|
(name "tailscale")
|
||||||
(version "1.80.3")
|
(version "1.80.3")
|
||||||
(source
|
(source (origin
|
||||||
(origin
|
|
||||||
(method go-vendored-fetch)
|
|
||||||
(uri (origin
|
|
||||||
(method git-fetch)
|
(method git-fetch)
|
||||||
(uri (git-reference
|
(uri (git-reference
|
||||||
(url "https://github.com/tailscale/tailscale")
|
(url "https://github.com/tailscale/tailscale")
|
||||||
@ -103,16 +103,17 @@ a SOCKS5 proxy.")
|
|||||||
(file-name (git-file-name name version))
|
(file-name (git-file-name name version))
|
||||||
(sha256
|
(sha256
|
||||||
(base32
|
(base32
|
||||||
"07s8kwksvd0f9r65zkrhp3sn4jrv0c8g5w0wbiv9qq950l8gdv2h"))))
|
"07s8kwksvd0f9r65zkrhp3sn4jrv0c8g5w0wbiv9qq950l8gdv2h"))
|
||||||
(file-name (git-file-name name version))
|
|
||||||
(sha256
|
|
||||||
(base32
|
|
||||||
"0g2pzazrfl41s1gra2g3ni34ddgw32mb2rjlv8x17g3yc7axdbqa"))
|
|
||||||
(modules '((guix build utils)))
|
(modules '((guix build utils)))
|
||||||
(snippet '(delete-file-recursively "tool"))))
|
(snippet
|
||||||
|
'(begin
|
||||||
|
(delete-file-recursively "tool")
|
||||||
|
(substitute* "net/tstun/tun_linux.go"
|
||||||
|
(("/sbin/(modprobe)" _ cmd) cmd))))))
|
||||||
(build-system go-build-system)
|
(build-system go-build-system)
|
||||||
(arguments
|
(arguments
|
||||||
(list
|
(list
|
||||||
|
#:tests? (not (%current-target-system)) ;TODO: Run test suite.
|
||||||
#:go go-1.23
|
#:go go-1.23
|
||||||
#:install-source? #f
|
#:install-source? #f
|
||||||
#:import-path "."
|
#:import-path "."
|
||||||
@ -120,25 +121,26 @@ a SOCKS5 proxy.")
|
|||||||
#~(list "-tags" "ts_include_cli"
|
#~(list "-tags" "ts_include_cli"
|
||||||
(string-append
|
(string-append
|
||||||
"-ldflags="
|
"-ldflags="
|
||||||
" -X tailscale.com/version.longStamp=v"
|
" -X tailscale.com/version.longStamp="
|
||||||
#$(package-version this-package)
|
#$(package-version this-package)
|
||||||
" -X tailscale.com/version.shortStamp=v"
|
" -X tailscale.com/version.shortStamp="
|
||||||
#$(package-version this-package)))
|
#$(package-version this-package)))
|
||||||
#:test-flags ''("-skip=^TestPackageDocs$")
|
|
||||||
#:test-subdirs ''(".")
|
|
||||||
#:modules
|
#:modules
|
||||||
'(((guix build gnu-build-system) #:prefix gnu:)
|
'((ice-9 match)
|
||||||
|
((guix build gnu-build-system) #:prefix gnu:)
|
||||||
(guix build go-build-system)
|
(guix build go-build-system)
|
||||||
(guix build utils))
|
(guix build utils))
|
||||||
#:phases
|
#:phases
|
||||||
#~(modify-phases %standard-phases
|
#~(modify-phases %standard-phases
|
||||||
(replace 'unpack
|
(replace 'unpack
|
||||||
(lambda args
|
(lambda args
|
||||||
|
(unsetenv "GO111MODULE")
|
||||||
(apply (assoc-ref gnu:%standard-phases 'unpack) args)
|
(apply (assoc-ref gnu:%standard-phases 'unpack) args)
|
||||||
(unsetenv "GO111MODULE")))
|
(copy-recursively
|
||||||
|
#+(this-package-native-input "vendored-go-dependencies")
|
||||||
|
"vendor")))
|
||||||
(replace 'install-license-files
|
(replace 'install-license-files
|
||||||
(assoc-ref gnu:%standard-phases 'install-license-files))
|
(assoc-ref gnu:%standard-phases 'install-license-files))
|
||||||
;; TODO: Fix command references.
|
|
||||||
(replace 'build
|
(replace 'build
|
||||||
(lambda* (#:key build-flags parallel-build? #:allow-other-keys)
|
(lambda* (#:key build-flags parallel-build? #:allow-other-keys)
|
||||||
(let* ((njobs (if parallel-build? (parallel-job-count) 1)))
|
(let* ((njobs (if parallel-build? (parallel-job-count) 1)))
|
||||||
@ -151,12 +153,69 @@ a SOCKS5 proxy.")
|
|||||||
,(string-append "tailscale.com/cmd/" pkg))))
|
,(string-append "tailscale.com/cmd/" pkg))))
|
||||||
'("derper"
|
'("derper"
|
||||||
"derpprobe"
|
"derpprobe"
|
||||||
"tailscale"
|
"tailscaled"
|
||||||
|
"tsidp")))))
|
||||||
|
(add-after 'install 'install-extras
|
||||||
|
(lambda _
|
||||||
|
(symlink (in-vicinity #$output "bin/tailscaled")
|
||||||
|
(in-vicinity #$output "bin/tailscale"))
|
||||||
|
(let ((tailscale
|
||||||
|
(or (which "tailscale")
|
||||||
|
(in-vicinity #$output "bin/tailscale"))))
|
||||||
|
(map
|
||||||
|
(match-lambda
|
||||||
|
((shell . path)
|
||||||
|
(let ((file (in-vicinity #$output path)))
|
||||||
|
(mkdir-p (dirname file))
|
||||||
|
(with-output-to-file file
|
||||||
|
(lambda ()
|
||||||
|
(invoke tailscale "completion" shell))))))
|
||||||
|
'(("bash" . "etc/bash_completion.d/tailscale")
|
||||||
|
("fish" . "share/fish/vendor_completions.d/tailscale.fish")
|
||||||
|
("zsh" . "share/zsh/site-functions/_tailscale"))))))
|
||||||
|
(add-after 'install 'wrap-binaries
|
||||||
|
(lambda* (#:key inputs #:allow-other-keys)
|
||||||
|
(wrap-program (in-vicinity #$output "bin/tailscaled")
|
||||||
|
`("PATH" ":" prefix
|
||||||
|
,(map (lambda (cmd)
|
||||||
|
(dirname (search-input-file inputs cmd)))
|
||||||
|
'("bin/find"
|
||||||
|
"bin/getent"
|
||||||
|
"bin/modprobe"
|
||||||
|
"sbin/ip"
|
||||||
|
"sbin/iptables"
|
||||||
|
"sbin/resolvconf"
|
||||||
|
"sbin/sysctl"))))))
|
||||||
|
(delete 'check)
|
||||||
|
(add-after 'install 'check
|
||||||
|
(lambda* (#:key tests? #:allow-other-keys)
|
||||||
|
(when tests?
|
||||||
|
(for-each
|
||||||
|
(lambda (cmd)
|
||||||
|
(invoke (string-append #$output "/bin/" cmd) "--help"))
|
||||||
|
'("derper"
|
||||||
|
"derpprobe"
|
||||||
"tailscaled"
|
"tailscaled"
|
||||||
"tsidp"))))))))
|
"tsidp"))))))))
|
||||||
|
(native-inputs
|
||||||
|
(append
|
||||||
|
(list (origin
|
||||||
|
(method (go-mod-vendor #:go go-1.23))
|
||||||
|
(uri (package-source this-package))
|
||||||
|
(file-name "vendored-go-dependencies")
|
||||||
|
(sha256
|
||||||
|
(base32
|
||||||
|
"1lp5xqb9nmz1dqmmvdnnl0qla7zw6v25jbyf6shrl65rh270wmgk"))))
|
||||||
|
(if (%current-target-system)
|
||||||
|
(list this-package)
|
||||||
|
'())))
|
||||||
|
(inputs
|
||||||
|
(list findutils glibc iproute iptables-nft kmod openresolv procps))
|
||||||
(home-page "https://tailscale.com/")
|
(home-page "https://tailscale.com/")
|
||||||
(synopsis "Private WireGuard® networks made easy")
|
(synopsis "Mesh VPN service utilizing the WireGuard protocol and 2FA")
|
||||||
(description
|
(description
|
||||||
"This package provides @command{tailscale}, which brings an easy and secure
|
"Tailscale is a mesh VPN service that simplifies the process of securely
|
||||||
way to use WireGuard and 2FA.")
|
connecting devices and services across various networks. It allows you to
|
||||||
|
create a private network with minimal configuration and aims to remove the
|
||||||
|
complexity of building a trusted and secure network.")
|
||||||
(license license:bsd-3)))
|
(license license:bsd-3)))
|
||||||
|
@ -34,11 +34,8 @@
|
|||||||
(define-public hugo
|
(define-public hugo
|
||||||
(package
|
(package
|
||||||
(name "hugo")
|
(name "hugo")
|
||||||
(version "0.145.0")
|
(version "0.147.2")
|
||||||
(source
|
(source (origin
|
||||||
(origin
|
|
||||||
(method go-vendored-fetch)
|
|
||||||
(uri (origin
|
|
||||||
(method git-fetch)
|
(method git-fetch)
|
||||||
(uri (git-reference
|
(uri (git-reference
|
||||||
(url "https://github.com/gohugoio/hugo")
|
(url "https://github.com/gohugoio/hugo")
|
||||||
@ -46,10 +43,7 @@
|
|||||||
(file-name (git-file-name name version))
|
(file-name (git-file-name name version))
|
||||||
(sha256
|
(sha256
|
||||||
(base32
|
(base32
|
||||||
"19kfij8c1ljfn8xr3mfm5c89fhp62bl0c7rx0i8726jn6dbpl9g5"))))
|
"0j0grh8sxd6ma9g406cbcwhwgfdazc4lg3r7jmiyrw2287d218yz"))))
|
||||||
(sha256
|
|
||||||
(base32
|
|
||||||
"10fmva8p4hcbs2kyjggbanrmix1mf1fym549c5zdv80khpppzfnb"))))
|
|
||||||
(build-system go-build-system)
|
(build-system go-build-system)
|
||||||
(arguments
|
(arguments
|
||||||
(list
|
(list
|
||||||
@ -57,8 +51,10 @@
|
|||||||
#:install-source? #f
|
#:install-source? #f
|
||||||
#:import-path "."
|
#:import-path "."
|
||||||
#:build-flags
|
#:build-flags
|
||||||
''("-tags" "extended withdeploy"
|
#~(list "-tags" "extended withdeploy"
|
||||||
"-ldflags=-X github.com/gohugoio/hugo/common/hugo.vendorInfo=Nonguix")
|
(string-append
|
||||||
|
"-ldflags="
|
||||||
|
" -X github.com/gohugoio/hugo/common/hugo.vendorInfo=Nonguix"))
|
||||||
#:test-flags ''("-skip=^TestCommands/mod|^TestCommands/server")
|
#:test-flags ''("-skip=^TestCommands/mod|^TestCommands/server")
|
||||||
#:test-subdirs ''(".")
|
#:test-subdirs ''(".")
|
||||||
#:modules
|
#:modules
|
||||||
@ -69,35 +65,52 @@
|
|||||||
#~(modify-phases %standard-phases
|
#~(modify-phases %standard-phases
|
||||||
(replace 'unpack
|
(replace 'unpack
|
||||||
(lambda args
|
(lambda args
|
||||||
|
(unsetenv "GO111MODULE")
|
||||||
(apply (assoc-ref gnu:%standard-phases 'unpack) args)
|
(apply (assoc-ref gnu:%standard-phases 'unpack) args)
|
||||||
(unsetenv "GO111MODULE")))
|
(copy-recursively
|
||||||
|
#+(this-package-native-input "vendored-go-dependencies")
|
||||||
|
"vendor")))
|
||||||
(replace 'install-license-files
|
(replace 'install-license-files
|
||||||
(assoc-ref gnu:%standard-phases 'install-license-files))
|
(assoc-ref gnu:%standard-phases 'install-license-files))
|
||||||
(add-after 'unpack 'fix-paths
|
(add-after 'unpack 'fix-paths
|
||||||
(lambda* (#:key inputs #:allow-other-keys)
|
(lambda* (#:key native-inputs inputs #:allow-other-keys)
|
||||||
(setenv "C_INCLUDE_PATH"
|
(setenv "C_INCLUDE_PATH"
|
||||||
(string-append
|
(string-append
|
||||||
(getenv "C_INCLUDE_PATH") ":"
|
(getenv "C_INCLUDE_PATH") ":"
|
||||||
(dirname
|
(dirname
|
||||||
(dirname
|
(dirname
|
||||||
(dirname
|
(dirname
|
||||||
(search-input-file inputs "src/dec/alphai_dec.h"))))))
|
(search-input-file
|
||||||
|
(or native-inputs inputs)
|
||||||
|
"src/dec/alphai_dec.h"))))))
|
||||||
(with-directory-excursion "vendor/github.com/bep/gowebp"
|
(with-directory-excursion "vendor/github.com/bep/gowebp"
|
||||||
(substitute* (find-files "internal/libwebp")
|
(substitute* (find-files "internal/libwebp")
|
||||||
(("../../libwebp_src/(.*)\"" _ file)
|
(("../../libwebp_src/(.*)\"" _ file)
|
||||||
(string-append (search-input-file inputs file) "\""))))
|
(format #f "~a\""
|
||||||
|
(search-input-file
|
||||||
|
(or native-inputs inputs) file)))))
|
||||||
(with-directory-excursion "vendor/github.com/bep/golibsass"
|
(with-directory-excursion "vendor/github.com/bep/golibsass"
|
||||||
(substitute* (find-files "internal/libsass")
|
(substitute* (find-files "internal/libsass")
|
||||||
(("../../libsass_src/(.*)\"" _ file)
|
(("../../libsass_src/(.*)\"" _ file)
|
||||||
(string-append (search-input-file inputs file) "\"")))))))))
|
(format #f "~a\""
|
||||||
(inputs
|
(search-input-file
|
||||||
(list (package-source libsass)
|
(or native-inputs inputs) file))))))))))
|
||||||
|
(native-inputs
|
||||||
|
(list (origin
|
||||||
|
(method (go-mod-vendor #:go go-1.23))
|
||||||
|
(uri (package-source this-package))
|
||||||
|
(file-name "vendored-go-dependencies")
|
||||||
|
(sha256
|
||||||
|
(base32
|
||||||
|
"1pwq7i0y2gb4cw9nriy699wa6pqlhz42rjkzv39g355nyszwpyj8")))
|
||||||
|
(package-source libsass)
|
||||||
(package-source libwebp)))
|
(package-source libwebp)))
|
||||||
(home-page "https://gohugo.io/")
|
(home-page "https://gohugo.io/")
|
||||||
(synopsis "Static site generator")
|
(synopsis "Static site generator written in Go")
|
||||||
(description
|
(description
|
||||||
"Hugo is a static site generator written in Go, optimized for speed and
|
"Hugo is a static site generator written in Go, optimized for speed and
|
||||||
designed for flexibility.")
|
designed for flexibility. With its advanced templating system and fast asset
|
||||||
|
pipelines, Hugo renders a complete site in seconds, often less.")
|
||||||
(license license:asl2.0)))
|
(license license:asl2.0)))
|
||||||
|
|
||||||
;; TODO: Package Forgejo without vendored dependencies.
|
;; TODO: Package Forgejo without vendored dependencies.
|
||||||
|
@ -6,45 +6,41 @@
|
|||||||
#:use-module (guix gexp)
|
#:use-module (guix gexp)
|
||||||
#:use-module (guix packages)
|
#:use-module (guix packages)
|
||||||
#:use-module (guix build-system gnu)
|
#:use-module (guix build-system gnu)
|
||||||
#:use-module (guix build-system go)
|
#:export (go-mod-vendor))
|
||||||
#:export (go-vendored-fetch))
|
|
||||||
|
;;;
|
||||||
|
;;; ‘go mod vendor’ based fetcher
|
||||||
|
;;;
|
||||||
|
|
||||||
|
(define* (go-mod-vendor #:key go)
|
||||||
|
(lambda* (src hash-algo hash #:optional name #:key (system (%current-system)))
|
||||||
|
(define nss-certs
|
||||||
|
(module-ref (resolve-interface '(gnu packages certs)) 'nss-certs))
|
||||||
|
|
||||||
;; NOTE: This approach shouldn't be upstreamed.
|
|
||||||
(define* (go-vendored-fetch src hash-algo hash
|
|
||||||
#:optional name
|
|
||||||
#:key (system (%current-system))
|
|
||||||
(go
|
|
||||||
(module-ref
|
|
||||||
(resolve-interface '(gnu packages golang))
|
|
||||||
;; Use latest Go in Guix.
|
|
||||||
'go-1.23))
|
|
||||||
(nss-certs
|
|
||||||
(module-ref
|
|
||||||
(resolve-interface '(gnu packages certs))
|
|
||||||
'nss-certs)))
|
|
||||||
(gexp->derivation
|
(gexp->derivation
|
||||||
(or name
|
(or name "vendored-go-dependencies")
|
||||||
(string-append (origin-file-name src) "-vendored"))
|
|
||||||
(with-imported-modules %default-gnu-imported-modules
|
(with-imported-modules %default-gnu-imported-modules
|
||||||
#~(begin
|
#~(begin
|
||||||
(use-modules (guix build gnu-build-system)
|
(use-modules (guix build gnu-build-system)
|
||||||
(guix build utils))
|
(guix build utils))
|
||||||
(setenv "GOCACHE" "/tmp/go")
|
|
||||||
(setenv "GOMODCACHE" "/tmp/gomod")
|
|
||||||
(setenv "SSL_CERT_DIR" #+(file-append nss-certs "/etc/ssl/certs"))
|
|
||||||
;; Support Unicode in file name.
|
;; Support Unicode in file name.
|
||||||
(setlocale LC_ALL "C.UTF-8")
|
(setlocale LC_ALL "C.UTF-8")
|
||||||
|
;; For HTTPS support.
|
||||||
|
(setenv "SSL_CERT_DIR" #+(file-append nss-certs "/etc/ssl/certs"))
|
||||||
|
|
||||||
((assoc-ref %standard-phases 'unpack) #:source #+src)
|
((assoc-ref %standard-phases 'unpack) #:source #+src)
|
||||||
(invoke #+(file-append go "/bin/go") "mod" "vendor")
|
(invoke #+(file-append go "/bin/go") "mod" "vendor")
|
||||||
(copy-recursively "." #$output)))
|
(copy-recursively "vendor" #$output)))
|
||||||
#:system system
|
#:system system
|
||||||
#:hash-algo hash-algo
|
#:hash-algo hash-algo
|
||||||
#:hash hash
|
#:hash hash
|
||||||
;; Is a directory.
|
;; Is a directory.
|
||||||
#:recursive? #t
|
#:recursive? #t
|
||||||
|
#:env-vars '(("GOCACHE" . "/tmp/go-cache")
|
||||||
|
("GOPATH" . "/tmp/go"))
|
||||||
;; Honor the user's proxy and locale settings.
|
;; Honor the user's proxy and locale settings.
|
||||||
#:leaked-env-vars '("http_proxy" "https_proxy"
|
#:leaked-env-vars '("GOPROXY"
|
||||||
|
"http_proxy" "https_proxy"
|
||||||
"LC_ALL" "LC_MESSAGES" "LANG"
|
"LC_ALL" "LC_MESSAGES" "LANG"
|
||||||
"COLUMNS")
|
"COLUMNS")
|
||||||
#:local-build? #t))
|
#:local-build? #t)))
|
||||||
|
Loading…
Reference in New Issue
Block a user