diff options
| author | Sakarias Johansson <sakarias.johansson@goodbyekansas.com> | 2023-01-05 17:22:10 +0100 |
|---|---|---|
| committer | Sakarias Johansson <sakarias.johansson@goodbyekansas.com> | 2023-01-05 17:22:10 +0100 |
| commit | cf7bd1aec7e9908f80bfc014fc53a1144e17ccb5 (patch) | |
| tree | d37492001d250f7dc7a1584415181ad443f62d8a /default.nix | |
| download | racer-tracer-cf7bd1aec7e9908f80bfc014fc53a1144e17ccb5.tar.gz racer-tracer-cf7bd1aec7e9908f80bfc014fc53a1144e17ccb5.tar.xz racer-tracer-cf7bd1aec7e9908f80bfc014fc53a1144e17ccb5.zip | |
Initial commit 🎉
Diffstat (limited to 'default.nix')
| -rw-r--r-- | default.nix | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..fe76061 --- /dev/null +++ b/default.nix @@ -0,0 +1,66 @@ +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 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64/ + export RUST_SRC_PATH=${rustSrcNoSymlinks} + ''; +} |
