Hey folks, seems like every time I think I’m starting to figure things out, I hit a new wrinkle.
I’ve been trying to move various projects to devshells. Using the code-fhs package and direnv, I’m generally able to create devshells, cd in, have them automatically set up, run code .
, and things just work. I have a Rust project that’s giving me grief, though.
In short, it builds with cargo build
from the command line, and some VS Code functionality works (E.g. goto definition for some crates.) But RA fails to compile my app. I can sometimes navigate to definitions in crates that RA may have compiled, but I generally can’t see problems in my own code.
RA’s output displays the following error:
cargo:warning=
pkg-config exited with status code 1
> PKG_CONFIG_PATH=/usr/lib/pkgconfig PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags javascriptcoregtk-4.1 'javascriptcoregtk-4.1 >= 2.38'
The system library `javascriptcoregtk-4.1` required by crate `javascriptcore-rs-sys` was not found.
The file `javascriptcoregtk-4.1.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
PKG_CONFIG_PATH contains the following:
- /usr/lib/pkgconfig
HINT: you may need to install a package such as javascriptcoregtk-4.1, javascriptcoregtk-4.1-dev or javascriptcoregtk-4.1-devel.
It’s definitely in my flake.nix:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk/master";
};
outputs =
{
self,
nixpkgs,
utils,
naersk,
}:
utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
naersk-lib = pkgs.callPackage naersk { };
libs = with pkgs; [
webkitgtk_4_1 # right here
gtk3
xdotool.out
];
in
{
defaultPackage = naersk-lib.buildPackage ./.;
devShell =
with pkgs;
mkShell {
nativeBuildInputs = [
clang
cargo
rustc
rustfmt
rustPackages.clippy
cargo-binstall
mold
pkg-config
pre-commit
lldb
];
buildInputs = [
webkitgtk_4_1 # and here again
gtk3
xdotool.out
];
shellHook = ''
pre-commit install
export RUSTFLAGS="-C link-arg=-Wl,-rpath,${lib.makeLibraryPath libs}";
'';
RUST_SRC_PATH = rustPlatform.rustLibSrc;
};
}
);
}
I’ve had a lot of weirdness setting this up. In particular, at one point it complained about missing libsoup, so I added libsoup_3 to libs
and buildInputs
and that got me here. So thinking I was on the wrong path, I removed it, cd’d back out and in to set things up, relaunched code
, and now I’m here.
How do I get RA to see all of these dependencies when run under code? Is there something else I can do to make this flake better/less repetitive?