From 82a8dcc824e149c482ea879cb8d509c66a1d3c52 Mon Sep 17 00:00:00 2001 From: Hilton Chain Date: Sun, 27 Apr 2025 21:49:47 +0800 Subject: [PATCH 1/5] =?UTF-8?q?download:=20Add=20=E2=80=98go-mod-vendor?= =?UTF-8?q?=E2=80=99=20fetcher.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * nonguix/download.scm (go-mod-vendor): New procedure. --- nonguix/download.scm | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/nonguix/download.scm b/nonguix/download.scm index 0eb661ad..c5ecfb62 100644 --- a/nonguix/download.scm +++ b/nonguix/download.scm @@ -1,13 +1,17 @@ ;;; SPDX-License-Identifier: GPL-3.0-or-later ;;; Copyright © 2019 Julien Lepiller +;;; Copyright © 2025 Hilton Chain (define-module (nonguix download) #:use-module (guix derivations) + #:use-module (guix gexp) #:use-module (guix monads) #:use-module (guix packages) #:use-module (guix store) + #:use-module (guix build-system gnu) #:use-module (ice-9 match) - #:export (unredistributable-url-fetch)) + #:export (go-mod-vendor + unredistributable-url-fetch)) (define* (unredistributable-url-fetch url hash-algo hash #:optional name @@ -48,3 +52,41 @@ if you run a substitute server on your machine." ;; Do not substitute copyrighted material #:substitutable? #f))) + + +;;; +;;; ‘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)) + + (gexp->derivation + (or name "vendored-go-dependencies") + (with-imported-modules %default-gnu-imported-modules + #~(begin + (use-modules (guix build gnu-build-system) + (guix build utils)) + ;; Support Unicode in file name. + (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) + (invoke #+(file-append go "/bin/go") "mod" "vendor") + (copy-recursively "vendor" #$output))) + #:system system + #:hash-algo hash-algo + #:hash hash + ;; Is a directory. + #:recursive? #t + #:env-vars '(("GOCACHE" . "/tmp/go-cache") + ("GOPATH" . "/tmp/go")) + ;; Honor the user's proxy and locale settings. + #:leaked-env-vars '("GOPROXY" + "http_proxy" "https_proxy" + "LC_ALL" "LC_MESSAGES" "LANG" + "COLUMNS") + #:local-build? #t))) From 60d5822908afd3f472fe793e498b234a4f7ccb1b Mon Sep 17 00:00:00 2001 From: Hilton Chain Date: Fri, 9 May 2025 11:18:24 +0800 Subject: [PATCH 2/5] nongnu: hugo: Update to 0.147.2. * nongnu/packages/hugo.scm (hugo): Update to 0.147.2. [source]: Use git-fetch. [build-system]: Switch to go-build-system. [inputs]: Add vendor dependencies, libsass and libwebp sources. --- nongnu/packages/hugo.scm | 110 ++++++++++++++++++++++++++++----------- 1 file changed, 79 insertions(+), 31 deletions(-) diff --git a/nongnu/packages/hugo.scm b/nongnu/packages/hugo.scm index 1b11a5bb..7d11cac5 100644 --- a/nongnu/packages/hugo.scm +++ b/nongnu/packages/hugo.scm @@ -1,45 +1,93 @@ ;;; SPDX-License-Identifier: GPL-3.0-or-later ;;; Copyright © 2024 Romain Garbage +;;; Copyright © 2025 Hilton Chain (define-module (nongnu packages hugo) - #:use-module (nonguix build-system binary) - #:use-module (guix download) - #:use-module ((guix licenses) - #:prefix license:) + #:use-module (guix gexp) + #:use-module ((guix licenses) #:prefix license:) #:use-module (guix packages) - #:use-module (guix utils)) + #:use-module (guix utils) + #:use-module (guix git-download) + #:use-module (nonguix download) + #:use-module (guix build-system go) + #:use-module (gnu packages golang) + #:use-module (gnu packages image) + #:use-module (gnu packages web)) (define-public hugo (package (name "hugo") - (version "0.140.2") - (source - (origin - (method url-fetch) - (uri (string-append - "https://github.com/gohugoio/hugo/releases/download/v" version - "/" name "_" version "_linux-" (cond ((target-aarch64?) - "arm64") - ((target-arm32?) - "arm") - ((target-x86-64?) - "amd64") - (else "")) ".tar.gz")) - (sha256 - (base32 (cond ((target-aarch64?) - "1dv2k9j3i3294bl94jhwi645pf5r2143hizxd3xpc3fz8w8cfyy8") - ((target-arm32?) - "0f3mirqn3x2lrj7gzjyqklj081y7jfyxww2zkccg9f6jq0vcfcxd") - ((target-x86-64?) - "0hs4b3nrr1qajrh7f64ibwjrfipqllvifp526kf2gfxnhpkr67l8") - (else "")))))) - (build-system binary-build-system) + (version "0.147.2") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/gohugoio/hugo") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0j0grh8sxd6ma9g406cbcwhwgfdazc4lg3r7jmiyrw2287d218yz")))) + (build-system go-build-system) (arguments (list - #:install-plan ''(("hugo" "/bin/hugo")))) - (supported-systems (list "aarch64-linux" - "armhf-linux" - "x86_64-linux")) + #:go go-1.23 + #:install-source? #f + #:import-path "." + #:build-flags + #~(list "-tags" "extended withdeploy" + (string-append + "-ldflags=" + " -X github.com/gohugoio/hugo/common/hugo.vendorInfo=Nonguix")) + #:test-flags ''("-skip=^TestCommands/mod|^TestCommands/server") + #:test-subdirs ''(".") + #: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) + (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 'fix-paths + (lambda* (#:key native-inputs inputs #:allow-other-keys) + (setenv "C_INCLUDE_PATH" + (string-append + (getenv "C_INCLUDE_PATH") ":" + (dirname + (dirname + (dirname + (search-input-file + (or native-inputs inputs) + "src/dec/alphai_dec.h")))))) + (with-directory-excursion "vendor/github.com/bep/gowebp" + (substitute* (find-files "internal/libwebp") + (("../../libwebp_src/(.*)\"" _ file) + (format #f "~a\"" + (search-input-file + (or native-inputs inputs) file))))) + (with-directory-excursion "vendor/github.com/bep/golibsass" + (substitute* (find-files "internal/libsass") + (("../../libsass_src/(.*)\"" _ file) + (format #f "~a\"" + (search-input-file + (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))) (home-page "https://gohugo.io/") (synopsis "Static site generator written in Go") (description From 95aa767e4716216b44db8aaa17314f29f8157df5 Mon Sep 17 00:00:00 2001 From: Hilton Chain Date: Fri, 9 May 2025 22:33:58 +0800 Subject: [PATCH 3/5] nongnu: Add tailscale. * nongnu/packages/networking.scm: New file. --- nongnu/packages/networking.scm | 144 +++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 nongnu/packages/networking.scm diff --git a/nongnu/packages/networking.scm b/nongnu/packages/networking.scm new file mode 100644 index 00000000..70a1c890 --- /dev/null +++ b/nongnu/packages/networking.scm @@ -0,0 +1,144 @@ +;;; SPDX-License-Identifier: GPL-3.0-or-later +;;; Copyright © 2025 Hilton Chain + +(define-module (nongnu packages networking) + #:use-module (guix gexp) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix packages) + #:use-module (guix utils) + #:use-module (guix git-download) + #:use-module (nonguix download) + #:use-module (guix build-system go) + #:use-module (gnu packages base) + #:use-module (gnu packages dns) + #:use-module (gnu packages golang) + #:use-module (gnu packages linux)) + +(define-public tailscale + (package + (name "tailscale") + (version "1.80.3") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/tailscale/tailscale") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "07s8kwksvd0f9r65zkrhp3sn4jrv0c8g5w0wbiv9qq950l8gdv2h")) + (modules '((guix build utils))) + (snippet + '(begin + (delete-file-recursively "tool") + (substitute* "net/tstun/tun_linux.go" + (("/sbin/(modprobe)" _ cmd) cmd)))))) + (build-system go-build-system) + (arguments + (list + #:tests? (not (%current-target-system)) ;TODO: Run test suite. + #:go go-1.23 + #:install-source? #f + #:import-path "." + #:build-flags + #~(list "-tags" "ts_include_cli" + (string-append + "-ldflags=" + " -X tailscale.com/version.longStamp=" + #$(package-version this-package) + " -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)) + #: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)) + (replace 'build + (lambda* (#:key build-flags parallel-build? #:allow-other-keys) + (let* ((njobs (if parallel-build? (parallel-job-count) 1))) + (setenv "GOMAXPROCS" (number->string njobs)) + (for-each + (lambda (pkg) + (apply invoke "go" "build" "-ldflags=-s -w" "-trimpath" + "-o" (string-append #$output "/bin/" pkg) + `(,@build-flags + ,(string-append "tailscale.com/cmd/" pkg)))) + '("derper" + "derpprobe" + "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" + "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/") + (synopsis "Mesh VPN service utilizing the WireGuard protocol and 2FA") + (description + "Tailscale is a mesh VPN service that simplifies the process of securely +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))) From 093b19bab8a2d0552c94fb145b872fd54d52a475 Mon Sep 17 00:00:00 2001 From: Hilton Chain Date: Sun, 11 May 2025 00:22:41 +0800 Subject: [PATCH 4/5] nongnu: Add forgejo. * nongnu/packages/web.scm: New file. --- nongnu/packages/web.scm | 90 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 nongnu/packages/web.scm diff --git a/nongnu/packages/web.scm b/nongnu/packages/web.scm new file mode 100644 index 00000000..1c84823c --- /dev/null +++ b/nongnu/packages/web.scm @@ -0,0 +1,90 @@ +;;; SPDX-License-Identifier: GPL-3.0-or-later +;;; Copyright © 2025 Hilton Chain + +(define-module (nongnu packages web) + #:use-module (guix gexp) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix packages) + #:use-module (guix utils) + #:use-module (guix download) + #:use-module (guix git-download) + #:use-module (nonguix download) + #:use-module (guix build-system go) + #:use-module (gnu packages golang) + #:use-module (gnu packages version-control)) + +(define-public forgejo + (package + (name "forgejo") + (version "10.0.3") + ;; TODO: Address npm dependencies and fetch from git. + (source (origin + (method url-fetch) + (uri (string-append + "https://codeberg.org/forgejo/forgejo/releases/download/v" + version "/forgejo-src-" version ".tar.gz")) + (sha256 + (base32 + "0cqp4x3xrvr7q1pkijqmf6jnx3wahi20xjfrv7ap81ykif83269x")) + (modules '((guix build utils))) + ;; Avoid downloading toolchain. + (snippet '(substitute* "go.mod" + (("^toolchain.*") ""))))) + (build-system go-build-system) + (arguments + (list #:tests? (not (%current-target-system)) ;TODO: Run test suite. + #:go go-1.23 + #:install-source? #f + #:import-path "." + #:build-flags + #~(list (string-append + "-ldflags=" + " -X main.ReleaseVersion=" #$(package-version this-package) + " -X main.Version=" #$(package-version this-package) + " -X main.ForgejoVersion=" #$(package-version this-package) + " -X code.gitea.io/gitea/modules/setting.AppWorkPath=/var/lib/forgejo" + " -X code.gitea.io/gitea/modules/setting.CustomPath=" #$output "/etc/forgejo" + " -X code.gitea.io/gitea/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/gitea") + (in-vicinity #$output "bin/forgejo")))) + (add-after 'install 'install-extras + (lambda _ + (mkdir-p (in-vicinity #$output "/etc/forgejo")) + (copy-file "custom/conf/app.example.ini" + (in-vicinity #$output "etc/forgejo/app.ini")) + (for-each + (lambda (dir) + (copy-recursively + dir (string-append #$output "/etc/forgejo/" dir))) + '("options" "public" "templates")))) + (delete 'check) + (add-after 'install 'check + (lambda* (#:key tests? #:allow-other-keys) + (when tests? + (let ((gitea (in-vicinity #$output "bin/gitea"))) + (invoke gitea "--help") + (invoke gitea "--version")))))))) + (native-inputs (list git-minimal)) + (home-page "https://forgejo.org/") + (synopsis "Lightweight software forge") + (description + "Forgejo is a self-hosted, lightweight software forge designed to +facilitate collaborative software development. It is built to be easy to +install and maintain, making it an ideal choice for teams and organizations +looking for a reliable platform to manage their software projects.") + (license license:gpl3+))) From e862bf3e95f187ceb9d1a858a56093a81573e394 Mon Sep 17 00:00:00 2001 From: Hilton Chain Date: Sun, 11 May 2025 00:42:38 +0800 Subject: [PATCH 5/5] nongnu: Add caddy. * nongnu/packages/web.scm (caddy): New variable. --- nongnu/packages/web.scm | 87 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/nongnu/packages/web.scm b/nongnu/packages/web.scm index 1c84823c..82113e09 100644 --- a/nongnu/packages/web.scm +++ b/nongnu/packages/web.scm @@ -13,6 +13,93 @@ #:use-module (gnu packages golang) #:use-module (gnu packages version-control)) +(define-public caddy + (package + (name "caddy") + (version "2.9.1") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/caddyserver/caddy") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1cnkx7n2ca49xgzqx3lanh1bm1mkpnnl03vjzy7gd4z6dq2mqvax")) + (modules '((guix build utils))) + (snippet '(substitute* "go.mod" + (("^toolchain.*") ""))))) + (build-system go-build-system) + (arguments + (list #:go go-1.23 + #:tests? (not (%current-target-system)) ;TODO: Run test suite. + #:install-source? #f + #:import-path "./cmd/caddy" + #:build-flags + #~(list "-tags" "nobadger nomysql nopgx" + (string-append + "-ldflags=" + " -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)) + #: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 + (or (which "caddy") + (in-vicinity #$output "bin/caddy")))) + (invoke caddy "manpage" "--directory" + (in-vicinity #$output "share/man/man8")) + (map + (match-lambda + ((shell . path) + (let ((file (in-vicinity #$output path))) + (mkdir-p (dirname file)) + (with-output-to-file file + (lambda () + (invoke caddy "completion" shell)))))) + '(("bash" . "etc/bash_completion.d/caddy") + ("fish" . "share/fish/vendor_completions.d/caddy.fish") + ("zsh" . "share/zsh/site-functions/_caddy")))))) + (delete 'check) + (add-after 'install 'check + (lambda* (#:key tests? #:allow-other-keys) + (when tests? + (let ((caddy (in-vicinity #$output "bin/caddy"))) + (invoke caddy "help") + (invoke caddy "version")))))))) + (native-inputs + (list (origin + (method (go-mod-vendor #:go go-1.23)) + (uri (package-source this-package)) + (file-name "vendored-go-dependencies") + (sha256 + (base32 + "13viia2v0ac3nbg0pxngiq05wbd563xs5k64l3ypy5p7ljx6kfda"))))) + (home-page "https://caddyserver.com/") + (synopsis "Extensible HTTP web server with automatic HTTPS") + (description + "Caddy is a web server designed for simplicity and ease of use. It is +notable for its automatic HTTPS feature, which enables secure connections +without requiring complex configuration. Caddy is built with a focus on +performance and flexibility, making it suitable for a variety of applications, +from serving static websites to running dynamic web applications.") + (license license:asl2.0))) + (define-public forgejo (package (name "forgejo")