crate2nix
crate2nix copied to clipboard
How to use nightly channel
I have default.nix which compiles the application. I have my own crate that uses several functions from nightly. My default.nix:
{ pkgs ? import ./nix/nixpkgs.nix { config = { allowUnfree = true; }; }
, lib ? pkgs.lib
, stdenv ? pkgs.stdenv
, generatedCargoNix ? import ./Cargo.nix
}:
let
llvmclang = pkgs.llvmPackages_latest.libclang;
generatedBuild = pkgs.callPackage generatedCargoNix {
defaultCrateOverrides = pkgs.defaultCrateOverrides // {
v4l2-sys-mit = attrs: {
buildINputs = with pkgs; [
clang
glibc.dev
llvmclang
linuxHeaders
libv4l.dev
];
LIBCLANG_PATH = "${llvmclang.lib}/lib";
BINDGEN_EXTRA_CLANG_ARGS = "-I${pkgs.linuxHeaders}/include -I${pkgs.glibc.dev}/include";
};
my-crate = attrs: {
buildInputs = with pkgs; [
clang
cudaPackages.cuda_cudart
cudaPackages.cuda_nvcc
cudaPackages.libcufft
];
CFLAGS = "-I${pkgs.cudaPackages.cuda_cudart}/include";
CXXFLAGS = "-I${pkgs.cudaPackages.cuda_cudart}/include";
CUDA_HOST_COMPILER = "${pkgs.clang}/bin/clang";
CXX = "clang";
};
};
};
in
generatedBuild.rootCrate.build
But i got an error
You should be able to generate Cargo.nix with the normal nixpkgs rustc. Then when calling it, you override buildRustCrateForPkgs. I have an example here: https://github.com/apoelstra/local-nix-ci/blob/main/andrew-utils.nix#L527-L573 though this also does several other things which might not be interesting to you.
@apoelstra I'm very sorry, but I couldn't implement your example in my code. Could you send another example or explain this one in more detail, please?