Guix 打包 emacs-rime

发现Guix特别适合各种包的管理 vim,emacs,python,等等

然后需要的包都写了Guix打包

有Guix需要安装emacs-rime的可以看一下。

guix 处理这种需要动态模块的包还是挺不错的。

放好代码后直接

guix build emacs-rime && guix package -i  emacs-rime
(define-public emacs-rime
  (let ((version "0")
        (revision "1")
        (commit "daf956df30d4007f70a4495560d656e517ab69a9"))
    (package
      (name "emacs-rime")
      (version (git-version version revision commit))
      (source (origin
                (method git-fetch)
                (uri (git-reference
                      (url "https://github.com/DogLooksGood/emacs-rime.git")
                      (commit commit)))
                (file-name (git-file-name name version))
                (sha256
                 (base32
                  "0wr1ski9j7m7mwizdgxnnj61z1nqpyjp6gc7dniaac0m6svxf1rf"))))
      (build-system emacs-build-system)
      (arguments
       `(#:modules ((guix build emacs-build-system)
                    (guix build emacs-utils)
                    (guix build utils))
         #:imported-modules (,@%emacs-build-system-modules)
         #:phases
         (modify-phases %standard-phases
			(add-before 'add-source-to-load-path 'substitute-rime-module-path
				    (lambda* (#:key outputs #:allow-other-keys)
				      (chmod "rime.el" #o644)
				      (emacs-substitute-sexps "rime.el"
							      ("(defvar rime--module-path"
							       (string-append (assoc-ref outputs "out")
									      "/lib/librime-emacs.so")))
				      #t))
			(add-before 'add-source-to-load-path 'substitute-rime-data-path
				    (lambda* (#:key inputs #:allow-other-keys)
				      (chmod "rime.el" #o644)       
				      (emacs-substitute-sexps "rime.el"
							      ("(defcustom rime-share-data-dir"
							       (string-append (assoc-ref inputs "rime-data")
									      "/share/rime-data/")))
				      #t))
           (add-after 'configure 'make
             ;; Run make.
             (lambda* (#:key (make-flags '()) outputs #:allow-other-keys)
               ;; Compile the shared object file.
               (apply invoke "make" "lib" make-flags)
               ;; Move the file into /lib.
               (install-file
                "librime-emacs.so"
                (string-append (assoc-ref outputs "out") "/lib"))
               #t)))
         #:tests? #f))
      (inputs
       `(("librime" ,librime)
	 ("rime-data" ,rime-data))
       )
      (propagated-inputs
       `(("dash" ,emacs-dash))
	)
      (home-page "https://github.com/DogLooksGood/emacs-rime.git")
      (synopsis "Emacs 下的 Rime 输入法")
      (description "Emacs 下的 Rime 输入法")
      (license license:gpl3+))))

https://github.com/nniixxoossccnn/my-guix/blob/github/packages/luhux/packages/emacs-xyz.scm

3 个赞

也许可以加到 faq 里面

?? 哪个faq?

我指 readme 中的 faq 里面,加一项,然后在 installation 那里提一下。

感觉用guix替代Emacs自己的鶸鸡包管理应该可行(还可以顺便管理不同版本的Emacs)

我已经替代了melpa了,现在正在打包各种lsp实现和vim插件. 比起编辑器里面的弱鸡包管理器还是系统的好用

Guix实际上就是个用Scheme写的简化Nix而已,Nix管理Emacs包也是通过写*.nix文件管理的,对于Emacs来说只要写.emacs.d中的配置就行,省去了package.el的配置

链接失效了. 还有, 这种方式可以管理任意来源的package吗? 比如我需要从cargo上下载rg和fd, 也可以通过guix统一包装吗?

Guix官方源里有ripgrep和fd了。

对于任意cratesio的package,可以用importer

guix import crate -r cbindgen > ~/tmp/cbindgen.scm
chino@asus-laptop:~$ guix import crate -r cbindgen > ~/tmp/cbindgen.scm
following redirection to `https://static.crates.io/crates/cbindgen/cbindgen-0.16.0.crate'...
following redirection to `https://static.crates.io/crates/serial_test/serial_test-0.5.1.crate'...
following redirection to `https://static.crates.io/crates/serial_test_derive/serial_test_derive-0.5.1.crate'...
chino@asus-laptop:~$ cat ~/tmp/cbindgen.scm 
(define-public rust-serial-test-derive-0.5
  (package
    (name "rust-serial-test-derive")
    (version "0.5.1")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "serial_test_derive" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "1m8sd97xr8dn6p9by0xwfqm0rz8cbn1ghs5l1fv1xd6xzvgddb5j"))))
    (build-system cargo-build-system)
    (arguments
      `(#:skip-build?
        #t
        #:cargo-inputs
        (("rust-proc-macro2" ,rust-proc-macro2-1)
         ("rust-quote" ,rust-quote-1)
         ("rust-syn" ,rust-syn-1))))
    (home-page "")
    (synopsis "Helper crate for serial_test")
    (description "Helper crate for serial_test")
    (license license:expat)))

(define-public rust-serial-test-0.5
  (package
    (name "rust-serial-test")
    (version "0.5.1")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "serial_test" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "0pchc7imdi9wv8xxnwkb9lzs6cg06ghs0gaajjb834y8837wpg70"))))
    (build-system cargo-build-system)
    (arguments
      `(#:skip-build?
        #t
        #:cargo-inputs
        (("rust-lazy-static" ,rust-lazy-static-1)
         ("rust-parking-lot" ,rust-parking-lot-0.11)
         ("rust-serial-test-derive"
          ,rust-serial-test-derive-0.5))))
    (home-page "")
    (synopsis
      "Allows for the creation of serialised Rust tests")
    (description
      "Allows for the creation of serialised Rust tests")
    (license license:expat)))

(define-public rust-cbindgen-0.16
  (package
    (name "rust-cbindgen")
    (version "0.16.0")
    (source
      (origin
        (method url-fetch)
        (uri (crate-uri "cbindgen" version))
        (file-name
          (string-append name "-" version ".tar.gz"))
        (sha256
          (base32
            "049cai626nzw0km03parx4sxwaxgbr7i5ifjbjwnfxkqkj5k2i4k"))))
    (build-system cargo-build-system)
    (arguments
      `(#:cargo-inputs
        (("rust-clap" ,rust-clap-2)
         ("rust-heck" ,rust-heck-0.3)
         ("rust-indexmap" ,rust-indexmap-1)
         ("rust-log" ,rust-log-0.4)
         ("rust-proc-macro2" ,rust-proc-macro2-1)
         ("rust-quote" ,rust-quote-1)
         ("rust-serde" ,rust-serde-1)
         ("rust-serde-json" ,rust-serde-json-1)
         ("rust-syn" ,rust-syn-1)
         ("rust-tempfile" ,rust-tempfile-3)
         ("rust-toml" ,rust-toml-0.5))
        #:cargo-development-inputs
        (("rust-serial-test" ,rust-serial-test-0.5))))
    (home-page "")
    (synopsis
      "A tool for generating C bindings to Rust code.")
    (description
      "This package provides a tool for generating C bindings to Rust code.")
    (license license:mpl2.0)))

当然你装了cargo之后用cargo install安装的包一般都是可以用的

链接失效了

源里有了

这种方式可以管理任意来源的package吗

是的

比如我需要从cargo上下载rg和fd, 也可以通过guix统一包装吗?

guix 已经有 rg 和 fd 了

那剩下最大的问题就是能不能在msys2上跑guix了.