!FBuJyWXTGcGtHTPphC:nixos.org

Nix Rust

706 Members
Rust162 Servers

Load older messages


SenderMessageTime
14 Sep 2022
@farcaller:matrix.orgfarcallerah right. my vscode is outside of nix so I don't think that applies.10:08:50
@pennae:matrix.eno.spacepennae left the room.14:11:10
@x10an14:matrix.orgx10an14
In reply to @x10an14:matrix.org

I've tried the rust-analyzer and vscode (read: codium) combo too, but can't get it to work... Would some kind soul here be willing to take a look at my below paste and tell me what I'm doing wrong?
The rust-analyzer extension keeps complaning when I start up vscode - other than that I have no error messages (it complains about missing binaries for my OS - NixOS).

This is my first time ever using VS Code for rust, and first time ever touching rust-analyzer (heck - first time ever using vscode on nix/nixos too). Reading the Rust wiki and the plugins' issues didn't help me understand where to go from here. Any pointers anyone?
https://paste.sr.ht/~x10an14/c9d82c36b864b0bd334a9ffaf43e065da385f9bb

I found a solution to my issue (I think - still veryfing/testing).

The rust-lang.rust-analyzer extension supports a "rust-analyzer.server.path": "rust-analyzer" setting, which can be put in <project/git repo root>/.vscode/settings.json. That along with the arrterian.nix-env-selector extension (and required shell.nix since I use flakes) seem to have done the trick for me.

Many thanks to @NobbZ on the Unofficial Nix/NixOS Discord Server for sharing the solution.

15:29:58
@farcaller:matrix.orgfarcaller arrterian.nix-env-selector didn't do anything useful for me :( what did you set rust-analyzer.server.path to? 15:30:58
@x10an14:matrix.orgx10an14
In reply to @farcaller:matrix.org
arrterian.nix-env-selector didn't do anything useful for me :( what did you set rust-analyzer.server.path to?
I installed rust-analyzer into the PATH that my flake's devShell specified. Check out the paste in my opening post.
15:32:17
@farcaller:matrix.orgfarcallerah15:32:51
@farcaller:matrix.orgfarcaller I've past that step :) I think you can also do the same with direnv and echo use\ flake >> .envrc 15:34:58
@x10an14:matrix.orgx10an14
In reply to @farcaller:matrix.org
I've past that step :) I think you can also do the same with direnv and echo use\ flake >> .envrc
Yes, that's correct =)
15:36:25
@x10an14:matrix.orgx10an14
In reply to @farcaller:matrix.org
arrterian.nix-env-selector didn't do anything useful for me :( what did you set rust-analyzer.server.path to?

To answer your question;

{
  "rust-analyzer.server.path": "rust-analyzer" 
}
15:38:16
@farcaller:matrix.orgfarcallerah huh.15:58:26
@schuelermine:matrix.orgschuelermine farcaller: maybe you need to set the environment variable RUST_SRC_PATH to ${rustPlatform.rustLibSrc}? 17:11:23
@farcaller:matrix.orgfarcaller
In reply to @schuelermine:matrix.org
farcaller: maybe you need to set the environment variable RUST_SRC_PATH to ${rustPlatform.rustLibSrc}?
what's rustPlatform? where is it coming from?
17:13:24
@schuelermine:matrix.orgschuelermine sorry, I mean pkgs.rustPlatform.rustLibSrc 17:13:54
@schuelermine:matrix.orgschuelermineat any rate that was the issue I had which made VSCode not work17:14:16
@farcaller:matrix.orgfarcallerno cricket, same glibc issue :(17:19:06
@farcaller:matrix.orgfarcallerthanks for the idea, still.17:19:15
@schuelermine:matrix.orgschuelermineoh are you running vscode in a fhs?17:22:21
@farcaller:matrix.orgfarcallerI'm running vscode on windows and nix in WSL :)17:28:17
@farcaller:matrix.orgfarcallerso it has nothing to do with the frontend because it's pretty far away from nixos17:28:53
@schuelermine:matrix.orgschuelerminehm okay, no idea then!17:37:27
15 Sep 2022
@m_algery:leohoo.xyzm_algery joined the room.12:00:58
@m_algery:leohoo.xyzm_algery left the room.12:01:01
@gianarb:matrix.orgGianluca Arbezzano joined the room.15:09:36
@gianarb:matrix.orgGianluca Arbezzano

Hello! I am not sure if I am doing something that has sense or not. But I would like to build a rust project that does not have a flake.nix checked out in the repo itself. And I would like to avoid that right now. I was thinking about something like this:

{
  description = "";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";
    naersk.url = "github:nix-community/naersk";
  };

  outputs = { self, nixpkgs, naersk, ... }:
    let
      system = "x86_64-linux";
    in
    {
      packages.${system}.quarry = naersk.lib.${system}.buildPackage {
        pname = "quarry";
        src = nixpkgs.lib.fetchgit {
          url = "git+ssh://git@github.com/testtest/test";
          rev = "a3f0e0f9d4085b24334b37da5fb7db3cd84188bf";
          sha256 = "69b056298cf570debd3718b2e2cb7e63ad9465919c8190cf38043791ce61d0d6";
        };
      };
    };
}

but I get this error error: attribute 'fetchgit' missing and I am not sure if what I am doing is possible

15:11:16
@farcaller:matrix.orgfarcaller isn't it builtins.fetchGit? 15:12:14
@farcaller:matrix.orgfarcallerhttps://nixos.org/manual/nix/stable/language/builtins.html#builtins-fetchGit15:12:25
@gianarb:matrix.orgGianluca ArbezzanoAh you are right! 15:21:28
@gianarb:matrix.orgGianluca ArbezzanoThanks15:21:31
@gianarb:matrix.orgGianluca Arbezzano

I think I have another question, the build process fails because the rust project I am trying to build has a private build-dependency:

[build-dependencies]
buildinfo = { git = "ssh://git@github.com/test/testprivate.git", tag = "0.2.0"}
$ nix build
fetching Git repository 'ssh://git@github.com/test/testprivate.git'fatal: couldn't find remote ref refs/heads/0.2.0
error: program 'git' failed with exit code 128

I can't find if it is supported or not

16:07:40
@gianarb:matrix.orgGianluca Arbezzano *

I think I have another question, the build process fails because the rust project I am trying to build has a private build-dependency:

[build-dependencies]
testprivate = { git = "ssh://git@github.com/test/testprivate.git", tag = "0.2.0"}
$ nix build
fetching Git repository 'ssh://git@github.com/test/testprivate.git'fatal: couldn't find remote ref refs/heads/0.2.0
error: program 'git' failed with exit code 128

I can't find if it is supported or not

16:07:47

Show newer messages


Back to Room ListRoom Version: 6