2020-10-20 17:27:49 +00:00
|
|
|
{ clang
|
2020-04-24 23:36:52 +00:00
|
|
|
, fetchFromGitHub
|
2020-10-20 17:27:49 +00:00
|
|
|
, lib
|
|
|
|
, llvmPackages
|
|
|
|
, protobuf
|
2020-04-24 23:36:52 +00:00
|
|
|
, rustPlatform
|
2022-04-03 18:54:34 +00:00
|
|
|
, stdenv
|
2022-02-20 05:27:41 +00:00
|
|
|
, writeShellScriptBin
|
2022-03-30 09:31:56 +00:00
|
|
|
, Security
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "polkadot";
|
2022-05-18 14:49:53 +00:00
|
|
|
version = "0.9.21";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "paritytech";
|
2020-10-20 17:27:49 +00:00
|
|
|
repo = "polkadot";
|
|
|
|
rev = "v${version}";
|
2022-05-18 14:49:53 +00:00
|
|
|
sha256 = "HCj5WwfKa4QsfO+1u4ciukDg6Rzv/uvc8h+V/Duhksg=";
|
2022-02-20 05:27:41 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
# the build process of polkadot requires a .git folder in order to determine
|
|
|
|
# the git commit hash that is being built and add it to the version string.
|
|
|
|
# since having a .git folder introduces reproducibility issues to the nix
|
|
|
|
# build, we check the git commit hash after fetching the source and save it
|
|
|
|
# into a .git_commit file, and then delete the .git folder. we can then use
|
|
|
|
# this file to populate an environment variable with the commit hash, which
|
|
|
|
# is picked up by polkadot's build process.
|
2022-02-20 05:27:41 +00:00
|
|
|
leaveDotGit = true;
|
|
|
|
postFetch = ''
|
|
|
|
( cd $out; git rev-parse --short HEAD > .git_commit )
|
|
|
|
rm -rf $out/.git
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
cargoSha256 = "tHU8KygIhJDgID/tGGssYTnY8raI5qTdLEDwOKox3No=";
|
2020-10-20 17:27:49 +00:00
|
|
|
|
2022-04-03 18:54:34 +00:00
|
|
|
buildInputs = lib.optional stdenv.isDarwin [ Security ];
|
2022-03-30 09:31:56 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [ clang ];
|
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
export SUBSTRATE_CLI_GIT_COMMIT_HASH=$(cat .git_commit)
|
|
|
|
rm .git_commit
|
|
|
|
'';
|
2020-10-20 17:27:49 +00:00
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
|
2020-10-20 17:27:49 +00:00
|
|
|
PROTOC = "${protobuf}/bin/protoc";
|
|
|
|
|
|
|
|
# NOTE: We don't build the WASM runtimes since this would require a more
|
2021-02-05 17:12:51 +00:00
|
|
|
# complicated rust environment setup and this is only needed for developer
|
|
|
|
# environments. The resulting binary is useful for end-users of live networks
|
|
|
|
# since those just use the WASM blob from the network chainspec.
|
|
|
|
SKIP_WASM_BUILD = 1;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-20 17:27:49 +00:00
|
|
|
# We can't run the test suite since we didn't compile the WASM runtimes.
|
|
|
|
doCheck = false;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-20 17:27:49 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Polkadot Node Implementation";
|
|
|
|
homepage = "https://polkadot.network";
|
2021-03-09 03:18:52 +00:00
|
|
|
license = licenses.gpl3Only;
|
2021-05-20 23:08:51 +00:00
|
|
|
maintainers = with maintainers; [ akru andresilva asymmetric FlorianFranzen RaghavSood ];
|
2022-03-30 09:31:56 +00:00
|
|
|
platforms = platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|