From b0231df0234134cd0a75c2f5dc5b889002d2edf3 Mon Sep 17 00:00:00 2001 From: Hilton Chain Date: Tue, 13 May 2025 21:15:18 +0800 Subject: [PATCH] rosenthal: Add mihomo. * modules/rosenthal/packages/networking.scm (mihomo): New variable. * modules/rosenthal/packages/binaries.scm (mihomo-bin): Deprecated by it. (clash-bin): Delete variable. --- modules/rosenthal/packages/binaries.scm | 60 +------------------ modules/rosenthal/packages/networking.scm | 70 +++++++++++++++++++++++ 2 files changed, 71 insertions(+), 59 deletions(-) diff --git a/modules/rosenthal/packages/binaries.scm b/modules/rosenthal/packages/binaries.scm index e51c20f..4990beb 100644 --- a/modules/rosenthal/packages/binaries.scm +++ b/modules/rosenthal/packages/binaries.scm @@ -55,69 +55,11 @@ (define-public bitwarden/icecat (make-icecat-extension bitwarden)) -(define-public clash-bin - (package - (name "clash-bin") - (version "1.18.0") - (source (origin - (method url-fetch) - (uri (string-append - "https://github.com/Dreamacro/clash/releases/download/v" - version "/clash-linux-amd64-v3-v" version ".gz")) - (sha256 - (base32 - "0gchpc4pvy24dvhb5nk08g97rswjqr1ic6i405f1ba5snfv8i5z8")))) - (build-system copy-build-system) - (arguments - (list #:install-plan - #~'((#$(format #f "clash-linux-amd64-v3-v~a" version) "bin/clash")) - #:phases - #~(modify-phases %standard-phases - (add-after 'install 'fix-permission - (lambda _ - (chmod (string-append #$output "/bin/clash") #o555)))))) - (supported-systems '("x86_64-linux")) - (home-page "https://github.com/Dreamacro/clash") - (synopsis "Rule-based tunnel in Go") - (description - "Clash is a cross-platform rule-based proxy utility that runs on the -network and application layer, supporting various proxy and anti-censorship -protocols out-of-the-box.") - (license license:gpl3))) - (define-public hugo-bin (deprecated-package "hugo-bin" hugo)) (define-public mihomo-bin - (package - (name "mihomo-bin") - (version "1.19.5") - (source (origin - (method url-fetch) - (uri (string-append - "https://github.com/MetaCubeX/mihomo/releases/download/v" - version "/mihomo-linux-amd64-v" version ".gz")) - (sha256 - (base32 - "1x7i7v1gkfgc19fmsn9annv8nvwfl6w5pqr1m3982plzabnlr1ni")))) - (build-system copy-build-system) - (arguments - (list #:install-plan - #~'((#$(string-append - "mihomo-linux-amd64-v" (package-version this-package)) - "bin/mihomo")) - #:phases - #~(modify-phases %standard-phases - (add-after 'install 'fix-permission - (lambda _ - (chmod (string-append #$output "/bin/mihomo") #o555)))))) - (supported-systems '("x86_64-linux")) - (home-page "https://wiki.metacubex.one/") - (synopsis "Rule-based tunnel in Go") - (description - "This package provides @command{mihomo}, another @code{clash} kernel.") - (license license:gpl3) - (properties '((upstream-name . "mihomo"))))) + (deprecated-package "mihomo-bin" mihomo)) (define-public clash-meta-bin (deprecated-package "clash-meta-bin" mihomo-bin)) diff --git a/modules/rosenthal/packages/networking.scm b/modules/rosenthal/packages/networking.scm index b950bda..937ed54 100644 --- a/modules/rosenthal/packages/networking.scm +++ b/modules/rosenthal/packages/networking.scm @@ -66,6 +66,76 @@ this daemon, without requiring you to poke holes on your firewall --- your origin can remain as closed as possible.") (license license:asl2.0))) +(define-public mihomo + (package + (name "mihomo") + (version "1.19.8") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/MetaCubeX/mihomo") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0wnzaji5yzj8hvjifgnmhg371mm94bc89bb2m1dmsqsp30m3dj0b")))) + (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" "with_gvisor" + (string-append + "-ldflags=" + " -X github.com/metacubex/mihomo/constant.Version=" + #$(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)) + (delete 'check) + (add-after 'install 'check + (lambda* (#:key tests? #:allow-other-keys) + (when tests? + (let ((mihomo (in-vicinity #$output "bin/mihomo"))) + (invoke mihomo "--help") + (invoke mihomo "-v")))))))) + (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 + "1275yq3n7dg7hbw7vj5i1dqi83qgin77iavqxbc2gw8dawbd9plg")))) + (if (%current-target-system) + (list this-package) + '()))) + (home-page "https://wiki.metacubex.one/") + (synopsis "Rule-based proxy") + (description + "Mihomo is an anti-censorship proxy application, originally known as +\"Clash Meta\", designed to facilitate secure and flexible internet access. +It supports various protocols, making it a versatile tool for users seeking to +bypass network restrictions." ) + (license license:gpl3+))) + (define-public socks2http (package (name "socks2http")