rust-analyzer: merge version specific fields into generic derivation

This commit is contained in:
oxalica 2021-04-12 01:35:08 +08:00
parent d4e758c5ac
commit 6efb930e18
No known key found for this signature in database
GPG Key ID: CED392DE0C483D00
5 changed files with 21 additions and 36 deletions

View File

@ -1,16 +0,0 @@
{ pkgs, callPackage, CoreServices }:
{
rust-analyzer-unwrapped = callPackage ./generic.nix rec {
rev = "2021-04-05";
version = "unstable-${rev}";
sha256 = "sha256-ZDxy87F3uz8bTF1/2LIy5r4Nv/M3xe97F7mwJNEFcUs=";
cargoSha256 = "sha256-kDwdKa08E0h24lOOa7ALeNqHlMjMry/ru1qwCIyKmuE=";
inherit CoreServices;
};
rust-analyzer = callPackage ./wrapper.nix {} {
unwrapped = pkgs.rust-analyzer-unwrapped;
};
}

View File

@ -2,19 +2,22 @@
, libiconv
, useMimalloc ? false
, doCheck ? true
# Version specific args
, rev, version, sha256, cargoSha256
}:
let
rev = "2021-04-05";
in
rustPlatform.buildRustPackage {
pname = "rust-analyzer-unwrapped";
inherit version cargoSha256;
version = "unstable-${rev}";
cargoSha256 = "sha256-kDwdKa08E0h24lOOa7ALeNqHlMjMry/ru1qwCIyKmuE=";
src = fetchFromGitHub {
owner = "rust-analyzer";
repo = "rust-analyzer";
inherit rev sha256;
inherit rev;
sha256 = "sha256-ZDxy87F3uz8bTF1/2LIy5r4Nv/M3xe97F7mwJNEFcUs=";
};
buildAndTestSubdir = "crates/rust-analyzer";

View File

@ -25,7 +25,7 @@ echo "$old_rev -> $rev"
sha256=$(nix-prefetch -f "$nixpkgs" rust-analyzer-unwrapped.src --rev "$rev")
# Clear cargoSha256 to avoid inconsistency.
sed -e "s#rev = \".*\"#rev = \"$rev\"#" \
-e "s#sha256 = \".*\"#sha256 = \"$sha256\"#" \
-e "/fetchFromGitHub/,/}/ s#sha256 = \".*\"#sha256 = \"$sha256\"#" \
-e "s#cargoSha256 = \".*\"#cargoSha256 = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"#" \
--in-place ./default.nix
node_src="$(nix-build "$nixpkgs" -A rust-analyzer.src --no-out-link)/editors/code"

View File

@ -1,17 +1,15 @@
{ lib, rustPlatform, runCommandNoCC, makeWrapper }:
lib.makeOverridable ({
unwrapped,
pname ? "rust-analyzer",
version ? unwrapped.version,
{ lib, rustPlatform, runCommand, makeWrapper, rust-analyzer-unwrapped
, pname ? "rust-analyzer"
, version ? rust-analyzer-unwrapped.version
# Use name from `RUST_SRC_PATH`
rustSrc ? rustPlatform.rustLibSrc,
}: runCommandNoCC "${pname}-${version}" {
, rustSrc ? rustPlatform.rustLibSrc
}:
runCommand "${pname}-${version}" {
inherit pname version;
inherit (unwrapped) src meta;
inherit (rust-analyzer-unwrapped) src meta;
nativeBuildInputs = [ makeWrapper ];
} ''
mkdir -p $out/bin
makeWrapper ${unwrapped}/bin/rust-analyzer $out/bin/rust-analyzer \
makeWrapper ${rust-analyzer-unwrapped}/bin/rust-analyzer $out/bin/rust-analyzer \
--set-default RUST_SRC_PATH "${rustSrc}"
'')
''

View File

@ -11321,10 +11321,10 @@ in
rustracerd = callPackage ../development/tools/rust/racerd {
inherit (darwin.apple_sdk.frameworks) Security;
};
inherit (callPackage ../development/tools/rust/rust-analyzer {
rust-analyzer-unwrapped = callPackage ../development/tools/rust/rust-analyzer {
inherit (darwin.apple_sdk.frameworks) CoreServices;
})
rust-analyzer-unwrapped rust-analyzer;
};
rust-analyzer = callPackage ../development/tools/rust/rust-analyzer/wrapper.nix { };
rust-bindgen = callPackage ../development/tools/rust/bindgen { };
rust-cbindgen = callPackage ../development/tools/rust/cbindgen {
inherit (darwin.apple_sdk.frameworks) Security;