rust-analyzer: init at unstable-2020-03-09
This commit is contained in:
parent
5a8777ae50
commit
3ea54e6972
14
pkgs/development/tools/rust/rust-analyzer/default.nix
Normal file
14
pkgs/development/tools/rust/rust-analyzer/default.nix
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{ pkgs, callPackage }:
|
||||||
|
|
||||||
|
{
|
||||||
|
rust-analyzer-unwrapped = callPackage ./generic.nix rec {
|
||||||
|
rev = "2020-03-09";
|
||||||
|
version = "unstable-${rev}";
|
||||||
|
sha256 = "1m97sinfyg43p3crhbjrsgf64bn5pyj7m96ikvznps80w8dnsv5n";
|
||||||
|
cargoSha256 = "0rxmyv8va4za0aghwk9765qn4xwd03nnry83mrkjidw0ripka5sf";
|
||||||
|
};
|
||||||
|
|
||||||
|
rust-analyzer = callPackage ./wrapper.nix {} {
|
||||||
|
unwrapped = pkgs.rust-analyzer-unwrapped;
|
||||||
|
};
|
||||||
|
}
|
45
pkgs/development/tools/rust/rust-analyzer/generic.nix
Normal file
45
pkgs/development/tools/rust/rust-analyzer/generic.nix
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{ lib, stdenv, fetchFromGitHub, rustPlatform, darwin
|
||||||
|
, useJemalloc ? false
|
||||||
|
, doCheck ? true
|
||||||
|
|
||||||
|
# Version specific args
|
||||||
|
, rev, version, sha256, cargoSha256 }:
|
||||||
|
|
||||||
|
rustPlatform.buildRustPackage {
|
||||||
|
pname = "rust-analyzer-unwrapped";
|
||||||
|
inherit version cargoSha256;
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "rust-analyzer";
|
||||||
|
repo = "rust-analyzer";
|
||||||
|
inherit rev sha256;
|
||||||
|
};
|
||||||
|
|
||||||
|
preBuild = "pushd crates/rust-analyzer";
|
||||||
|
# Do not checking other crates in checkPhase.
|
||||||
|
preInstall = "popd";
|
||||||
|
|
||||||
|
cargoBuildFlags = lib.optional useJemalloc "--features=jemalloc";
|
||||||
|
|
||||||
|
nativeBuildInputs = lib.optionals doCheck [ rustPlatform.rustcSrc ];
|
||||||
|
|
||||||
|
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin
|
||||||
|
[ darwin.apple_sdk.frameworks.CoreServices ];
|
||||||
|
|
||||||
|
inherit doCheck;
|
||||||
|
# Skip tests running `rustup` for `cargo fmt`.
|
||||||
|
preCheck = ''
|
||||||
|
fakeRustup=$(mktemp -d)
|
||||||
|
ln -s $(command -v true) $fakeRustup/rustup
|
||||||
|
export PATH=$PATH''${PATH:+:}$fakeRustup
|
||||||
|
export RUST_SRC_PATH=${rustPlatform.rustcSrc}
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with stdenv.lib; {
|
||||||
|
description = "An experimental modular compiler frontend for the Rust language";
|
||||||
|
homepage = "https://github.com/rust-analyzer/rust-analyzer";
|
||||||
|
license = with licenses; [ mit asl20 ];
|
||||||
|
maintainers = with maintainers; [ oxalica ];
|
||||||
|
platforms = platforms.all;
|
||||||
|
};
|
||||||
|
}
|
39
pkgs/development/tools/rust/rust-analyzer/update.sh
Executable file
39
pkgs/development/tools/rust/rust-analyzer/update.sh
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#!nix-shell -i bash -p curl jq nix-prefetch-github
|
||||||
|
set -euo pipefail
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
owner=rust-analyzer
|
||||||
|
repo=rust-analyzer
|
||||||
|
nixpkgs=../../../../..
|
||||||
|
|
||||||
|
# Update lsp
|
||||||
|
|
||||||
|
rev=$(
|
||||||
|
curl -s "https://api.github.com/repos/$owner/$repo/releases" |
|
||||||
|
jq 'map(select(.prerelease | not)) | .[0].tag_name' --raw-output
|
||||||
|
)
|
||||||
|
old_rev=$(sed -nE 's/.*\brev = "(.*)".*/\1/p' ./default.nix)
|
||||||
|
if grep -q '0000000000000000000000000000000000000000000000000000' ./default.nix; then
|
||||||
|
old_rev='broken'
|
||||||
|
fi
|
||||||
|
if [[ "$rev" == "$old_rev" ]]; then
|
||||||
|
echo "Up to date: $rev"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
echo "$old_rev -> $rev"
|
||||||
|
|
||||||
|
sha256=$(nix-prefetch-github --prefetch "$owner" "$repo" --rev "$rev" | jq '.sha256' --raw-output)
|
||||||
|
sed -e "s/rev = \".*\"/rev = \"$rev\"/" \
|
||||||
|
-e "s/sha256 = \".*\"/sha256 = \"$sha256\"/" \
|
||||||
|
-e "s/cargoSha256 = \".*\"/cargoSha256 = \"0000000000000000000000000000000000000000000000000000\"/" \
|
||||||
|
--in-place ./default.nix
|
||||||
|
|
||||||
|
echo "Prebuilding nix"
|
||||||
|
cargo_sha256=$({
|
||||||
|
! nix-build "$nixpkgs" -A rust-analyzer-unwrapped --no-out-link 2>&1
|
||||||
|
} | tee /dev/stderr | sed -nE 's/\s*got:\s*sha256:(\w+)/\1/p' | head -n1)
|
||||||
|
echo "cargoSha256: $cargo_sha256"
|
||||||
|
[[ "$cargo_sha256" ]]
|
||||||
|
sed "s/cargoSha256 = \".*\"/cargoSha256 = \"$cargo_sha256\"/" \
|
||||||
|
--in-place ./default.nix
|
||||||
|
|
16
pkgs/development/tools/rust/rust-analyzer/wrapper.nix
Normal file
16
pkgs/development/tools/rust/rust-analyzer/wrapper.nix
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{ lib, rustPlatform, runCommandNoCC, makeWrapper }:
|
||||||
|
|
||||||
|
lib.makeOverridable ({
|
||||||
|
unwrapped,
|
||||||
|
pname ? "rust-analyzer",
|
||||||
|
version ? unwrapped.version,
|
||||||
|
rustcSrc ? rustPlatform.rustcSrc,
|
||||||
|
}: runCommandNoCC "${pname}-${version}" {
|
||||||
|
inherit pname version;
|
||||||
|
inherit (unwrapped) src meta;
|
||||||
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
|
} ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
makeWrapper ${unwrapped}/bin/rust-analyzer $out/bin/rust-analyzer \
|
||||||
|
--set-default RUST_SRC_PATH "${rustcSrc}"
|
||||||
|
'')
|
@ -8904,6 +8904,8 @@ in
|
|||||||
inherit (rustPackages_1_38_0) rustPlatform;
|
inherit (rustPackages_1_38_0) rustPlatform;
|
||||||
inherit (darwin.apple_sdk.frameworks) Security;
|
inherit (darwin.apple_sdk.frameworks) Security;
|
||||||
};
|
};
|
||||||
|
inherit (callPackage ../development/tools/rust/rust-analyzer { })
|
||||||
|
rust-analyzer-unwrapped rust-analyzer;
|
||||||
rust-bindgen = callPackage ../development/tools/rust/bindgen { };
|
rust-bindgen = callPackage ../development/tools/rust/bindgen { };
|
||||||
rust-cbindgen = callPackage ../development/tools/rust/cbindgen {
|
rust-cbindgen = callPackage ../development/tools/rust/cbindgen {
|
||||||
inherit (darwin.apple_sdk.frameworks) Security;
|
inherit (darwin.apple_sdk.frameworks) Security;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user