about summary refs log tree commit diff
diff options
context:
space:
mode:
authorpjotrp2026-04-24 11:24:36 +0200
committerpjotrp2026-04-24 18:04:10 +0200
commit51aa7ec41d70316d610fd360a47f5d135867dab2 (patch)
tree294244adaf6bed827112cdc09203be7238262393
parent5dbe1be8ec8cae3c9ed4dcb9c5efe058e125e195 (diff)
downloadguix-bioinformatics-51aa7ec41d70316d610fd360a47f5d135867dab2.tar.gz
Added (networking) headscale package
-rw-r--r--gn/packages/network.scm101
1 files changed, 101 insertions, 0 deletions
diff --git a/gn/packages/network.scm b/gn/packages/network.scm
new file mode 100644
index 0000000..ae4ed92
--- /dev/null
+++ b/gn/packages/network.scm
@@ -0,0 +1,101 @@
+;; Network packages
+
+(define-module (gn packages network)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix git-download)
+  #:use-module (guix build-system go)
+  #:use-module (guix gexp)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages compression)
+  #:use-module (gnu packages golang))
+
+(define-public headscale
+  (package
+    (name "headscale")
+    (version "0.28.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/juanfont/headscale")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1lmyz618qcvdlich110qpjb5kj04lcvn4k78k0xyzzzqbcw687l1"))))
+    (build-system go-build-system)
+    (arguments
+     (list
+      #:go go-1.26
+      #:import-path "github.com/juanfont/headscale/cmd/headscale"
+      #:unpack-path "github.com/juanfont/headscale"
+      #:install-source? #f
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'setup-go-environment 'enable-modules
+            (lambda _
+              ;; Override GO111MODULE=off set by go-build-system
+              (setenv "GO111MODULE" "on")
+              ;; Use the available Go toolchain, don't download another
+              (setenv "GOTOOLCHAIN" "local")))
+          (add-after 'unpack 'install-vendor
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((vendor-tar (assoc-ref inputs "vendor-tar")))
+                (with-directory-excursion
+                  "src/github.com/juanfont/headscale"
+                  (invoke "tar" "xzf" vendor-tar)))))
+          (add-after 'install-vendor 'patch-version
+            (lambda _
+              (substitute*
+                "src/github.com/juanfont/headscale/hscontrol/types/version.go"
+                (("Version:   \"dev\"")
+                 (string-append "Version:   \"" #$version "\""))
+                (("Commit:    \"unknown\"")
+                 (string-append "Commit:    \"v" #$version "\"")))))
+          (replace 'build
+            (lambda* (#:key import-path #:allow-other-keys)
+              (with-directory-excursion
+                "src/github.com/juanfont/headscale"
+                (invoke "go" "build" "-mod=vendor"
+                        "-ldflags=-s -w" "-trimpath"
+                        "-o" (string-append (getenv "GOBIN") "/headscale")
+                        "./cmd/headscale"))))
+          (delete 'install)
+          (replace 'check
+            (lambda* (#:key tests? #:allow-other-keys)
+              (when tests?
+                (with-directory-excursion
+                  "src/github.com/juanfont/headscale"
+                  ;; Skip hscontrol/db: requires PostgreSQL
+                  (invoke "go" "test" "-mod=vendor" "-short"
+                          "-skip" "TestDB"
+                          "./cmd/..."
+                          "./hscontrol/mapper/..."
+                          "./hscontrol/derp/..."
+                          "./hscontrol/db/sqliteconfig/..."
+                          "./hscontrol/policy/..."
+                          "./hscontrol/routes/..."
+                          "./hscontrol/state/..."
+                          "./hscontrol/types/..."
+                          "./hscontrol/util/..."
+                          "./integration/..."))))))))
+    (native-inputs
+     `(("vendor-tar"
+        ,(origin
+           (method url-fetch)
+           ;; TODO: host this tarball properly
+           (uri (string-append
+                 "file:///tmp/headscale-vendor.tar.gz"))
+           (sha256
+            (base32
+             "1w03g2lp1wwz3g2ka9g1kp83yrhqsv47gsbyjmrrm2najj5nrh8s"))))
+       ("tar" ,tar)
+       ("gzip" ,gzip)))
+    (home-page "https://github.com/juanfont/headscale")
+    (synopsis "Self-hosted implementation of the Tailscale control server")
+    (description
+     "Headscale is an open source, self-hosted implementation of the Tailscale
+control server.  It implements the coordination server that exchanges WireGuard
+public keys between nodes, assigns IP addresses, and manages the network.")
+    (license license:bsd-3)))