nixpkgs/pkgs/applications/blockchains/polkadot/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

92 lines
2.9 KiB
Nix
Raw Normal View History

2023-03-29 09:36:02 +00:00
{ fetchFromGitHub
2020-09-25 23:41:01 +00:00
, lib
, protobuf
, rocksdb_8_3
, rust-jemalloc-sys-unprefixed
2018-12-05 14:10:31 +00:00
, rustPlatform
, rustc
2022-04-03 15:22:08 +00:00
, stdenv
2022-03-29 14:33:10 +00:00
, Security
2023-01-23 12:42:20 +00:00
, SystemConfiguration
2018-12-05 14:10:31 +00:00
}:
let
rocksdb = rocksdb_8_3;
in
2018-12-05 14:10:31 +00:00
rustPlatform.buildRustPackage rec {
2019-08-31 11:41:23 +00:00
pname = "polkadot";
2024-04-09 14:14:46 +00:00
version = "1.10.0";
2018-12-05 14:10:31 +00:00
src = fetchFromGitHub {
owner = "paritytech";
2023-09-26 09:58:26 +00:00
repo = "polkadot-sdk";
rev = "polkadot-v${version}";
2024-04-09 14:14:46 +00:00
hash = "sha256-xRuV/1+OZeoth/lb5OXwVzHl2IWK1G0GgIN0E8EZlYg=";
2022-03-21 18:18:11 +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.
leaveDotGit = true;
postFetch = ''
( cd $out; git rev-parse --short HEAD > .git_commit )
rm -rf $out/.git
'';
};
2023-09-26 09:58:26 +00:00
preBuild = ''
export SUBSTRATE_CLI_GIT_COMMIT_HASH=$(< .git_commit)
2023-09-26 09:58:26 +00:00
rm .git_commit
'';
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"ark-secret-scalar-0.0.2" = "sha256-91sODxaj0psMw0WqigMCGO5a7+NenAsRj5ZmW6C7lvc=";
"common-0.1.0" = "sha256-LHz2dK1p8GwyMimlR7AxHLz1tjTYolPwdjP7pxork1o=";
"fflonk-0.1.0" = "sha256-+BvZ03AhYNP0D8Wq9EMsP+lSgPA6BBlnWkoxTffVLwo=";
2023-11-24 13:05:26 +00:00
"sp-ark-bls12-381-0.4.2" = "sha256-nNr0amKhSvvI9BlsoP+8v6Xppx/s7zkf0l9Lm3DW8w8=";
2023-12-19 22:38:25 +00:00
"sp-crypto-ec-utils-0.4.1" = "sha256-/Sw1ZM/JcJBokFE4y2mv/P43ciTL5DEm0PDG0jZvMkI=";
};
};
2022-03-21 18:18:11 +00:00
2023-10-22 17:10:03 +00:00
buildType = "production";
2023-09-26 09:58:26 +00:00
cargoBuildFlags = [ "-p" "polkadot" ];
2023-07-20 11:22:21 +00:00
2023-09-26 09:58:26 +00:00
# NOTE: tests currently fail to compile due to an issue with cargo-auditable
# and resolution of features flags, potentially related to this:
2023-09-26 09:58:26 +00:00
# https://github.com/rust-secure-code/cargo-auditable/issues/66
doCheck = false;
2022-03-29 14:33:10 +00:00
2023-09-26 09:58:26 +00:00
nativeBuildInputs = [
rustPlatform.bindgenHook
rustc
rustc.llvmPackages.lld
2023-09-26 09:58:26 +00:00
];
2020-09-25 23:41:01 +00:00
2023-10-22 17:10:03 +00:00
# NOTE: jemalloc is used by default on Linux with unprefixed enabled
buildInputs = lib.optionals stdenv.isLinux [ rust-jemalloc-sys-unprefixed ] ++
lib.optionals stdenv.isDarwin [ Security SystemConfiguration ];
2020-09-25 23:41:01 +00:00
2023-12-19 22:38:25 +00:00
# NOTE: disable building `core`/`std` in wasm environment since rust-src isn't
# available for `rustc-wasm32`
WASM_BUILD_STD = 0;
2023-09-26 09:58:26 +00:00
# NOTE: we need to force lld otherwise rust-lld is not found for wasm32 target
CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_LINKER = "lld";
2020-09-25 23:41:01 +00:00
PROTOC = "${protobuf}/bin/protoc";
2023-01-24 10:10:14 +00:00
ROCKSDB_LIB_DIR = "${rocksdb}/lib";
2020-09-25 23:41:01 +00:00
meta = with lib; {
2018-12-05 14:10:31 +00:00
description = "Polkadot Node Implementation";
homepage = "https://polkadot.network";
2021-03-06 02:30:43 +00:00
license = licenses.gpl3Only;
maintainers = with maintainers; [ akru andresilva FlorianFranzen RaghavSood ];
2022-03-29 14:33:10 +00:00
platforms = platforms.unix;
2018-12-05 14:10:31 +00:00
};
}