How do y'all develop Rust projects?

Hi, I recently switch to guix from nix. I’m looking for something equivalent to nix shell. My understanding is that guix shell -D is what I’m looking for. However guix shell -D only loads the dependencies of the crate itself, things like rust-analyzer, clippy, cargo-next, etc are things I need on my development shell that are not part of the package. How do you handle those scenarios?

I’m curious what is the existing practice for Rust projects. Do y’all use a manifest to install cargo, rust, rust-analyzer and keep rust dependencies outside of guix?

Another limitation of guix shell -D is that it doesn’t allow one to set environment variables, which nix’s mkShell does.

Do you have any links to a rust project?

Thanks in advance

2 Likes

I’m not a rust dev, just came here to say a couple of things.

  1. guix shell -D indeed only adds dependencies of the specified package. If you need something else, you need to specify it additionally in the manifest file or simply on the command line:
guix shell -D alacritty rust-cargo rust-analyzer rust-clippy
  1. In order to specify environment variables, guile’s setenv should be suitable. Something like this:
(use-modules ((gnu packages terminals)
              #:select (alacritty))
             ((gnu packages rust)
              #:select (rust-analyzer))
             ((gnu packages crates-io)
              #:select (rust-clippy-0.0))
             ((gnu packages rust-apps)
              #:select (rust-cargo)))

(setenv "MY_VARIABLE" "test!")

(concatenate-manifests
 (list (package->development-manifest alacritty)
       (packages->manifest (list rust-cargo
                                 rust-analyzer
                                 rust-clippy-0.0))))

Although I’ve tested this and it seems to me that for the shell to work correctly, it’s better to run it with the --rebuild-cache flag. Here’s what the manual says about that:

The --rebuild-cache forces the cached environment to be refreshed. This is useful when using --file or --manifest and the guix.scm or manifest.scm file has external dependencies, or if its behavior depends, say, on environment variables.

Perhaps there are other ways to specify environment variables that don’t require additional flags, I don’t know.

2 Likes

Also, I recently found this thing. Maybe this will be useful to you.

1 Like

Thanks, I didn’t know about concatenate-manifests or package->development-manifest. That would let me split the package and the ‘development shell’ into two separate files, guix.scm and maniest.scm. Similar to the nix convention of default.nix an shell.nix.

Thanks!

1 Like