From 387f07d9707293b06d827649f0e47dab4a466fa9 Mon Sep 17 00:00:00 2001 From: Hilton Chain Date: Thu, 3 Apr 2025 00:58:25 +0800 Subject: [PATCH] rosenthal: Add tailscale. * rosenthal/packages/networking.scm (tailscale): New variable. * rosenthal/packages/binaries.scm (tailscale-bin): Deprecated by it. * rosenthal/services/networking.scm (tailscale-configuration)[tailscale]: Use it. --- rosenthal/packages/binaries.scm | 29 ++---------- rosenthal/packages/networking.scm | 74 +++++++++++++++++++++++++++++++ rosenthal/services/networking.scm | 4 +- 3 files changed, 80 insertions(+), 27 deletions(-) diff --git a/rosenthal/packages/binaries.scm b/rosenthal/packages/binaries.scm index 97761cb..ae33a1d 100644 --- a/rosenthal/packages/binaries.scm +++ b/rosenthal/packages/binaries.scm @@ -19,7 +19,9 @@ #:use-module (gnu packages glib) #:use-module (gnu packages java) #:use-module (gnu packages nss) - #:use-module (rosenthal packages rust-apps)) + #:use-module (rosenthal packages networking) + #:use-module (rosenthal packages rust-apps) + #:use-module (rosenthal packages web)) (define license (@@ (guix licenses) license)) @@ -359,30 +361,7 @@ in sidebar.") (properties '((upstream-name . "sing-box"))))) (define-public tailscale-bin - (package - (name "tailscale-bin") - (version "1.82.0") - (source (origin - (method url-fetch) - (uri (string-append "https://pkgs.tailscale.com" - "/stable/tailscale_" version "_amd64.tgz")) - (sha256 - (base32 - "0ayc224qr2v04qvppbjlhfvnv360qm4129nwzspcd2929xaqkbf4")))) - (build-system copy-build-system) - (arguments - (list #:install-plan - #~'(("." "bin/" #:include ("tailscale" "tailscaled"))))) - (supported-systems '("x86_64-linux")) - (home-page "https://tailscale.com/") - (synopsis "Private WireGuard® networks made easy") - (description - "This package provides @command{tailscale}, which brings an easy and secure -way to use WireGuard and 2FA.") - (license license:bsd-3) - (properties - '((release-monitoring-url . "https://github.com/tailscale/tailscale/releases") - (upstream-name . "tailscale"))))) + (deprecated-package "tailscale-bin" tailscale)) (define-public wakapi-bin (package diff --git a/rosenthal/packages/networking.scm b/rosenthal/packages/networking.scm index 0f35216..484237c 100644 --- a/rosenthal/packages/networking.scm +++ b/rosenthal/packages/networking.scm @@ -8,6 +8,7 @@ #:use-module (guix gexp) #:use-module (guix git-download) #:use-module (guix packages) + #:use-module (rosenthal utils download) #:use-module (gnu packages golang) #:use-module (gnu packages golang-build)) @@ -86,3 +87,76 @@ origin can remain as closed as possible.") "This package provides a simple tool to plumb HTTP proxy requests through a SOCKS5 proxy.") (license license:expat))) + +(define-public tailscale + (package + (name "tailscale") + (version "1.80.3") + (source + (origin + (method go-vendored-fetch) + (uri (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")))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0g2pzazrfl41s1gra2g3ni34ddgw32mb2rjlv8x17g3yc7axdbqa")) + (modules '((guix build utils))) + (snippet '(delete-file-recursively "tool")))) + (build-system go-build-system) + (arguments + (list + #:go go-1.23 + #:install-source? #f + #:import-path "." + #:build-flags + #~(list "-tags" "ts_include_cli" + (string-append + "-ldflags=" + " -X tailscale.com/version.longStamp=v" + #$(package-version this-package) + " -X tailscale.com/version.shortStamp=v" + #$(package-version this-package))) + #:test-flags ''("-skip=^TestPackageDocs$") + #: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 + (apply (assoc-ref gnu:%standard-phases 'unpack) args) + (unsetenv "GO111MODULE"))) + (replace 'install-license-files + (assoc-ref gnu:%standard-phases 'install-license-files)) + ;; TODO: Fix command references. + (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" + "tailscale" + "tailscaled" + "tsidp")))))))) + (home-page "https://tailscale.com/") + (synopsis "Private WireGuard® networks made easy") + (description + "This package provides @command{tailscale}, which brings an easy and secure +way to use WireGuard and 2FA.") + (license license:bsd-3))) diff --git a/rosenthal/services/networking.scm b/rosenthal/services/networking.scm index 60dd5ad..a96bae0 100644 --- a/rosenthal/services/networking.scm +++ b/rosenthal/services/networking.scm @@ -9,12 +9,12 @@ #:use-module (guix records) #:use-module (gnu packages linux) #:use-module (gnu packages networking) + #:use-module (rosenthal packages networking) #:use-module (gnu services) #:use-module (gnu services admin) #:use-module (gnu services configuration) #:use-module (gnu services dbus) #:use-module (gnu services shepherd) - #:use-module (rosenthal packages binaries) #:export (iwd-configuration iwd-service-type @@ -367,7 +367,7 @@ list, power save will be disabled.")) (define-configuration tailscale-configuration (tailscale - (file-like tailscale-bin) + (file-like tailscale) "The tailscale package to use.") (iptables