Well, that answers a good part of my question!
I’m sure I’ll get it to build with this example, but it is not exactly what I’m looking for, let me explain with the following questions :
this method builds the crate as a nixpkg if I’m not mistaken, but what if I actually want to compile it as a crate?
although this will work for compiling this specific package, what about working on a project that has that kind of linking? Would something like nix-shell be the solution for that?
Hey, as I got problems posting via mail, here is my response sent via the web interface.
Hey Luxed,
as Cargo is only a language-level package manager, it will only
automatically install Rust crates for you. neovim-gtk has additional
system dependencies, as you can see in the lengthy apt install command
in their build instructions.
My preferred Nix way of suppliying these dependencies is via nix-shell.
I placed a shell.nix file with the following content in the directory:
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "mydevshell";
buildInputs = with pkgs; [
gtkd
atk
cairo
gdk_pixbuf
glib
gnome2.pango
rustc
cargo
pkgconfig
];
}
The names of the Nix packages differ from those in the apt command. I
found them by grepping Nixpkgs and looking at the PR Matthieu Coudron
mentioned.
With having the shell.nix file in place, you can run nix-shell --pure in the repo to get a development shell in which only the
mentioned packages are installed. This has the advantage, that you don’t
clutter your system with packages you only need once.
I was able to build neovim-gtk inside this shell with being
the current master revision. This is important, as the rustc version in
nixos-18.03 is too old. If you don’t happen too be on something like
nixos-unstable, you may run nix-shell like this:
I have also been struggling with Rust.
I was trying to make a little package for “spotifyd” which seemed pretty simple.
However, rustPlatform.buildRustPackage has been giving me such a headache.
There seems to be some issues with the “replace” declarations of Cargo that leads to multiple versions in the vendor. I have seen a few similar issues pop up in the GitHub Issue tracker, but no solutions.
Thanks for all the help guys !
But now the issue is that the program doesn’t launch. I do cargo build inside the environment, everything compiles just fine, but when I go ahead and do target/debug/nvim-gtk, nothing happens. No log, no nothing. It’s just like if I ran an empty program. I also tried with cargo build --release with no success.
When out of options, try to run strace -fF against the program. It takes a while to sift through the logs but it gives a lot of good clues about what the program is doing. Especially open, stat and execve syscalls, they will tell you if files or programs that were supposed to exist are missing.
Well thank you for that !
I am going through the entire 5k lines right now, but it’s clear that a lot of things are still missing.
It’s weird and I don’t really understand.
From what I see, even though I have included things like glib, I still see No such file errors related to glib.
I want to use NixOS, but for now I cannot use it at all, I’m just lost in dependency hell.