diff mbox series

[bug#42179] gnu: Add racer.

Message ID 87y2o0d18c.fsf@asu.edu
State Accepted
Headers show
Series [bug#42179] gnu: Add racer. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job

Commit Message

John Soo July 3, 2020, 4:14 p.m. UTC
Hi Guix,

I have been writing a lot of Rust recently. Racer provides
autocompletion. It uses the source of rust standard libraries among
other tools.

There are two items I paid close attention to:

1. Add a "source" output for rust.  This roughly corresponds to the
rustup component.  Using the rustup toolchain to manage rust tooling the
command would be: rustup component add rust-src. However, using guix, we
already have the source.

2. Racer requires features that are not in the stable branch of rust.
Unfortunately this is not any fault of racer. Racer uses crates from
rustc which uses unstable features.  To get around this, I built
racer using the undocumented and unsupported RUSTC_BOOTSTRAP environment
variable. Perhaps the better future solution would be to provide a
nightly rustc and use that to compile racer.

I hope someone gets some use out of racer!

- John

Comments

Maja Kądziołka July 12, 2020, 2:58 p.m. UTC | #1
On Fri, Jul 03, 2020 at 09:14:59AM -0700, John Soo wrote:
> 2. Racer requires features that are not in the stable branch of rust.
> Unfortunately this is not any fault of racer. Racer uses crates from
> rustc which uses unstable features.  To get around this, I built
> racer using the undocumented and unsupported RUSTC_BOOTSTRAP environment
> variable. Perhaps the better future solution would be to provide a
> nightly rustc and use that to compile racer.

How about we use the source of rust itself for the rustc-ap packages?
That way, updating rustc won't actually ever break because of RUSTC_BOOTSTRAP,
since the use of the unstable features comes from the same source of
truth that will actually compile them.

Regards,
Jakub Kądziołka
John Soo July 19, 2020, 11:40 p.m. UTC | #2
Hi Jakub,

Sorry I am late to respond. 

> How about we use the source of rust itself for the rustc-ap packages?
> That way, updating rustc won't actually ever break because of RUSTC_BOOTSTRAP,
> since the use of the unstable features comes from the same source of
> truth that will actually compile them.

I like the idea of keeping racer up to date with rust. Do you think making racer an output of rust would be good or is a separate package depending on rust a better option?

Thanks!

John
John Soo Jan. 1, 2021, 6:21 p.m. UTC | #3
Hi Jakub and Efraim,

I agree with Jakub that racer-like packages would be most helpful if
provided as an output of rust. There are plenty of other places where
this guarantee is not provided like cabal-install. But, since racer is
now superceded by rls and rust-analyzer, I am going to close this. Rls
and rust-analyzer are both outputs of rust after 1.46 and it has been
shown to work for rustfmt already.

Thanks again,

John
diff mbox series

Patch

From 7b9030a45938f0caba0591c4c99e778d45028100 Mon Sep 17 00:00:00 2001
From: John Soo <jsoo1@asu.edu>
Date: Tue, 16 Jun 2020 23:43:49 -0700
Subject: [PATCH 33/33] gnu: emacs-racer: Patch paths to rust source and racer.

* gnu/packages/emacs-xyz.scm (emacs-racer): [arguments] Patch paths to rust
source and racer binary in racer.el.
---
 gnu/packages/emacs-xyz.scm | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index aae9eb25fd..f0a1fddb83 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -168,6 +168,8 @@ 
   #:use-module (gnu packages fontutils)
   #:use-module (gnu packages password-utils)
   #:use-module (gnu packages pulseaudio)
+  #:use-module (gnu packages rust)
+  #:use-module (gnu packages rust-apps)
   #:use-module (gnu packages sphinx)
   #:use-module (gnu packages xdisorg)
   #:use-module (gnu packages shells)
@@ -17375,11 +17377,21 @@  files.  It focuses on highlighting the document to improve readability.")
        #:test-command '("make" "test")
        #:phases
        (modify-phases %standard-phases
+         (add-after 'unpack 'patch-rust-src-path
+           (lambda* (#:key inputs #:allow-other-keys)
+             (substitute* "racer.el"
+               (("/usr/local/src/rust/src")
+                (string-append (assoc-ref inputs "rust") "/src/src"))
+               (("/usr/local/bin/racer")
+                (string-append (assoc-ref inputs "racer") "/bin/racer")))))
          (add-before 'check 'fix-makefile
            (lambda _
              (substitute* "Makefile"
                (("\\$\\{CASK\\} exec ") ""))
              #t)))))
+    (inputs
+     `(("racer" ,racer)
+       ("rust" ,rust "source")))
     (native-inputs
      `(("emacs-ert-runner" ,emacs-ert-runner)
        ("emacs-undercover" ,emacs-undercover)))
-- 
2.26.2