blob: 326d7016973306713d48f671ca9aa9551a71befa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
let
sources = import ./nix/sources.nix;
nixpkgs = with
{
overlay = _: pkgs:
{
niv = (import sources.niv { }).niv;
};
};
import sources.nixpkgs
{
overlays = [ overlay (import sources.rust) ];
config = { };
};
rustBin = nixpkgs.rust-bin.stable."1.65.0".rust;
# rust-analyzer cannot handle symlinks
# so we need to create a derivation with the
# correct rust source without symlinks
rustSrcNoSymlinks = nixpkgs.stdenv.mkDerivation {
name = "rust-src-no-symlinks";
rustWithSrc = (rustBin.override {
extensions = [ "rust-src" ];
});
rust = rustBin;
builder = builtins.toFile "builder.sh" ''
source $stdenv/setup
mkdir -p $out
cp -r -L $rustWithSrc/lib/rustlib/src/rust/library/. $out/
'';
};
in
nixpkgs.stdenv.mkDerivation {
name = "racer-tracer";
src = nixpkgs.nix-gitignore.gitignoreSource [] ./racer-tracer;
nativeBuildInputs = [ rustBin nixpkgs.cacert nixpkgs.xorg.libX11 ];
configurePhase = ''
export CARGO_HOME=$PWD
'';
buildPhase = ''
cargo build --release
'';
checkPhase = ''
cargo fmt -- --check
cargo clippy
cargo test
'';
doCheck = true;
installPhase = ''
mkdir -p $out/bin
find target/release -executable -type f -exec cp {} $out/bin \;
'';
shellHook = ''
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${nixpkgs.lib.makeLibraryPath [ nixpkgs.xorg.libX11 nixpkgs.xorg.libXcursor ] }
export RUST_SRC_PATH=${rustSrcNoSymlinks}
'';
}
|