Setting up the 40 y/o virgin stack
How I got my Rust project working with Hyprland and NixOS
I recently bought a thinkpad to use as my personal linux box for building out some low level projects and, after many config iterations, I landed on using nixOS with hyprland. While I've enjoyed it so far, I was surprised by how difficult it was to get one of my Rust projects up and running. The solution ended up being dead simple but I have a good feeling I'm going to need this again in the future.
tldr: use shell.nix
After a whole day, I realized that creating a shell.nix file in my project root fixed my openssl issues. Here's what I ended up using:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = [
pkgs.openssl
pkgs.pkg-config
pkgs.cargo
pkgs.rustc
];
shellHook = ''
export OPENSSL_LIB_DIR=${pkgs.openssl.out}/lib
export OPENSSL_INCLUDE_DIR=${pkgs.openssl.dev}/include
export PKG_CONFIG_PATH=${pkgs.openssl.dev}/lib/pkgconfig
'';
}
And here are my rust specific packages I have in my configuration.nix:
environment.systemPackages = with pkgs; [
rustc
rustup
rust-analyzer
cargo
openssl
pkg-config
]
Your mileage my vary on this one but these seemed to get me unstuck.
Now all you need to do is run nix-shell in your project and you should be good to go!