diff mbox series

[bug#48729,v3,47/47] gnu: Add bitmask-vpn.

Message ID 20210609170022.8207-47-rg@raghavgururajan.name
State New
Headers show
Series None | expand

Commit Message

Raghav Gururajan June 9, 2021, 5 p.m. UTC
* gnu/packages/vpn.scm (bitmask-vpn): New variable.

Co-authored-by: Jorge Gomez <jgart@disroot.org>
---
 gnu/packages/vpn.scm | 220 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 220 insertions(+)
diff mbox series

Patch

diff --git a/gnu/packages/vpn.scm b/gnu/packages/vpn.scm
index a952e3f0db..3bc990c613 100644
--- a/gnu/packages/vpn.scm
+++ b/gnu/packages/vpn.scm
@@ -15,6 +15,8 @@ 
 ;;; Copyright © 2020 Ryan Prior <rprior@protonmail.com>
 ;;; Copyright © 2020 Ivan Kozlov <kanichos@yandex.ru>
 ;;; Copyright © 2020 David Dashyan <mail@davie.li>
+;;; Copyright © 2021 Raghav Gururajan <rg@raghavgururajan.name>
+;;; Copyright © 2021 Jorge Gomez <jgart@disroot.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -38,6 +40,7 @@ 
   #:use-module (guix git-download)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system go)
   #:use-module (guix build-system linux-module)
   #:use-module (guix build-system python)
   #:use-module (guix utils)
@@ -52,6 +55,8 @@ 
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages gnupg)
+  #:use-module (gnu packages golang)
+  #:use-module (gnu packages gtk)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages libevent)
   #:use-module (gnu packages linux)
@@ -69,6 +74,221 @@ 
   #:use-module (gnu packages tls)
   #:use-module (gnu packages xml))
 
