# Either have nixpkgs and fenix in your channels
# Or build it using flakes, flake way is more recommended!
{
pkgs ? let
lock = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.nixpkgs.locked;
nixpkgs = fetchTarball {
url = "https://github.com/nixos/nixpkgs/archive/${lock.rev}.tar.gz";
sha256 = lock.narHash;
};
in
import nixpkgs {overlays = [];},
...
}: let
# Helpful nix function
getLibFolder = pkg: "${pkg}/lib";
# Manifest
manifest = (pkgs.lib.importTOML ./Cargo.toml).package;
in
pkgs.stdenv.mkDerivation {
name = "${manifest.name}-dev";
# Compile time dependencies
nativeBuildInputs = with pkgs; [
# GCC toolchain
pkg-config
# Hail the Nix
nixd
statix
deadnix
alejandra
# Rust
rustc
cargo
rustfmt
clippy
rust-analyzer
cargo-watch
# Other compile time dependencies
# here
openssl
];
# Runtime dependencies which will be in present
# after activation
buildInputs = with pkgs; [
openssl
# libressl
];
# Set Environment Variables
RUST_BACKTRACE = "full";
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
# Compiler LD variables
# > Make sure packages have /lib or /include path'es
NIX_LDFLAGS = "-L${(getLibFolder pkgs.libiconv)}";
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
pkgs.gcc
pkgs.libiconv
pkgs.llvmPackages.llvm
];
shellHook = ''
# Extra steps to do while activating development shell
'';
}