+(define-public bitmask
+  (package
+    (name "bitmask")
+    (version "0.20.4")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://0xacab.org/leap/bitmask-vpn")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "04sh69m5fq3gml4xgzv92z8i3hay98n9llq9p7p6q9q81s8q8849"))))
+    (build-system go-build-system)
+    (arguments
+     `(#:imported-modules
+       ((guix build copy-build-system)
+        ,@%go-build-system-modules)
+       #:modules
+       (((guix build copy-build-system)
+         #:prefix copy:)
+        (guix build go-build-system)
+        (guix build utils))
+       #:unpack-path "0xacab.org/leap/bitmask-vpn"
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'setup-go-environment 'insert-missing-sources
+           ;; For some reason these packages are left out.
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let* ((go-dialog (assoc-ref inputs "go-0xacab-org-leap-go-dialog"))
+                    (go-dialog-src (string-append go-dialog "/src"))
+                    (shapeshifter (assoc-ref inputs "go-0xacab-org-leap-shapeshifter"))
+                    (shapeshifter-src (string-append shapeshifter "/src")))
+               (copy-recursively go-dialog-src "src")
+               (copy-recursively shapeshifter-src "src"))
+             #t))
+         (add-after 'unpack 'patch-source
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             ;; To use 'emersion/go-autostart',
+             ;; instead of 'ProtonMail/go-autostart',
+             ;; as the latter no longer exists.
+             (substitute* (find-files "." "\\.go$")
+               (("github.com/ProtonMail/go-autostart")
+                "github.com/emersion/go-autostart"))
+             ;; To use absolute paths for referenced programs.
+             (let* ((ip (string-append (assoc-ref inputs "iproute")
+                                       "/sbin/ip"))
+                    (iptables (string-append (assoc-ref inputs "iptables")
+                                             "/sbin/iptables"))
+                    (ip6tables (string-append (assoc-ref inputs "iptables")
+                                              "/sbin/ip6tables"))
+                    (sysctl (string-append (assoc-ref inputs "procps")
+                                           "/sbin/sysctl"))
+                    (openvpn (string-append (assoc-ref inputs "openvpn")
+                                            "/sbin/openvpn"))
+                    (bitmask-root (string-append (assoc-ref outputs "out")
+                                                 "/sbin/bitmask-root")))
+               (substitute* (find-files "." "(\\.go$|\\.policy$|bitmask-root)")
+                 (("swhich\\(\"ip\"\\)")
+                  (string-append "\"" ip "\""))
+                 (("swhich\\(\"iptables\"\\)")
+                  (string-append "\"" iptables "\""))
+                 (("swhich\\(\"ip6tables\"\\)")
+                  (string-append "\"" ip6tables "\""))
+                 (("swhich\\(\"sysctl\"\\)")
+                  (string-append "\"" sysctl "\""))
+                 (("/usr/sbin/openvpn")
+                  openvpn)
+                 (("/usr/sbin/bitmask-root")
+                  bitmask-root)
+                 (("/usr/local/sbin/bitmask-root")
+                  bitmask-root)))
+             #t))
+         (replace 'build
+           (lambda* (#:key source system outputs search-paths build-flags unpack-path inputs #:allow-other-keys)
+             (for-each
+              (lambda (directory)
+                ((assoc-ref %standard-phases 'build)
+                 #:source source
+                 #:system system
+                 #:outputs outputs
+                 #:search-paths search-paths
+                 #:build-flags build-flags
+                 #:unpack-path unpack-path
+                 #:inputs inputs
+                 #:import-path directory))
+              (list
+               "0xacab.org/leap/bitmask-vpn/cmd/bitmask-connect"
+               "0xacab.org/leap/bitmask-vpn/cmd/bitmask-helper"
+               "0xacab.org/leap/bitmask-vpn/cmd/bitmask-vpn"
+               "0xacab.org/leap/bitmask-vpn/icon"
+               "0xacab.org/leap/bitmask-vpn/pkg/bitmask"
+               "0xacab.org/leap/bitmask-vpn/pkg/bitmaskd"
+               "0xacab.org/leap/bitmask-vpn/pkg/config"
+               "0xacab.org/leap/bitmask-vpn/pkg/helper"
+               "0xacab.org/leap/bitmask-vpn/pkg/standalone"
+               "0xacab.org/leap/bitmask-vpn/pkg/systray"
+               "0xacab.org/leap/bitmask-vpn/tools/transifex"))
+             #t))
+         (replace 'check
+           (lambda* (#:key source system outputs search-paths tests? unpack-path inputs #:allow-other-keys)
+             (for-each
+              (lambda (directory)
+                ((assoc-ref %standard-phases 'check)
+                 #:source source
+                 #:system system
+                 #:outputs outputs
+                 #:search-paths search-paths
+                 #:tests? tests?
+                 #:unpack-path unpack-path
+                 #:inputs inputs
+                 #:import-path directory))
+              (list
+               "0xacab.org/leap/bitmask-vpn/cmd/bitmask-connect"
+               "0xacab.org/leap/bitmask-vpn/cmd/bitmask-helper"
+               "0xacab.org/leap/bitmask-vpn/cmd/bitmask-vpn"
+               "0xacab.org/leap/bitmask-vpn/icon"
+               "0xacab.org/leap/bitmask-vpn/pkg/bitmask"
+               "0xacab.org/leap/bitmask-vpn/pkg/bitmaskd"
+               "0xacab.org/leap/bitmask-vpn/pkg/config"
+               "0xacab.org/leap/bitmask-vpn/pkg/helper"
+               "0xacab.org/leap/bitmask-vpn/pkg/standalone"
+               "0xacab.org/leap/bitmask-vpn/pkg/systray"
+               "0xacab.org/leap/bitmask-vpn/tools/transifex"))
+             #t))
+         (replace 'install
+           (lambda* (#:key source system outputs search-paths install-source? unpack-path inputs #:allow-other-keys)
+             (for-each
+              (lambda (directory)
+                ((assoc-ref %standard-phases 'install)
+                 #:source source
+                 #:system system
+                 #:outputs outputs
+                 #:search-paths search-paths
+                 #:install-source? install-source?
+                 #:unpack-path unpack-path
+                 #:inputs inputs
+                 #:import-path directory))
+              (list
+               "0xacab.org/leap/bitmask-vpn/cmd/bitmask-connect"
+               "0xacab.org/leap/bitmask-vpn/cmd/bitmask-helper"
+               "0xacab.org/leap/bitmask-vpn/cmd/bitmask-vpn"
+               "0xacab.org/leap/bitmask-vpn/icon"
+               "0xacab.org/leap/bitmask-vpn/pkg/bitmask"
+               "0xacab.org/leap/bitmask-vpn/pkg/bitmaskd"
+               "0xacab.org/leap/bitmask-vpn/pkg/config"
+               "0xacab.org/leap/bitmask-vpn/pkg/helper"
+               "0xacab.org/leap/bitmask-vpn/pkg/standalone"
+               "0xacab.org/leap/bitmask-vpn/pkg/systray"
+               "0xacab.org/leap/bitmask-vpn/tools/transifex"))
+             #t))
+         (add-after 'install 'install-continued
+           ;; To install bitmask-root script and polkit policy.
+           (lambda args
+             (apply (assoc-ref copy:%standard-phases 'install)
+                    #:install-plan
+                    '(("src/0xacab.org/leap/bitmask-vpn/helpers"
+                       "sbin"
+                       #:include ("bitmask-root"))
+                      ("src/0xacab.org/leap/bitmask-vpn/helpers"
+                       "share/polkit-1/actions"
+                       #:include ("se.leap.bitmask.policy")))
+                    args)))
+         (add-after 'install-continued 'post-install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (bitmask-root (string-append out "/sbin/bitmask-root")))
+               ;; To make bitmask-root script executable.
+               (chmod bitmask-root #o555)
+               ;; To wrap bitmask-root script with $PYTHONPATH.
+               (wrap-program bitmask-root
+                 `("PYTHONPATH" ":" prefix (,(getenv "PYTHONPATH")))))
+             #t)))))
+    (native-inputs
+     `(("gtk+:bin" ,gtk+ "bin")
+       ("pkg-config" ,pkg-config)))
+    (inputs
+     `(("gtk+" ,gtk+)
+       ("iproute" ,iproute)
+       ("iptables" ,iptables)
+       ("libappindicator" ,libappindicator)
+       ("openvpn" ,openvpn)
+       ("procps" ,procps)
+       ("python" ,python)))
+    (propagated-inputs
+     `(("go-0xacab-org-leap-go-dialog"
+        ,go-0xacab-org-leap-go-dialog)
+       ("go-0xacab-org-leap-shapeshifter"
+        ,go-0xacab-org-leap-shapeshifter)
+       ("go-github-com-apparentlymart-go-openvpn-mgmt"
+        ,go-github-com-apparentlymart-go-openvpn-mgmt)
+       ("go-github-com-emersion-go-autostart"
+        ,go-github-com-emersion-go-autostart)
+       ("go-github-com-getlantern-systray"
+        ,go-github-com-getlantern-systray)
+       ("go-github-com-jmshal-go-locale"
+        ,go-github-com-jmshal-go-locale)
+       ("go-github-com-keybase-go-ps"
+        ,go-github-com-keybase-go-ps)
+       ("go-github-com-sevlyar-go-daemon"
+        ,go-github-com-sevlyar-go-daemon)
+       ("go-github-com-skratchdot-open-golang"
+        ,go-github-com-skratchdot-open-golang)
+       ("go-golang-org-x-sys" ,go-golang-org-x-sys)
+       ("go-golang-org-x-text" ,go-golang-org-x-text)
+       ("go-golang-org-x-tools" ,go-golang-org-x-tools)))
+    (synopsis "Bitmask VPN Client")
+    (description "Bitmask, by @acronym{LEAP, LEAP Encryption Access Project},
+is an application to provide easy and secure encrypted communication with a
+@acronym{VPN, Virtual Private Network}.  It allows you to select from a variety
+of trusted service provider all from one app.  Current providers include Riseup
+Networks and The Calyx Institute.")
+    (home-page "https://bitmask.net/")
+    (license license:gpl3+)))
+
 (define-public gvpe
   (package
     (name "gvpe")