uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
113
pkgs/build-support/rust/build-rust-crate/build-crate.nix
Normal file
113
pkgs/build-support/rust/build-rust-crate/build-crate.nix
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
{ lib, stdenv, mkRustcDepArgs, mkRustcFeatureArgs, rust }:
|
||||
{ crateName,
|
||||
dependencies,
|
||||
crateFeatures, crateRenames, libName, release, libPath,
|
||||
crateType, metadata, crateBin, hasCrateBin,
|
||||
extraRustcOpts, verbose, colors,
|
||||
buildTests,
|
||||
codegenUnits
|
||||
}:
|
||||
|
||||
let
|
||||
baseRustcOpts =
|
||||
[
|
||||
(if release then "-C opt-level=3" else "-C debuginfo=2")
|
||||
"-C codegen-units=${toString codegenUnits}"
|
||||
"--remap-path-prefix=$NIX_BUILD_TOP=/"
|
||||
(mkRustcDepArgs dependencies crateRenames)
|
||||
(mkRustcFeatureArgs crateFeatures)
|
||||
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||
"--target" (rust.toRustTargetSpec stdenv.hostPlatform)
|
||||
] ++ extraRustcOpts
|
||||
# since rustc 1.42 the "proc_macro" crate is part of the default crate prelude
|
||||
# https://github.com/rust-lang/cargo/commit/4d64eb99a4#diff-7f98585dbf9d30aa100c8318e2c77e79R1021-R1022
|
||||
++ lib.optional (lib.elem "proc-macro" crateType) "--extern proc_macro"
|
||||
;
|
||||
rustcMeta = "-C metadata=${metadata} -C extra-filename=-${metadata}";
|
||||
|
||||
|
||||
# build the final rustc arguments that can be different between different
|
||||
# crates
|
||||
libRustcOpts = lib.concatStringsSep " " (
|
||||
baseRustcOpts
|
||||
++ [rustcMeta]
|
||||
++ (map (x: "--crate-type ${x}") crateType)
|
||||
);
|
||||
|
||||
binRustcOpts = lib.concatStringsSep " " (
|
||||
baseRustcOpts
|
||||
);
|
||||
|
||||
build_bin = if buildTests then "build_bin_test" else "build_bin";
|
||||
in ''
|
||||
runHook preBuild
|
||||
|
||||
# configure & source common build functions
|
||||
LIB_RUSTC_OPTS="${libRustcOpts}"
|
||||
BIN_RUSTC_OPTS="${binRustcOpts}"
|
||||
LIB_EXT="${stdenv.hostPlatform.extensions.sharedLibrary}"
|
||||
LIB_PATH="${libPath}"
|
||||
LIB_NAME="${libName}"
|
||||
|
||||
CRATE_NAME='${lib.replaceStrings ["-"] ["_"] libName}'
|
||||
|
||||
setup_link_paths
|
||||
|
||||
if [[ -e "$LIB_PATH" ]]; then
|
||||
build_lib "$LIB_PATH"
|
||||
${lib.optionalString buildTests ''build_lib_test "$LIB_PATH"''}
|
||||
elif [[ -e src/lib.rs ]]; then
|
||||
build_lib src/lib.rs
|
||||
${lib.optionalString buildTests "build_lib_test src/lib.rs"}
|
||||
fi
|
||||
|
||||
|
||||
|
||||
${lib.optionalString (lib.length crateBin > 0) (lib.concatMapStringsSep "\n" (bin: ''
|
||||
mkdir -p target/bin
|
||||
BIN_NAME='${bin.name or crateName}'
|
||||
${if !bin ? path then ''
|
||||
BIN_PATH=""
|
||||
search_for_bin_path "$BIN_NAME"
|
||||
'' else ''
|
||||
BIN_PATH='${bin.path}'
|
||||
''}
|
||||
${build_bin} "$BIN_NAME" "$BIN_PATH"
|
||||
'') crateBin)}
|
||||
|
||||
${lib.optionalString buildTests ''
|
||||
# When tests are enabled build all the files in the `tests` directory as
|
||||
# test binaries.
|
||||
if [ -d tests ]; then
|
||||
# find all the .rs files (or symlinks to those) in the tests directory, no subdirectories
|
||||
find tests -maxdepth 1 \( -type f -o -type l \) -a -name '*.rs' -print0 | while IFS= read -r -d ''' file; do
|
||||
mkdir -p target/bin
|
||||
build_bin_test_file "$file"
|
||||
done
|
||||
|
||||
# find all the subdirectories of tests/ that contain a main.rs file as
|
||||
# that is also a test according to cargo
|
||||
find tests/ -mindepth 1 -maxdepth 2 \( -type f -o -type l \) -a -name 'main.rs' -print0 | while IFS= read -r -d ''' file; do
|
||||
mkdir -p target/bin
|
||||
build_bin_test_file "$file"
|
||||
done
|
||||
|
||||
fi
|
||||
''}
|
||||
|
||||
# If crateBin is empty and hasCrateBin is not set then we must try to
|
||||
# detect some kind of bin target based on some files that might exist.
|
||||
${lib.optionalString (lib.length crateBin == 0 && !hasCrateBin) ''
|
||||
if [[ -e src/main.rs ]]; then
|
||||
mkdir -p target/bin
|
||||
${build_bin} ${crateName} src/main.rs
|
||||
fi
|
||||
for i in src/bin/*.rs; do #*/
|
||||
mkdir -p target/bin
|
||||
${build_bin} "$(basename $i .rs)" "$i"
|
||||
done
|
||||
''}
|
||||
# Remove object files to avoid "wrong ELF type"
|
||||
find target -type f -name "*.o" -print0 | xargs -0 rm -f
|
||||
runHook postBuild
|
||||
''
|
||||
202
pkgs/build-support/rust/build-rust-crate/configure-crate.nix
Normal file
202
pkgs/build-support/rust/build-rust-crate/configure-crate.nix
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
{ lib, stdenv, rust, echo_colored, noisily, mkRustcDepArgs, mkRustcFeatureArgs }:
|
||||
{
|
||||
build
|
||||
, buildDependencies
|
||||
, codegenUnits
|
||||
, colors
|
||||
, completeBuildDeps
|
||||
, completeDeps
|
||||
, crateAuthors
|
||||
, crateDescription
|
||||
, crateHomepage
|
||||
, crateFeatures
|
||||
, crateName
|
||||
, crateRenames
|
||||
, crateVersion
|
||||
, extraLinkFlags
|
||||
, extraRustcOptsForBuildRs
|
||||
, libName
|
||||
, libPath
|
||||
, release
|
||||
, verbose
|
||||
, workspace_member }:
|
||||
let version_ = lib.splitString "-" crateVersion;
|
||||
versionPre = if lib.tail version_ == [] then "" else lib.elemAt version_ 1;
|
||||
version = lib.splitVersion (lib.head version_);
|
||||
rustcOpts = lib.foldl' (opts: opt: opts + " " + opt)
|
||||
(if release then "-C opt-level=3" else "-C debuginfo=2")
|
||||
(["-C codegen-units=${toString codegenUnits}"] ++ extraRustcOptsForBuildRs);
|
||||
buildDeps = mkRustcDepArgs buildDependencies crateRenames;
|
||||
authors = lib.concatStringsSep ":" crateAuthors;
|
||||
optLevel = if release then 3 else 0;
|
||||
completeDepsDir = lib.concatStringsSep " " completeDeps;
|
||||
completeBuildDepsDir = lib.concatStringsSep " " completeBuildDeps;
|
||||
envFeatures = lib.concatStringsSep " " (
|
||||
map (f: lib.replaceChars ["-"] ["_"] (lib.toUpper f)) crateFeatures
|
||||
);
|
||||
in ''
|
||||
${echo_colored colors}
|
||||
${noisily colors verbose}
|
||||
source ${./lib.sh}
|
||||
|
||||
${lib.optionalString (workspace_member != null) ''
|
||||
noisily cd "${workspace_member}"
|
||||
''}
|
||||
${lib.optionalString (workspace_member == null) ''
|
||||
echo_colored "Searching for matching Cargo.toml (${crateName})"
|
||||
local cargo_toml_dir=$(matching_cargo_toml_dir "${crateName}")
|
||||
if [ -z "$cargo_toml_dir" ]; then
|
||||
echo_error "ERROR configuring ${crateName}: No matching Cargo.toml in $(pwd) found." >&2
|
||||
exit 23
|
||||
fi
|
||||
noisily cd "$cargo_toml_dir"
|
||||
''}
|
||||
|
||||
runHook preConfigure
|
||||
|
||||
symlink_dependency() {
|
||||
# $1 is the nix-store path of a dependency
|
||||
# $2 is the target path
|
||||
i=$1
|
||||
ln -s -f $i/lib/*.rlib $2 #*/
|
||||
ln -s -f $i/lib/*.so $i/lib/*.dylib $2 #*/
|
||||
if [ -e $i/env ]; then
|
||||
source $i/env
|
||||
fi
|
||||
}
|
||||
|
||||
# The following steps set up the dependencies of the crate. Two
|
||||
# kinds of dependencies are distinguished: build dependencies
|
||||
# (used by the build script) and crate dependencies. For each
|
||||
# dependency we have to:
|
||||
#
|
||||
# - Make its Rust library available to rustc. This is done by
|
||||
# symlinking all library dependencies into a directory that
|
||||
# can be provided to rustc.
|
||||
# - Accumulate linking flags. These flags are largely used for
|
||||
# linking native libraries.
|
||||
#
|
||||
# The crate link flags are added to the `link` and `link.final`
|
||||
# files. The `link` file is used for linkage in the current
|
||||
# crate. The `link.final` file will be copied to the output and can
|
||||
# be used by downstream crates to get the linker flags of this
|
||||
# crate.
|
||||
|
||||
mkdir -p target/{deps,lib,build,buildDeps}
|
||||
chmod uga+w target -R
|
||||
echo ${extraLinkFlags} > target/link
|
||||
echo ${extraLinkFlags} > target/link.final
|
||||
|
||||
# Prepare crate dependencies
|
||||
for i in ${completeDepsDir}; do
|
||||
symlink_dependency $i target/deps
|
||||
if [ -e "$i/lib/link" ]; then
|
||||
cat $i/lib/link >> target/link
|
||||
cat $i/lib/link >> target/link.final
|
||||
fi
|
||||
done
|
||||
|
||||
# Prepare crate build dependencies that are used for the build script.
|
||||
for i in ${completeBuildDepsDir}; do
|
||||
symlink_dependency $i target/buildDeps
|
||||
if [ -e "$i/lib/link" ]; then
|
||||
cat $i/lib/link >> target/link.build
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove duplicate linker flags from the build dependencies.
|
||||
if [[ -e target/link.build ]]; then
|
||||
sort -uo target/link.build target/link.build
|
||||
fi
|
||||
|
||||
# Remove duplicate linker flags from the dependencies.
|
||||
sort -uo target/link target/link
|
||||
tr '\n' ' ' < target/link > target/link_
|
||||
|
||||
# Remove duplicate linker flags from the that are written
|
||||
# to the derivation's output.
|
||||
sort -uo target/link.final target/link.final
|
||||
|
||||
EXTRA_BUILD=""
|
||||
BUILD_OUT_DIR=""
|
||||
export CARGO_PKG_NAME=${crateName}
|
||||
export CARGO_PKG_VERSION=${crateVersion}
|
||||
export CARGO_PKG_AUTHORS="${authors}"
|
||||
export CARGO_PKG_DESCRIPTION="${crateDescription}"
|
||||
|
||||
export CARGO_CFG_TARGET_ARCH=${rust.toTargetArch stdenv.hostPlatform}
|
||||
export CARGO_CFG_TARGET_OS=${rust.toTargetOs stdenv.hostPlatform}
|
||||
export CARGO_CFG_TARGET_FAMILY="unix"
|
||||
export CARGO_CFG_UNIX=1
|
||||
export CARGO_CFG_TARGET_ENV="gnu"
|
||||
export CARGO_CFG_TARGET_ENDIAN=${if stdenv.hostPlatform.parsed.cpu.significantByte.name == "littleEndian" then "little" else "big"}
|
||||
export CARGO_CFG_TARGET_POINTER_WIDTH=${toString stdenv.hostPlatform.parsed.cpu.bits}
|
||||
export CARGO_CFG_TARGET_VENDOR=${stdenv.hostPlatform.parsed.vendor.name}
|
||||
|
||||
export CARGO_MANIFEST_DIR=$(pwd)
|
||||
export DEBUG="${toString (!release)}"
|
||||
export OPT_LEVEL="${toString optLevel}"
|
||||
export TARGET="${rust.toRustTargetSpec stdenv.hostPlatform}"
|
||||
export HOST="${rust.toRustTargetSpec stdenv.buildPlatform}"
|
||||
export PROFILE=${if release then "release" else "debug"}
|
||||
export OUT_DIR=$(pwd)/target/build/${crateName}.out
|
||||
export CARGO_PKG_VERSION_MAJOR=${lib.elemAt version 0}
|
||||
export CARGO_PKG_VERSION_MINOR=${lib.elemAt version 1}
|
||||
export CARGO_PKG_VERSION_PATCH=${lib.elemAt version 2}
|
||||
export CARGO_PKG_VERSION_PRE="${versionPre}"
|
||||
export CARGO_PKG_HOMEPAGE="${crateHomepage}"
|
||||
export NUM_JOBS=$NIX_BUILD_CORES
|
||||
export RUSTC="rustc"
|
||||
export RUSTDOC="rustdoc"
|
||||
|
||||
BUILD=""
|
||||
if [[ ! -z "${build}" ]] ; then
|
||||
BUILD=${build}
|
||||
elif [[ -e "build.rs" ]]; then
|
||||
BUILD="build.rs"
|
||||
fi
|
||||
|
||||
# Compile and run the build script, when available.
|
||||
if [[ ! -z "$BUILD" ]] ; then
|
||||
echo_build_heading "$BUILD" ${libName}
|
||||
mkdir -p target/build/${crateName}
|
||||
EXTRA_BUILD_FLAGS=""
|
||||
if [ -e target/link.build ]; then
|
||||
EXTRA_BUILD_FLAGS="$EXTRA_BUILD_FLAGS $(tr '\n' ' ' < target/link.build)"
|
||||
fi
|
||||
noisily rustc --crate-name build_script_build $BUILD --crate-type bin ${rustcOpts} \
|
||||
${mkRustcFeatureArgs crateFeatures} --out-dir target/build/${crateName} --emit=dep-info,link \
|
||||
-L dependency=target/buildDeps ${buildDeps} --cap-lints allow $EXTRA_BUILD_FLAGS --color ${colors}
|
||||
|
||||
mkdir -p target/build/${crateName}.out
|
||||
export RUST_BACKTRACE=1
|
||||
BUILD_OUT_DIR="-L $OUT_DIR"
|
||||
mkdir -p $OUT_DIR
|
||||
|
||||
(
|
||||
# Features should be set as environment variable for build scripts:
|
||||
# https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts
|
||||
for feature in ${envFeatures}; do
|
||||
export CARGO_FEATURE_$feature=1
|
||||
done
|
||||
|
||||
target/build/${crateName}/build_script_build > target/build/${crateName}.opt
|
||||
)
|
||||
|
||||
set +e
|
||||
EXTRA_BUILD=$(sed -n "s/^cargo:rustc-flags=\(.*\)/\1/p" target/build/${crateName}.opt | tr '\n' ' ' | sort -u)
|
||||
EXTRA_FEATURES=$(sed -n "s/^cargo:rustc-cfg=\(.*\)/--cfg \1/p" target/build/${crateName}.opt | tr '\n' ' ')
|
||||
EXTRA_LINK=$(sed -n "s/^cargo:rustc-link-lib=\(.*\)/\1/p" target/build/${crateName}.opt | tr '\n' ' ')
|
||||
EXTRA_LINK_SEARCH=$(sed -n "s/^cargo:rustc-link-search=\(.*\)/\1/p" target/build/${crateName}.opt | tr '\n' ' ' | sort -u)
|
||||
|
||||
for env in $(sed -n "s/^cargo:rustc-env=\(.*\)/\1/p" target/build/${crateName}.opt); do
|
||||
export $env
|
||||
done
|
||||
|
||||
CRATENAME=$(echo ${crateName} | sed -e "s/\(.*\)-sys$/\U\1/" -e "s/-/_/g")
|
||||
grep -P "^cargo:(?!(rustc-|warning=|rerun-if-changed=|rerun-if-env-changed))" target/build/${crateName}.opt \
|
||||
| awk -F= "/^cargo:/ { sub(/^cargo:/, \"\", \$1); gsub(/-/, \"_\", \$1); print \"export \" toupper(\"DEP_$(echo $CRATENAME)_\" \$1) \"=\" \$2 }" > target/env
|
||||
set -e
|
||||
fi
|
||||
runHook postConfigure
|
||||
''
|
||||
380
pkgs/build-support/rust/build-rust-crate/default.nix
Normal file
380
pkgs/build-support/rust/build-rust-crate/default.nix
Normal file
|
|
@ -0,0 +1,380 @@
|
|||
# Code for buildRustCrate, a Nix function that builds Rust code, just
|
||||
# like Cargo, but using Nix instead.
|
||||
#
|
||||
# This can be useful for deploying packages with NixOps, and to share
|
||||
# binary dependencies between projects.
|
||||
|
||||
{ lib
|
||||
, stdenv
|
||||
, defaultCrateOverrides
|
||||
, fetchCrate
|
||||
, pkgsBuildBuild
|
||||
, rustc
|
||||
, rust
|
||||
, cargo
|
||||
, jq
|
||||
, libiconv
|
||||
}:
|
||||
|
||||
let
|
||||
# Create rustc arguments to link against the given list of dependencies
|
||||
# and renames.
|
||||
#
|
||||
# See docs for crateRenames below.
|
||||
mkRustcDepArgs = dependencies: crateRenames:
|
||||
lib.concatMapStringsSep " "
|
||||
(dep:
|
||||
let
|
||||
normalizeName = lib.replaceStrings [ "-" ] [ "_" ];
|
||||
extern = normalizeName dep.libName;
|
||||
# Find a choice that matches in name and optionally version.
|
||||
findMatchOrUseExtern = choices:
|
||||
lib.findFirst
|
||||
(choice:
|
||||
(!(choice ? version)
|
||||
|| choice.version == dep.version or ""))
|
||||
{ rename = extern; }
|
||||
choices;
|
||||
name =
|
||||
if lib.hasAttr dep.crateName crateRenames then
|
||||
let choices = crateRenames.${dep.crateName};
|
||||
in
|
||||
normalizeName (
|
||||
if builtins.isList choices
|
||||
then (findMatchOrUseExtern choices).rename
|
||||
else choices
|
||||
)
|
||||
else
|
||||
extern;
|
||||
in
|
||||
(if lib.any (x: x == "lib" || x == "rlib") dep.crateType then
|
||||
" --extern ${name}=${dep.lib}/lib/lib${extern}-${dep.metadata}.rlib"
|
||||
else
|
||||
" --extern ${name}=${dep.lib}/lib/lib${extern}-${dep.metadata}${stdenv.hostPlatform.extensions.sharedLibrary}")
|
||||
)
|
||||
dependencies;
|
||||
|
||||
# Create feature arguments for rustc.
|
||||
mkRustcFeatureArgs = lib.concatMapStringsSep " " (f: ''--cfg feature=\"${f}\"'');
|
||||
|
||||
inherit (import ./log.nix { inherit lib; }) noisily echo_colored;
|
||||
|
||||
configureCrate = import ./configure-crate.nix {
|
||||
inherit lib stdenv rust echo_colored noisily mkRustcDepArgs mkRustcFeatureArgs;
|
||||
};
|
||||
|
||||
buildCrate = import ./build-crate.nix {
|
||||
inherit lib stdenv mkRustcDepArgs mkRustcFeatureArgs rust;
|
||||
};
|
||||
|
||||
installCrate = import ./install-crate.nix { inherit stdenv; };
|
||||
|
||||
# Allow access to the rust attribute set from inside buildRustCrate, which
|
||||
# has a parameter that shadows the name.
|
||||
rustAttrs = rust;
|
||||
in
|
||||
|
||||
/* The overridable pkgs.buildRustCrate function.
|
||||
*
|
||||
* Any unrecognized parameters will be passed as to
|
||||
* the underlying stdenv.mkDerivation.
|
||||
*/
|
||||
crate_: lib.makeOverridable
|
||||
(
|
||||
# The rust compiler to use.
|
||||
#
|
||||
# Default: pkgs.rustc
|
||||
{ rust
|
||||
# Whether to build a release version (`true`) or a debug
|
||||
# version (`false`). Debug versions are faster to build
|
||||
# but might be much slower at runtime.
|
||||
, release
|
||||
# Whether to print rustc invocations etc.
|
||||
#
|
||||
# Example: false
|
||||
# Default: true
|
||||
, verbose
|
||||
# A list of rust/cargo features to enable while building the crate.
|
||||
# Example: [ "std" "async" ]
|
||||
, features
|
||||
# Additional native build inputs for building this crate.
|
||||
, nativeBuildInputs
|
||||
# Additional build inputs for building this crate.
|
||||
#
|
||||
# Example: [ pkgs.openssl ]
|
||||
, buildInputs
|
||||
# Allows to override the parameters to buildRustCrate
|
||||
# for any rust dependency in the transitive build tree.
|
||||
#
|
||||
# Default: pkgs.defaultCrateOverrides
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# pkgs.defaultCrateOverrides // {
|
||||
# hello = attrs: { buildInputs = [ openssl ]; };
|
||||
# }
|
||||
, crateOverrides
|
||||
# Rust library dependencies, i.e. other libaries that were built
|
||||
# with buildRustCrate.
|
||||
, dependencies
|
||||
# Rust build dependencies, i.e. other libaries that were built
|
||||
# with buildRustCrate and are used by a build script.
|
||||
, buildDependencies
|
||||
# Specify the "extern" name of a library if it differs from the library target.
|
||||
# See above for an extended explanation.
|
||||
#
|
||||
# Default: no renames.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# `crateRenames` supports two formats.
|
||||
#
|
||||
# The simple version is an attrset that maps the
|
||||
# `crateName`s of the dependencies to their alternative
|
||||
# names.
|
||||
#
|
||||
# ```nix
|
||||
# {
|
||||
# my_crate_name = "my_alternative_name";
|
||||
# # ...
|
||||
# }
|
||||
# ```
|
||||
#
|
||||
# The extended version is also keyed by the `crateName`s but allows
|
||||
# different names for different crate versions:
|
||||
#
|
||||
# ```nix
|
||||
# {
|
||||
# my_crate_name = [
|
||||
# { version = "1.2.3"; rename = "my_alternative_name01"; }
|
||||
# { version = "3.2.3"; rename = "my_alternative_name03"; }
|
||||
# ]
|
||||
# # ...
|
||||
# }
|
||||
# ```
|
||||
#
|
||||
# This roughly corresponds to the following snippet in Cargo.toml:
|
||||
#
|
||||
# ```toml
|
||||
# [dependencies]
|
||||
# my_alternative_name01 = { package = "my_crate_name", version = "0.1" }
|
||||
# my_alternative_name03 = { package = "my_crate_name", version = "0.3" }
|
||||
# ```
|
||||
#
|
||||
# Dependencies which use the lib target name as extern name, do not need
|
||||
# to be specified in the crateRenames, even if their crate name differs.
|
||||
#
|
||||
# Including multiple versions of a crate is very popular during
|
||||
# ecosystem transitions, e.g. from futures 0.1 to futures 0.3.
|
||||
, crateRenames
|
||||
# A list of extra options to pass to rustc.
|
||||
#
|
||||
# Example: [ "-Z debuginfo=2" ]
|
||||
# Default: []
|
||||
, extraRustcOpts
|
||||
# A list of extra options to pass to rustc when building a build.rs.
|
||||
#
|
||||
# Example: [ "-Z debuginfo=2" ]
|
||||
# Default: []
|
||||
, extraRustcOptsForBuildRs
|
||||
# Whether to enable building tests.
|
||||
# Use true to enable.
|
||||
# Default: false
|
||||
, buildTests
|
||||
# Passed to stdenv.mkDerivation.
|
||||
, preUnpack
|
||||
# Passed to stdenv.mkDerivation.
|
||||
, postUnpack
|
||||
# Passed to stdenv.mkDerivation.
|
||||
, prePatch
|
||||
# Passed to stdenv.mkDerivation.
|
||||
, patches
|
||||
# Passed to stdenv.mkDerivation.
|
||||
, postPatch
|
||||
# Passed to stdenv.mkDerivation.
|
||||
, preConfigure
|
||||
# Passed to stdenv.mkDerivation.
|
||||
, postConfigure
|
||||
# Passed to stdenv.mkDerivation.
|
||||
, preBuild
|
||||
# Passed to stdenv.mkDerivation.
|
||||
, postBuild
|
||||
# Passed to stdenv.mkDerivation.
|
||||
, preInstall
|
||||
# Passed to stdenv.mkDerivation.
|
||||
, postInstall
|
||||
}:
|
||||
|
||||
let
|
||||
crate = crate_ // (lib.attrByPath [ crate_.crateName ] (attr: { }) crateOverrides crate_);
|
||||
dependencies_ = dependencies;
|
||||
buildDependencies_ = buildDependencies;
|
||||
processedAttrs = [
|
||||
"src"
|
||||
"nativeBuildInputs"
|
||||
"buildInputs"
|
||||
"crateBin"
|
||||
"crateLib"
|
||||
"libName"
|
||||
"libPath"
|
||||
"buildDependencies"
|
||||
"dependencies"
|
||||
"features"
|
||||
"crateRenames"
|
||||
"crateName"
|
||||
"version"
|
||||
"build"
|
||||
"authors"
|
||||
"colors"
|
||||
"edition"
|
||||
"buildTests"
|
||||
"codegenUnits"
|
||||
];
|
||||
extraDerivationAttrs = builtins.removeAttrs crate processedAttrs;
|
||||
nativeBuildInputs_ = nativeBuildInputs;
|
||||
buildInputs_ = buildInputs;
|
||||
extraRustcOpts_ = extraRustcOpts;
|
||||
extraRustcOptsForBuildRs_ = extraRustcOptsForBuildRs;
|
||||
buildTests_ = buildTests;
|
||||
|
||||
# crate2nix has a hack for the old bash based build script that did split
|
||||
# entries at `,`. No we have to work around that hack.
|
||||
# https://github.com/kolloch/crate2nix/blame/5b19c1b14e1b0e5522c3e44e300d0b332dc939e7/crate2nix/templates/build.nix.tera#L89
|
||||
crateBin = lib.filter (bin: !(bin ? name && bin.name == ",")) (crate.crateBin or [ ]);
|
||||
hasCrateBin = crate ? crateBin;
|
||||
in
|
||||
stdenv.mkDerivation (rec {
|
||||
|
||||
inherit (crate) crateName;
|
||||
inherit
|
||||
preUnpack
|
||||
postUnpack
|
||||
prePatch
|
||||
patches
|
||||
postPatch
|
||||
preConfigure
|
||||
postConfigure
|
||||
preBuild
|
||||
postBuild
|
||||
preInstall
|
||||
postInstall
|
||||
buildTests
|
||||
;
|
||||
|
||||
src = crate.src or (fetchCrate { inherit (crate) crateName version sha256; });
|
||||
name = "rust_${crate.crateName}-${crate.version}${lib.optionalString buildTests_ "-test"}";
|
||||
version = crate.version;
|
||||
depsBuildBuild = [ pkgsBuildBuild.stdenv.cc ];
|
||||
nativeBuildInputs = [ rust stdenv.cc cargo jq ] ++ (crate.nativeBuildInputs or [ ]) ++ nativeBuildInputs_;
|
||||
buildInputs = lib.optionals stdenv.isDarwin [ libiconv ] ++ (crate.buildInputs or [ ]) ++ buildInputs_;
|
||||
dependencies = map lib.getLib dependencies_;
|
||||
buildDependencies = map lib.getLib buildDependencies_;
|
||||
|
||||
completeDeps = lib.unique (dependencies ++ lib.concatMap (dep: dep.completeDeps) dependencies);
|
||||
completeBuildDeps = lib.unique (
|
||||
buildDependencies
|
||||
++ lib.concatMap (dep: dep.completeBuildDeps ++ dep.completeDeps) buildDependencies
|
||||
);
|
||||
|
||||
# Create a list of features that are enabled by the crate itself and
|
||||
# through the features argument of buildRustCrate. Exclude features
|
||||
# with a forward slash, since they are passed through to dependencies,
|
||||
# and dep: features, since they're internal-only and do nothing except
|
||||
# enable optional dependencies.
|
||||
crateFeatures = lib.optionals (crate ? features)
|
||||
(builtins.filter
|
||||
(f: !(lib.hasInfix "/" f || lib.hasPrefix "dep:" f))
|
||||
(crate.features ++ features)
|
||||
);
|
||||
|
||||
libName = if crate ? libName then crate.libName else crate.crateName;
|
||||
libPath = if crate ? libPath then crate.libPath else "";
|
||||
|
||||
# Seed the symbol hashes with something unique every time.
|
||||
# https://doc.rust-lang.org/1.0.0/rustc/metadata/loader/index.html#frobbing-symbols
|
||||
metadata =
|
||||
let
|
||||
depsMetadata = lib.foldl' (str: dep: str + dep.metadata) "" (dependencies ++ buildDependencies);
|
||||
hashedMetadata = builtins.hashString "sha256"
|
||||
(crateName + "-" + crateVersion + "___" + toString (mkRustcFeatureArgs crateFeatures) +
|
||||
"___" + depsMetadata + "___" + rustAttrs.toRustTarget stdenv.hostPlatform);
|
||||
in
|
||||
lib.substring 0 10 hashedMetadata;
|
||||
|
||||
build = crate.build or "";
|
||||
# Either set to a concrete sub path to the crate root
|
||||
# or use `null` for auto-detect.
|
||||
workspace_member = crate.workspace_member or ".";
|
||||
crateVersion = crate.version;
|
||||
crateDescription = crate.description or "";
|
||||
crateAuthors = if crate ? authors && lib.isList crate.authors then crate.authors else [ ];
|
||||
crateHomepage = crate.homepage or "";
|
||||
crateType =
|
||||
if lib.attrByPath [ "procMacro" ] false crate then [ "proc-macro" ] else
|
||||
if lib.attrByPath [ "plugin" ] false crate then [ "dylib" ] else
|
||||
(crate.type or [ "lib" ]);
|
||||
colors = lib.attrByPath [ "colors" ] "always" crate;
|
||||
extraLinkFlags = lib.concatStringsSep " " (crate.extraLinkFlags or [ ]);
|
||||
edition = crate.edition or null;
|
||||
codegenUnits = if crate ? codegenUnits then crate.codegenUnits else 1;
|
||||
extraRustcOpts =
|
||||
lib.optionals (crate ? extraRustcOpts) crate.extraRustcOpts
|
||||
++ extraRustcOpts_
|
||||
++ (lib.optional (edition != null) "--edition ${edition}");
|
||||
extraRustcOptsForBuildRs =
|
||||
lib.optionals (crate ? extraRustcOptsForBuildRs) crate.extraRustcOptsForBuildRs
|
||||
++ extraRustcOptsForBuildRs_
|
||||
++ (lib.optional (edition != null) "--edition ${edition}");
|
||||
|
||||
|
||||
configurePhase = configureCrate {
|
||||
inherit crateName buildDependencies completeDeps completeBuildDeps crateDescription
|
||||
crateFeatures crateRenames libName build workspace_member release libPath crateVersion
|
||||
extraLinkFlags extraRustcOptsForBuildRs
|
||||
crateAuthors crateHomepage verbose colors codegenUnits;
|
||||
};
|
||||
buildPhase = buildCrate {
|
||||
inherit crateName dependencies
|
||||
crateFeatures crateRenames libName release libPath crateType
|
||||
metadata hasCrateBin crateBin verbose colors
|
||||
extraRustcOpts buildTests codegenUnits;
|
||||
};
|
||||
installPhase = installCrate crateName metadata buildTests;
|
||||
|
||||
# depending on the test setting we are either producing something with bins
|
||||
# and libs or just test binaries
|
||||
outputs = if buildTests then [ "out" ] else [ "out" "lib" ];
|
||||
outputDev = if buildTests then [ "out" ] else [ "lib" ];
|
||||
|
||||
meta = {
|
||||
mainProgram = crateName;
|
||||
};
|
||||
} // extraDerivationAttrs
|
||||
)
|
||||
)
|
||||
{
|
||||
rust = rustc;
|
||||
release = crate_.release or true;
|
||||
verbose = crate_.verbose or true;
|
||||
extraRustcOpts = [ ];
|
||||
extraRustcOptsForBuildRs = [ ];
|
||||
features = [ ];
|
||||
nativeBuildInputs = [ ];
|
||||
buildInputs = [ ];
|
||||
crateOverrides = defaultCrateOverrides;
|
||||
preUnpack = crate_.preUnpack or "";
|
||||
postUnpack = crate_.postUnpack or "";
|
||||
prePatch = crate_.prePatch or "";
|
||||
patches = crate_.patches or [ ];
|
||||
postPatch = crate_.postPatch or "";
|
||||
preConfigure = crate_.preConfigure or "";
|
||||
postConfigure = crate_.postConfigure or "";
|
||||
preBuild = crate_.preBuild or "";
|
||||
postBuild = crate_.postBuild or "";
|
||||
preInstall = crate_.preInstall or "";
|
||||
postInstall = crate_.postInstall or "";
|
||||
dependencies = crate_.dependencies or [ ];
|
||||
buildDependencies = crate_.buildDependencies or [ ];
|
||||
crateRenames = crate_.crateRenames or { };
|
||||
buildTests = crate_.buildTests or false;
|
||||
}
|
||||
26
pkgs/build-support/rust/build-rust-crate/helpers.nix
Normal file
26
pkgs/build-support/rust/build-rust-crate/helpers.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{stdenv, lib}:
|
||||
{
|
||||
kernel = stdenv.hostPlatform.parsed.kernel.name;
|
||||
abi = stdenv.hostPlatform.parsed.abi.name;
|
||||
cpu = stdenv.hostPlatform.parsed.cpu.name;
|
||||
updateFeatures = f: up: functions: lib.deepSeq f (lib.foldl' (features: fun: fun features) (lib.attrsets.recursiveUpdate f up) functions);
|
||||
mapFeatures = features: map (fun: fun { features = features; });
|
||||
mkFeatures = feat: lib.foldl (features: featureName:
|
||||
if feat.${featureName} or false then
|
||||
[ featureName ] ++ features
|
||||
else
|
||||
features
|
||||
) [] (lib.attrNames feat);
|
||||
include = includedFiles: src: builtins.filterSource (path: type:
|
||||
lib.any (f:
|
||||
let p = toString (src + ("/" + f));
|
||||
in
|
||||
p == path || (lib.strings.hasPrefix (p + "/") path)
|
||||
) includedFiles
|
||||
) src;
|
||||
exclude = excludedFiles: src: builtins.filterSource (path: type:
|
||||
lib.all (f:
|
||||
!lib.strings.hasPrefix (toString (src + ("/" + f))) path
|
||||
) excludedFiles
|
||||
) src;
|
||||
}
|
||||
51
pkgs/build-support/rust/build-rust-crate/install-crate.nix
Normal file
51
pkgs/build-support/rust/build-rust-crate/install-crate.nix
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
{ stdenv }:
|
||||
crateName: metadata: buildTests:
|
||||
if !buildTests then ''
|
||||
runHook preInstall
|
||||
# always create $out even if we do not have binaries. We are detecting binary targets during compilation, if those are missing there is no way to only have $lib
|
||||
mkdir $out
|
||||
if [[ -s target/env ]]; then
|
||||
mkdir -p $lib
|
||||
cp target/env $lib/env
|
||||
fi
|
||||
if [[ -s target/link.final ]]; then
|
||||
mkdir -p $lib/lib
|
||||
cp target/link.final $lib/lib/link
|
||||
fi
|
||||
if [[ "$(ls -A target/lib)" ]]; then
|
||||
mkdir -p $lib/lib
|
||||
cp -r target/lib/* $lib/lib #*/
|
||||
for library in $lib/lib/*.so $lib/lib/*.dylib; do #*/
|
||||
ln -s $library $(echo $library | sed -e "s/-${metadata}//")
|
||||
done
|
||||
fi
|
||||
if [[ "$(ls -A target/build)" ]]; then # */
|
||||
mkdir -p $lib/lib
|
||||
cp -r target/build/* $lib/lib # */
|
||||
fi
|
||||
if [[ -d target/bin ]]; then
|
||||
if [[ "$(ls -A target/bin)" ]]; then
|
||||
mkdir -p $out/bin
|
||||
cp -rP target/bin/* $out/bin # */
|
||||
fi
|
||||
fi
|
||||
runHook postInstall
|
||||
'' else
|
||||
# for tests we just put them all in the output. No execution.
|
||||
''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/tests
|
||||
if [ -e target/bin ]; then
|
||||
find target/bin/ -type f -executable -exec cp {} $out/tests \;
|
||||
fi
|
||||
if [ -e target/lib ]; then
|
||||
find target/lib/ -type f \! -name '*.rlib' \
|
||||
-a \! -name '*${stdenv.hostPlatform.extensions.sharedLibrary}' \
|
||||
-a \! -name '*.d' \
|
||||
-executable \
|
||||
-print0 | xargs --no-run-if-empty --null install --target $out/tests;
|
||||
fi
|
||||
|
||||
runHook postInstall
|
||||
''
|
||||
174
pkgs/build-support/rust/build-rust-crate/lib.sh
Normal file
174
pkgs/build-support/rust/build-rust-crate/lib.sh
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
echo_build_heading() {
|
||||
if (( $# == 1 )); then
|
||||
echo_colored "Building $1"
|
||||
else
|
||||
echo_colored "Building $1 ($2)"
|
||||
fi
|
||||
}
|
||||
|
||||
build_lib() {
|
||||
lib_src=$1
|
||||
echo_build_heading $lib_src ${libName}
|
||||
|
||||
noisily rustc \
|
||||
--crate-name $CRATE_NAME \
|
||||
$lib_src \
|
||||
--out-dir target/lib \
|
||||
-L dependency=target/deps \
|
||||
--cap-lints allow \
|
||||
$LIB_RUSTC_OPTS \
|
||||
$BUILD_OUT_DIR \
|
||||
$EXTRA_BUILD \
|
||||
$EXTRA_FEATURES \
|
||||
$EXTRA_RUSTC_FLAGS \
|
||||
--color $colors
|
||||
|
||||
EXTRA_LIB=" --extern $CRATE_NAME=target/lib/lib$CRATE_NAME-$metadata.rlib"
|
||||
if [ -e target/deps/lib$CRATE_NAME-$metadata$LIB_EXT ]; then
|
||||
EXTRA_LIB="$EXTRA_LIB --extern $CRATE_NAME=target/lib/lib$CRATE_NAME-$metadata$LIB_EXT"
|
||||
fi
|
||||
}
|
||||
|
||||
build_bin() {
|
||||
local crate_name=$1
|
||||
local crate_name_=$(echo $crate_name | tr '-' '_')
|
||||
local main_file=""
|
||||
|
||||
if [[ ! -z $2 ]]; then
|
||||
main_file=$2
|
||||
fi
|
||||
echo_build_heading $@
|
||||
noisily rustc \
|
||||
--crate-name $crate_name_ \
|
||||
$main_file \
|
||||
--crate-type bin \
|
||||
$BIN_RUSTC_OPTS \
|
||||
--out-dir target/bin \
|
||||
-L dependency=target/deps \
|
||||
$LINK \
|
||||
$EXTRA_LIB \
|
||||
--cap-lints allow \
|
||||
$BUILD_OUT_DIR \
|
||||
$EXTRA_BUILD \
|
||||
$EXTRA_FEATURES \
|
||||
$EXTRA_RUSTC_FLAGS \
|
||||
--color ${colors} \
|
||||
|
||||
if [ "$crate_name_" != "$crate_name" ]; then
|
||||
mv target/bin/$crate_name_ target/bin/$crate_name
|
||||
fi
|
||||
}
|
||||
|
||||
build_lib_test() {
|
||||
local file="$1"
|
||||
EXTRA_RUSTC_FLAGS="--test $EXTRA_RUSTC_FLAGS" build_lib "$1" "$2"
|
||||
}
|
||||
|
||||
build_bin_test() {
|
||||
local crate="$1"
|
||||
local file="$2"
|
||||
EXTRA_RUSTC_FLAGS="--test $EXTRA_RUSTC_FLAGS" build_bin "$1" "$2"
|
||||
}
|
||||
|
||||
build_bin_test_file() {
|
||||
local file="$1"
|
||||
local derived_crate_name="${file//\//_}"
|
||||
derived_crate_name="${derived_crate_name%.rs}"
|
||||
build_bin_test "$derived_crate_name" "$file"
|
||||
}
|
||||
|
||||
# Add additional link options that were provided by the build script.
|
||||
setup_link_paths() {
|
||||
EXTRA_LIB=""
|
||||
if [[ -e target/link_ ]]; then
|
||||
EXTRA_BUILD="$(cat target/link_) $EXTRA_BUILD"
|
||||
fi
|
||||
|
||||
echo "$EXTRA_LINK_SEARCH" | while read i; do
|
||||
if [[ ! -z "$i" ]]; then
|
||||
for library in $i; do
|
||||
echo "-L $library" >> target/link
|
||||
L=$(echo $library | sed -e "s#$(pwd)/target/build#$lib/lib#")
|
||||
echo "-L $L" >> target/link.final
|
||||
done
|
||||
fi
|
||||
done
|
||||
echo "$EXTRA_LINK" | while read i; do
|
||||
if [[ ! -z "$i" ]]; then
|
||||
for library in $i; do
|
||||
echo "-l $library" >> target/link
|
||||
echo "-l $library" >> target/link.final
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -e target/link ]]; then
|
||||
tr '\n' ' ' < target/link > target/link_
|
||||
LINK=$(cat target/link_)
|
||||
fi
|
||||
}
|
||||
|
||||
search_for_bin_path() {
|
||||
# heuristic to "guess" the correct source file as found in cargo:
|
||||
# https://github.com/rust-lang/cargo/blob/90fc9f620190d5fa3c80b0c8c65a1e1361e6b8ae/src/cargo/util/toml/targets.rs#L308-L325
|
||||
|
||||
BIN_NAME=$1
|
||||
BIN_NAME_=$(echo $BIN_NAME | tr '-' '_')
|
||||
|
||||
# the first two cases are the "new" default IIRC
|
||||
FILES=( "src/bin/$BIN_NAME.rs" "src/bin/$BIN_NAME/main.rs" "src/bin/$BIN_NAME_.rs" "src/bin/$BIN_NAME_/main.rs" "src/bin/main.rs" "src/main.rs" )
|
||||
|
||||
if ! [ -e "$LIB_PATH" -o -e src/lib.rs -o -e "src/$LIB_NAME.rs" ]; then
|
||||
# if this is not a library the following path is also valid
|
||||
FILES=( "src/$BIN_NAME.rs" "src/$BIN_NAME_.rs" "${FILES[@]}" )
|
||||
fi
|
||||
|
||||
for file in "${FILES[@]}";
|
||||
do
|
||||
echo "checking file $file"
|
||||
# first file that exists wins
|
||||
if [[ -e "$file" ]]; then
|
||||
BIN_PATH="$file"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z "$BIN_PATH" ]]; then
|
||||
echo_error "ERROR: failed to find file for binary target: $BIN_NAME" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Extracts cargo_toml_path of the matching crate.
|
||||
matching_cargo_toml_path() {
|
||||
local manifest_path="$1"
|
||||
local expected_crate_name="$2"
|
||||
|
||||
# If the Cargo.toml is not a workspace root,
|
||||
# it will only contain one package in ".packages"
|
||||
# because "--no-deps" suppressed dependency resolution.
|
||||
#
|
||||
# But to make it more general, we search for a matching
|
||||
# crate in all packages and use the manifest path that
|
||||
# is referenced there.
|
||||
cargo metadata --no-deps --format-version 1 \
|
||||
--manifest-path "$manifest_path" \
|
||||
| jq -r '.packages[]
|
||||
| select( .name == "'$expected_crate_name'")
|
||||
| .manifest_path'
|
||||
}
|
||||
|
||||
# Find a Cargo.toml in the current or any sub directory
|
||||
# with a matching crate name.
|
||||
matching_cargo_toml_dir() {
|
||||
local expected_crate_name="$1"
|
||||
|
||||
find -L -name Cargo.toml | sort | while read manifest_path; do
|
||||
echo "...checking manifest_path $manifest_path" >&2
|
||||
local matching_path="$(matching_cargo_toml_path "$manifest_path" "$expected_crate_name")"
|
||||
if [ -n "${matching_path}" ]; then
|
||||
echo "$(dirname $matching_path)"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
59
pkgs/build-support/rust/build-rust-crate/log.nix
Normal file
59
pkgs/build-support/rust/build-rust-crate/log.nix
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
{ lib }:
|
||||
|
||||
let echo_colored_body = start_escape:
|
||||
# Body of a function that behaves like "echo" but
|
||||
# has the output colored by the given start_escape
|
||||
# sequence. E.g.
|
||||
#
|
||||
# * echo_x "Building ..."
|
||||
# * echo_x -n "Running "
|
||||
#
|
||||
# This is more complicated than apparent at first sight
|
||||
# because:
|
||||
# * The color markers and the text must be print
|
||||
# in the same echo statement. Otherise, other
|
||||
# intermingled text from concurrent builds will
|
||||
# be colored as well.
|
||||
# * We need to preserve the trailing newline of the
|
||||
# echo if and only if it is present. Bash likes
|
||||
# to strip those if we capture the output of echo
|
||||
# in a variable.
|
||||
# * Leading "-" will be interpreted by test as an
|
||||
# option for itself. Therefore, we prefix it with
|
||||
# an x in `[[ "x$1" =~ ^x- ]]`.
|
||||
''
|
||||
local echo_args="";
|
||||
while [[ "x$1" =~ ^x- ]]; do
|
||||
echo_args+=" $1"
|
||||
shift
|
||||
done
|
||||
|
||||
local start_escape="$(printf '${start_escape}')"
|
||||
local reset="$(printf '\033[0m')"
|
||||
echo $echo_args $start_escape"$@"$reset
|
||||
'';
|
||||
echo_conditional_colored_body = colors: start_escape:
|
||||
if colors == "always"
|
||||
then (echo_colored_body start_escape)
|
||||
else ''echo "$@"'';
|
||||
in {
|
||||
echo_colored = colors: ''
|
||||
echo_colored() {
|
||||
${echo_conditional_colored_body colors ''\033[0;1;32m''}
|
||||
}
|
||||
|
||||
echo_error() {
|
||||
${echo_conditional_colored_body colors ''\033[0;1;31m''}
|
||||
}
|
||||
'';
|
||||
|
||||
noisily = colors: verbose: ''
|
||||
noisily() {
|
||||
${lib.optionalString verbose ''
|
||||
echo_colored -n "Running "
|
||||
echo $@
|
||||
''}
|
||||
$@
|
||||
}
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
{ lib, buildPlatform, buildRustCrate, fetchgit }:
|
||||
let kernel = buildPlatform.parsed.kernel.name;
|
||||
abi = buildPlatform.parsed.abi.name;
|
||||
include = includedFiles: src: builtins.filterSource (path: type:
|
||||
lib.lists.any (f:
|
||||
let p = toString (src + ("/" + f)); in
|
||||
(path == p) || (type == "directory" && lib.strings.hasPrefix path p)
|
||||
) includedFiles
|
||||
) src;
|
||||
updateFeatures = f: up: functions: builtins.deepSeq f (lib.lists.foldl' (features: fun: fun features) (lib.attrsets.recursiveUpdate f up) functions);
|
||||
mapFeatures = features: map (fun: fun { features = features; });
|
||||
mkFeatures = feat: lib.lists.foldl (features: featureName:
|
||||
if feat.${featureName} or false then
|
||||
[ featureName ] ++ features
|
||||
else
|
||||
features
|
||||
) [] (builtins.attrNames feat);
|
||||
in
|
||||
rec {
|
||||
alloc_no_stdlib_1_3_0_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate {
|
||||
crateName = "alloc-no-stdlib";
|
||||
version = "1.3.0";
|
||||
authors = [ "Daniel Reiter Horn <danielrh@dropbox.com>" ];
|
||||
sha256 = "1jcp27pzmqdszgp80y484g4kwbjbg7x8a589drcwbxg0i8xwkir9";
|
||||
crateBin = [ { name = "example"; } ];
|
||||
inherit dependencies buildDependencies features;
|
||||
};
|
||||
brotli_2_5_0_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate {
|
||||
crateName = "brotli";
|
||||
version = "2.5.0";
|
||||
authors = [ "Daniel Reiter Horn <danielrh@dropbox.com>" "The Brotli Authors" ];
|
||||
sha256 = "1ynw4hkdwnp0kj30p86ls44ahv4s99258s019bqrq4mya8hlsb5b";
|
||||
crateBin = [ { name = "brotli"; } ];
|
||||
inherit dependencies buildDependencies features;
|
||||
};
|
||||
brotli_decompressor_1_3_1_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate {
|
||||
crateName = "brotli-decompressor";
|
||||
version = "1.3.1";
|
||||
authors = [ "Daniel Reiter Horn <danielrh@dropbox.com>" "The Brotli Authors" ];
|
||||
sha256 = "022g69q1xzwdj0130qm3fa4qwpn4q1jx3lc8yz0v0v201p7bm8fb";
|
||||
crateBin = [ { name = "brotli-decompressor"; } ];
|
||||
inherit dependencies buildDependencies features;
|
||||
};
|
||||
alloc_no_stdlib_1_3_0 = { features?(alloc_no_stdlib_1_3_0_features {}) }: alloc_no_stdlib_1_3_0_ {
|
||||
features = mkFeatures (features.alloc_no_stdlib_1_3_0 or {});
|
||||
};
|
||||
alloc_no_stdlib_1_3_0_features = f: updateFeatures f ({
|
||||
alloc_no_stdlib_1_3_0.default = (f.alloc_no_stdlib_1_3_0.default or true);
|
||||
}) [];
|
||||
brotli_2_5_0 = { features?(brotli_2_5_0_features {}) }: brotli_2_5_0_ {
|
||||
dependencies = mapFeatures features ([ alloc_no_stdlib_1_3_0 brotli_decompressor_1_3_1 ]);
|
||||
features = mkFeatures (features.brotli_2_5_0 or {});
|
||||
};
|
||||
brotli_2_5_0_features = f: updateFeatures f (rec {
|
||||
alloc_no_stdlib_1_3_0.no-stdlib =
|
||||
(f.alloc_no_stdlib_1_3_0.no-stdlib or false) ||
|
||||
(brotli_2_5_0.no-stdlib or false) ||
|
||||
(f.brotli_2_5_0.no-stdlib or false);
|
||||
alloc_no_stdlib_1_3_0.default = true;
|
||||
brotli_2_5_0.default = (f.brotli_2_5_0.default or true);
|
||||
brotli_decompressor_1_3_1.disable-timer =
|
||||
(f.brotli_decompressor_1_3_1.disable-timer or false) ||
|
||||
(brotli_2_5_0.disable-timer or false) ||
|
||||
(f.brotli_2_5_0.disable-timer or false);
|
||||
brotli_decompressor_1_3_1.no-stdlib =
|
||||
(f.brotli_decompressor_1_3_1.no-stdlib or false) ||
|
||||
(brotli_2_5_0.no-stdlib or false) ||
|
||||
(f.brotli_2_5_0.no-stdlib or false);
|
||||
brotli_decompressor_1_3_1.benchmark =
|
||||
(f.brotli_decompressor_1_3_1.benchmark or false) ||
|
||||
(brotli_2_5_0.benchmark or false) ||
|
||||
(f.brotli_2_5_0.benchmark or false);
|
||||
brotli_decompressor_1_3_1.default = true;
|
||||
brotli_decompressor_1_3_1.seccomp =
|
||||
(f.brotli_decompressor_1_3_1.seccomp or false) ||
|
||||
(brotli_2_5_0.seccomp or false) ||
|
||||
(f.brotli_2_5_0.seccomp or false);
|
||||
}) [ alloc_no_stdlib_1_3_0_features brotli_decompressor_1_3_1_features ];
|
||||
brotli_decompressor_1_3_1 = { features?(brotli_decompressor_1_3_1_features {}) }: brotli_decompressor_1_3_1_ {
|
||||
dependencies = mapFeatures features ([ alloc_no_stdlib_1_3_0 ]);
|
||||
features = mkFeatures (features.brotli_decompressor_1_3_1 or {});
|
||||
};
|
||||
brotli_decompressor_1_3_1_features = f: updateFeatures f (rec {
|
||||
alloc_no_stdlib_1_3_0.no-stdlib =
|
||||
(f.alloc_no_stdlib_1_3_0.no-stdlib or false) ||
|
||||
(brotli_decompressor_1_3_1.no-stdlib or false) ||
|
||||
(f.brotli_decompressor_1_3_1.no-stdlib or false);
|
||||
alloc_no_stdlib_1_3_0.default = true;
|
||||
alloc_no_stdlib_1_3_0.unsafe =
|
||||
(f.alloc_no_stdlib_1_3_0.unsafe or false) ||
|
||||
(brotli_decompressor_1_3_1.unsafe or false) ||
|
||||
(f.brotli_decompressor_1_3_1.unsafe or false);
|
||||
brotli_decompressor_1_3_1.default = (f.brotli_decompressor_1_3_1.default or true);
|
||||
}) [ alloc_no_stdlib_1_3_0_features ];
|
||||
}
|
||||
657
pkgs/build-support/rust/build-rust-crate/test/default.nix
Normal file
657
pkgs/build-support/rust/build-rust-crate/test/default.nix
Normal file
|
|
@ -0,0 +1,657 @@
|
|||
{ lib
|
||||
, buildPackages
|
||||
, buildRustCrate
|
||||
, callPackage
|
||||
, releaseTools
|
||||
, runCommand
|
||||
, runCommandCC
|
||||
, stdenv
|
||||
, symlinkJoin
|
||||
, writeTextFile
|
||||
}:
|
||||
|
||||
let
|
||||
mkCrate = buildRustCrate: args: let
|
||||
p = {
|
||||
crateName = "nixtestcrate";
|
||||
version = "0.1.0";
|
||||
authors = [ "Test <test@example.com>" ];
|
||||
} // args;
|
||||
in buildRustCrate p;
|
||||
mkHostCrate = mkCrate buildRustCrate;
|
||||
|
||||
mkCargoToml =
|
||||
{ name, crateVersion ? "0.1.0", path ? "Cargo.toml" }:
|
||||
mkFile path ''
|
||||
[package]
|
||||
name = ${builtins.toJSON name}
|
||||
version = ${builtins.toJSON crateVersion}
|
||||
'';
|
||||
|
||||
mkFile = destination: text: writeTextFile {
|
||||
name = "src";
|
||||
destination = "/${destination}";
|
||||
inherit text;
|
||||
};
|
||||
|
||||
mkBin = name: mkFile name ''
|
||||
use std::env;
|
||||
fn main() {
|
||||
let name: String = env::args().nth(0).unwrap();
|
||||
println!("executed {}", name);
|
||||
}
|
||||
'';
|
||||
|
||||
mkBinExtern = name: extern: mkFile name ''
|
||||
extern crate ${extern};
|
||||
fn main() {
|
||||
assert_eq!(${extern}::test(), 23);
|
||||
}
|
||||
'';
|
||||
|
||||
mkTestFile = name: functionName: mkFile name ''
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn ${functionName}() {
|
||||
assert!(true);
|
||||
}
|
||||
'';
|
||||
mkTestFileWithMain = name: functionName: mkFile name ''
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn ${functionName}() {
|
||||
assert!(true);
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
'';
|
||||
|
||||
|
||||
mkLib = name: mkFile name "pub fn test() -> i32 { return 23; }";
|
||||
|
||||
mkTest = crateArgs: let
|
||||
crate = mkHostCrate (builtins.removeAttrs crateArgs ["expectedTestOutput"]);
|
||||
hasTests = crateArgs.buildTests or false;
|
||||
expectedTestOutputs = crateArgs.expectedTestOutputs or null;
|
||||
binaries = map (v: lib.escapeShellArg v.name) (crateArgs.crateBin or []);
|
||||
isLib = crateArgs ? libName || crateArgs ? libPath;
|
||||
crateName = crateArgs.crateName or "nixtestcrate";
|
||||
libName = crateArgs.libName or crateName;
|
||||
|
||||
libTestBinary = if !isLib then null else mkHostCrate {
|
||||
crateName = "run-test-${crateName}";
|
||||
dependencies = [ crate ];
|
||||
src = mkBinExtern "src/main.rs" libName;
|
||||
};
|
||||
|
||||
in
|
||||
assert expectedTestOutputs != null -> hasTests;
|
||||
assert hasTests -> expectedTestOutputs != null;
|
||||
|
||||
runCommand "run-buildRustCrate-${crateName}-test" {
|
||||
nativeBuildInputs = [ crate ];
|
||||
} (if !hasTests then ''
|
||||
${lib.concatMapStringsSep "\n" (binary:
|
||||
# Can't actually run the binary when cross-compiling
|
||||
(lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "type ") + binary
|
||||
) binaries}
|
||||
${lib.optionalString isLib ''
|
||||
test -e ${crate}/lib/*.rlib || exit 1
|
||||
${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "test -x "} \
|
||||
${libTestBinary}/bin/run-test-${crateName}
|
||||
''}
|
||||
touch $out
|
||||
'' else if stdenv.hostPlatform == stdenv.buildPlatform then ''
|
||||
for file in ${crate}/tests/*; do
|
||||
$file 2>&1 >> $out
|
||||
done
|
||||
set -e
|
||||
${lib.concatMapStringsSep "\n" (o: "grep '${o}' $out || { echo 'output \"${o}\" not found in:'; cat $out; exit 23; }") expectedTestOutputs}
|
||||
'' else ''
|
||||
for file in ${crate}/tests/*; do
|
||||
test -x "$file"
|
||||
done
|
||||
touch "$out"
|
||||
''
|
||||
);
|
||||
|
||||
/* Returns a derivation that asserts that the crate specified by `crateArgs`
|
||||
has the specified files as output.
|
||||
|
||||
`name` is used as part of the derivation name that performs the checking.
|
||||
|
||||
`crateArgs` is passed to `mkHostCrate` to build the crate with `buildRustCrate`.
|
||||
|
||||
`expectedFiles` contains a list of expected file paths in the output. E.g.
|
||||
`[ "./bin/my_binary" ]`.
|
||||
|
||||
`output` specifies the name of the output to use. By default, the default
|
||||
output is used but e.g. `output = "lib";` will cause the lib output
|
||||
to be checked instead. You do not need to specify any directories.
|
||||
*/
|
||||
assertOutputs = { name, crateArgs, expectedFiles, output? null }:
|
||||
assert (builtins.isString name);
|
||||
assert (builtins.isAttrs crateArgs);
|
||||
assert (builtins.isList expectedFiles);
|
||||
|
||||
let
|
||||
crate = mkHostCrate (builtins.removeAttrs crateArgs ["expectedTestOutput"]);
|
||||
crateOutput = if output == null then crate else crate."${output}";
|
||||
expectedFilesFile = writeTextFile {
|
||||
name = "expected-files-${name}";
|
||||
text =
|
||||
let sorted = builtins.sort (a: b: a<b) expectedFiles;
|
||||
concatenated = builtins.concatStringsSep "\n" sorted;
|
||||
in "${concatenated}\n";
|
||||
};
|
||||
in
|
||||
runCommand "assert-outputs-${name}" {
|
||||
} (''
|
||||
local actualFiles=$(mktemp)
|
||||
|
||||
cd "${crateOutput}"
|
||||
find . -type f \
|
||||
| sort \
|
||||
''
|
||||
# sed out the hash because it differs per platform
|
||||
+ ''
|
||||
| sed -E -e 's/-[0-9a-fA-F]{10}\.rlib/-HASH.rlib/g' \
|
||||
> "$actualFiles"
|
||||
diff -q ${expectedFilesFile} "$actualFiles" > /dev/null || {
|
||||
echo -e "\033[0;1;31mERROR: Difference in expected output files in ${crateOutput} \033[0m" >&2
|
||||
echo === Got:
|
||||
sed -e 's/^/ /' $actualFiles
|
||||
echo === Expected:
|
||||
sed -e 's/^/ /' ${expectedFilesFile}
|
||||
echo === Diff:
|
||||
diff -u ${expectedFilesFile} $actualFiles |\
|
||||
tail -n +3 |\
|
||||
sed -e 's/^/ /'
|
||||
exit 1
|
||||
}
|
||||
touch $out
|
||||
'')
|
||||
;
|
||||
|
||||
in rec {
|
||||
|
||||
tests = let
|
||||
cases = rec {
|
||||
libPath = { libPath = "src/my_lib.rs"; src = mkLib "src/my_lib.rs"; };
|
||||
srcLib = { src = mkLib "src/lib.rs"; };
|
||||
|
||||
# This used to be supported by cargo but as of 1.40.0 I can't make it work like that with just cargo anymore.
|
||||
# This might be a regression or deprecated thing they finally removed…
|
||||
# customLibName = { libName = "test_lib"; src = mkLib "src/test_lib.rs"; };
|
||||
# rustLibTestsCustomLibName = {
|
||||
# libName = "test_lib";
|
||||
# src = mkTestFile "src/test_lib.rs" "foo";
|
||||
# buildTests = true;
|
||||
# expectedTestOutputs = [ "test foo ... ok" ];
|
||||
# };
|
||||
|
||||
customLibNameAndLibPath = { libName = "test_lib"; libPath = "src/best-lib.rs"; src = mkLib "src/best-lib.rs"; };
|
||||
crateBinWithPath = { crateBin = [{ name = "test_binary1"; path = "src/foobar.rs"; }]; src = mkBin "src/foobar.rs"; };
|
||||
crateBinNoPath1 = { crateBin = [{ name = "my-binary2"; }]; src = mkBin "src/my_binary2.rs"; };
|
||||
crateBinNoPath2 = {
|
||||
crateBin = [{ name = "my-binary3"; } { name = "my-binary4"; }];
|
||||
src = symlinkJoin {
|
||||
name = "buildRustCrateMultipleBinariesCase";
|
||||
paths = [ (mkBin "src/bin/my_binary3.rs") (mkBin "src/bin/my_binary4.rs") ];
|
||||
};
|
||||
};
|
||||
crateBinNoPath3 = { crateBin = [{ name = "my-binary5"; }]; src = mkBin "src/bin/main.rs"; };
|
||||
crateBinNoPath4 = { crateBin = [{ name = "my-binary6"; }]; src = mkBin "src/main.rs";};
|
||||
crateBinRename1 = {
|
||||
crateBin = [{ name = "my-binary-rename1"; }];
|
||||
src = mkBinExtern "src/main.rs" "foo_renamed";
|
||||
dependencies = [ (mkHostCrate { crateName = "foo"; src = mkLib "src/lib.rs"; }) ];
|
||||
crateRenames = { "foo" = "foo_renamed"; };
|
||||
};
|
||||
crateBinRename2 = {
|
||||
crateBin = [{ name = "my-binary-rename2"; }];
|
||||
src = mkBinExtern "src/main.rs" "foo_renamed";
|
||||
dependencies = [ (mkHostCrate { crateName = "foo"; libName = "foolib"; src = mkLib "src/lib.rs"; }) ];
|
||||
crateRenames = { "foo" = "foo_renamed"; };
|
||||
};
|
||||
crateBinRenameMultiVersion = let
|
||||
crateWithVersion = version: mkHostCrate {
|
||||
crateName = "my_lib";
|
||||
inherit version;
|
||||
src = mkFile "src/lib.rs" ''
|
||||
pub const version: &str = "${version}";
|
||||
'';
|
||||
};
|
||||
depCrate01 = crateWithVersion "0.1.2";
|
||||
depCrate02 = crateWithVersion "0.2.1";
|
||||
in {
|
||||
crateName = "my_bin";
|
||||
src = symlinkJoin {
|
||||
name = "my_bin_src";
|
||||
paths = [
|
||||
(mkFile "src/main.rs" ''
|
||||
#[test]
|
||||
fn my_lib_01() { assert_eq!(lib01::version, "0.1.2"); }
|
||||
|
||||
#[test]
|
||||
fn my_lib_02() { assert_eq!(lib02::version, "0.2.1"); }
|
||||
|
||||
fn main() { }
|
||||
'')
|
||||
];
|
||||
};
|
||||
dependencies = [ depCrate01 depCrate02 ];
|
||||
crateRenames = {
|
||||
"my_lib" = [
|
||||
{
|
||||
version = "0.1.2";
|
||||
rename = "lib01";
|
||||
}
|
||||
{
|
||||
version = "0.2.1";
|
||||
rename = "lib02";
|
||||
}
|
||||
];
|
||||
};
|
||||
buildTests = true;
|
||||
expectedTestOutputs = [
|
||||
"test my_lib_01 ... ok"
|
||||
"test my_lib_02 ... ok"
|
||||
];
|
||||
};
|
||||
rustLibTestsDefault = {
|
||||
src = mkTestFile "src/lib.rs" "baz";
|
||||
buildTests = true;
|
||||
expectedTestOutputs = [ "test baz ... ok" ];
|
||||
};
|
||||
rustLibTestsCustomLibPath = {
|
||||
libPath = "src/test_path.rs";
|
||||
src = mkTestFile "src/test_path.rs" "bar";
|
||||
buildTests = true;
|
||||
expectedTestOutputs = [ "test bar ... ok" ];
|
||||
};
|
||||
rustLibTestsCustomLibPathWithTests = {
|
||||
libPath = "src/test_path.rs";
|
||||
src = symlinkJoin {
|
||||
name = "rust-lib-tests-custom-lib-path-with-tests-dir";
|
||||
paths = [
|
||||
(mkTestFile "src/test_path.rs" "bar")
|
||||
(mkTestFile "tests/something.rs" "something")
|
||||
];
|
||||
};
|
||||
buildTests = true;
|
||||
expectedTestOutputs = [
|
||||
"test bar ... ok"
|
||||
"test something ... ok"
|
||||
];
|
||||
};
|
||||
rustBinTestsCombined = {
|
||||
src = symlinkJoin {
|
||||
name = "rust-bin-tests-combined";
|
||||
paths = [
|
||||
(mkTestFileWithMain "src/main.rs" "src_main")
|
||||
(mkTestFile "tests/foo.rs" "tests_foo")
|
||||
(mkTestFile "tests/bar.rs" "tests_bar")
|
||||
];
|
||||
};
|
||||
buildTests = true;
|
||||
expectedTestOutputs = [
|
||||
"test src_main ... ok"
|
||||
"test tests_foo ... ok"
|
||||
"test tests_bar ... ok"
|
||||
];
|
||||
};
|
||||
rustBinTestsSubdirCombined = {
|
||||
src = symlinkJoin {
|
||||
name = "rust-bin-tests-subdir-combined";
|
||||
paths = [
|
||||
(mkTestFileWithMain "src/main.rs" "src_main")
|
||||
(mkTestFile "tests/foo/main.rs" "tests_foo")
|
||||
(mkTestFile "tests/bar/main.rs" "tests_bar")
|
||||
];
|
||||
};
|
||||
buildTests = true;
|
||||
expectedTestOutputs = [
|
||||
"test src_main ... ok"
|
||||
"test tests_foo ... ok"
|
||||
"test tests_bar ... ok"
|
||||
];
|
||||
};
|
||||
linkAgainstRlibCrate = {
|
||||
crateName = "foo";
|
||||
src = mkFile "src/main.rs" ''
|
||||
extern crate somerlib;
|
||||
fn main() {}
|
||||
'';
|
||||
dependencies = [
|
||||
(mkHostCrate {
|
||||
crateName = "somerlib";
|
||||
type = [ "rlib" ];
|
||||
src = mkLib "src/lib.rs";
|
||||
})
|
||||
];
|
||||
};
|
||||
buildScriptDeps = let
|
||||
depCrate = buildRustCrate: boolVal: mkCrate buildRustCrate {
|
||||
crateName = "bar";
|
||||
src = mkFile "src/lib.rs" ''
|
||||
pub const baz: bool = ${boolVal};
|
||||
'';
|
||||
};
|
||||
in {
|
||||
crateName = "foo";
|
||||
src = symlinkJoin {
|
||||
name = "build-script-and-main";
|
||||
paths = [
|
||||
(mkFile "src/main.rs" ''
|
||||
extern crate bar;
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn baz_false() { assert!(!bar::baz); }
|
||||
fn main() { }
|
||||
'')
|
||||
(mkFile "build.rs" ''
|
||||
extern crate bar;
|
||||
fn main() { assert!(bar::baz); }
|
||||
'')
|
||||
];
|
||||
};
|
||||
buildDependencies = [ (depCrate buildPackages.buildRustCrate "true") ];
|
||||
dependencies = [ (depCrate buildRustCrate "false") ];
|
||||
buildTests = true;
|
||||
expectedTestOutputs = [ "test baz_false ... ok" ];
|
||||
};
|
||||
buildScriptFeatureEnv = {
|
||||
crateName = "build-script-feature-env";
|
||||
features = [ "some-feature" "crate/another_feature" ];
|
||||
src = symlinkJoin {
|
||||
name = "build-script-feature-env";
|
||||
paths = [
|
||||
(mkFile "src/main.rs" ''
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn feature_not_visible() {
|
||||
assert!(std::env::var("CARGO_FEATURE_SOME_FEATURE").is_err());
|
||||
assert!(option_env!("CARGO_FEATURE_SOME_FEATURE").is_none());
|
||||
}
|
||||
fn main() {}
|
||||
'')
|
||||
(mkFile "build.rs" ''
|
||||
fn main() {
|
||||
assert!(std::env::var("CARGO_FEATURE_SOME_FEATURE").is_ok());
|
||||
assert!(option_env!("CARGO_FEATURE_SOME_FEATURE").is_none());
|
||||
}
|
||||
'')
|
||||
];
|
||||
};
|
||||
buildTests = true;
|
||||
expectedTestOutputs = [ "test feature_not_visible ... ok" ];
|
||||
};
|
||||
# Regression test for https://github.com/NixOS/nixpkgs/pull/88054
|
||||
# Build script output should be rewritten as valid env vars.
|
||||
buildScriptIncludeDirDeps = let
|
||||
depCrate = mkHostCrate {
|
||||
crateName = "bar";
|
||||
src = symlinkJoin {
|
||||
name = "build-script-and-include-dir-bar";
|
||||
paths = [
|
||||
(mkFile "src/lib.rs" ''
|
||||
fn main() { }
|
||||
'')
|
||||
(mkFile "build.rs" ''
|
||||
use std::path::PathBuf;
|
||||
fn main() { println!("cargo:include-dir={}/src", std::env::current_dir().unwrap_or(PathBuf::from(".")).to_str().unwrap()); }
|
||||
'')
|
||||
];
|
||||
};
|
||||
};
|
||||
in {
|
||||
crateName = "foo";
|
||||
src = symlinkJoin {
|
||||
name = "build-script-and-include-dir-foo";
|
||||
paths = [
|
||||
(mkFile "src/main.rs" ''
|
||||
fn main() { }
|
||||
'')
|
||||
(mkFile "build.rs" ''
|
||||
fn main() { assert!(std::env::var_os("DEP_BAR_INCLUDE_DIR").is_some()); }
|
||||
'')
|
||||
];
|
||||
};
|
||||
buildDependencies = [ depCrate ];
|
||||
dependencies = [ depCrate ];
|
||||
};
|
||||
# Regression test for https://github.com/NixOS/nixpkgs/issues/74071
|
||||
# Whenevever a build.rs file is generating files those should not be overlayed onto the actual source dir
|
||||
buildRsOutDirOverlay = {
|
||||
src = symlinkJoin {
|
||||
name = "buildrs-out-dir-overlay";
|
||||
paths = [
|
||||
(mkLib "src/lib.rs")
|
||||
(mkFile "build.rs" ''
|
||||
use std::env;
|
||||
use std::ffi::OsString;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
fn main() {
|
||||
let out_dir = env::var_os("OUT_DIR").expect("OUT_DIR not set");
|
||||
let out_file = Path::new(&out_dir).join("lib.rs");
|
||||
fs::write(out_file, "invalid rust code!").expect("failed to write lib.rs");
|
||||
}
|
||||
'')
|
||||
];
|
||||
};
|
||||
};
|
||||
# Regression test for https://github.com/NixOS/nixpkgs/pull/83379
|
||||
# link flag order should be preserved
|
||||
linkOrder = {
|
||||
src = symlinkJoin {
|
||||
name = "buildrs-out-dir-overlay";
|
||||
paths = [
|
||||
(mkFile "build.rs" ''
|
||||
fn main() {
|
||||
// in the other order, linkage will fail
|
||||
println!("cargo:rustc-link-lib=b");
|
||||
println!("cargo:rustc-link-lib=a");
|
||||
}
|
||||
'')
|
||||
(mkFile "src/main.rs" ''
|
||||
extern "C" {
|
||||
fn hello_world();
|
||||
}
|
||||
fn main() {
|
||||
unsafe {
|
||||
hello_world();
|
||||
}
|
||||
}
|
||||
'')
|
||||
];
|
||||
};
|
||||
buildInputs = let
|
||||
compile = name: text: let
|
||||
src = writeTextFile {
|
||||
name = "${name}-src.c";
|
||||
inherit text;
|
||||
};
|
||||
in runCommandCC name {} ''
|
||||
mkdir -p $out/lib
|
||||
# Note: On darwin (which defaults to clang) we have to add
|
||||
# `-undefined dynamic_lookup` as otherwise the compilation fails.
|
||||
$CC -shared \
|
||||
${lib.optionalString stdenv.isDarwin "-undefined dynamic_lookup"} \
|
||||
-o $out/lib/${name}${stdenv.hostPlatform.extensions.sharedLibrary} ${src}
|
||||
'';
|
||||
b = compile "libb" ''
|
||||
#include <stdio.h>
|
||||
|
||||
void hello();
|
||||
|
||||
void hello_world() {
|
||||
hello();
|
||||
printf(" world!\n");
|
||||
}
|
||||
'';
|
||||
a = compile "liba" ''
|
||||
#include <stdio.h>
|
||||
|
||||
void hello() {
|
||||
printf("hello");
|
||||
}
|
||||
'';
|
||||
in [ a b ];
|
||||
};
|
||||
rustCargoTomlInSubDir = {
|
||||
# The "workspace_member" can be set to the sub directory with the crate to build.
|
||||
# By default ".", meaning the top level directory is assumed.
|
||||
# Using null will trigger a search.
|
||||
workspace_member = null;
|
||||
src = symlinkJoin rec {
|
||||
name = "find-cargo-toml";
|
||||
paths = [
|
||||
(mkCargoToml { name = "ignoreMe"; })
|
||||
(mkTestFileWithMain "src/main.rs" "ignore_main")
|
||||
|
||||
(mkCargoToml { name = "rustCargoTomlInSubDir"; path = "subdir/Cargo.toml"; })
|
||||
(mkTestFileWithMain "subdir/src/main.rs" "src_main")
|
||||
(mkTestFile "subdir/tests/foo/main.rs" "tests_foo")
|
||||
(mkTestFile "subdir/tests/bar/main.rs" "tests_bar")
|
||||
];
|
||||
};
|
||||
buildTests = true;
|
||||
expectedTestOutputs = [
|
||||
"test src_main ... ok"
|
||||
"test tests_foo ... ok"
|
||||
"test tests_bar ... ok"
|
||||
];
|
||||
};
|
||||
|
||||
rustCargoTomlInTopDir =
|
||||
let
|
||||
withoutCargoTomlSearch = builtins.removeAttrs rustCargoTomlInSubDir [ "workspace_member" ];
|
||||
in
|
||||
withoutCargoTomlSearch // {
|
||||
expectedTestOutputs = [
|
||||
"test ignore_main ... ok"
|
||||
];
|
||||
};
|
||||
procMacroInPrelude = {
|
||||
procMacro = true;
|
||||
edition = "2018";
|
||||
src = symlinkJoin {
|
||||
name = "proc-macro-in-prelude";
|
||||
paths = [
|
||||
(mkFile "src/lib.rs" ''
|
||||
use proc_macro::TokenTree;
|
||||
'')
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
brotliCrates = (callPackage ./brotli-crates.nix {});
|
||||
tests = lib.mapAttrs (key: value: mkTest (value // lib.optionalAttrs (!value?crateName) { crateName = key; })) cases;
|
||||
in tests // rec {
|
||||
|
||||
crateBinWithPathOutputs = assertOutputs {
|
||||
name="crateBinWithPath";
|
||||
crateArgs = {
|
||||
crateBin = [{ name = "test_binary1"; path = "src/foobar.rs"; }];
|
||||
src = mkBin "src/foobar.rs";
|
||||
};
|
||||
expectedFiles = [
|
||||
"./bin/test_binary1"
|
||||
];
|
||||
};
|
||||
|
||||
crateBinWithPathOutputsDebug = assertOutputs {
|
||||
name="crateBinWithPath";
|
||||
crateArgs = {
|
||||
release = false;
|
||||
crateBin = [{ name = "test_binary1"; path = "src/foobar.rs"; }];
|
||||
src = mkBin "src/foobar.rs";
|
||||
};
|
||||
expectedFiles = [
|
||||
"./bin/test_binary1"
|
||||
] ++ lib.optionals stdenv.isDarwin [
|
||||
# On Darwin, the debug symbols are in a seperate directory.
|
||||
"./bin/test_binary1.dSYM/Contents/Info.plist"
|
||||
"./bin/test_binary1.dSYM/Contents/Resources/DWARF/test_binary1"
|
||||
];
|
||||
};
|
||||
|
||||
crateBinNoPath1Outputs = assertOutputs {
|
||||
name="crateBinNoPath1";
|
||||
crateArgs = {
|
||||
crateBin = [{ name = "my-binary2"; }];
|
||||
src = mkBin "src/my_binary2.rs";
|
||||
};
|
||||
expectedFiles = [
|
||||
"./bin/my-binary2"
|
||||
];
|
||||
};
|
||||
|
||||
crateLibOutputs = assertOutputs {
|
||||
name="crateLib";
|
||||
output="lib";
|
||||
crateArgs = {
|
||||
libName = "test_lib";
|
||||
type = [ "rlib" ];
|
||||
libPath = "src/lib.rs";
|
||||
src = mkLib "src/lib.rs";
|
||||
};
|
||||
expectedFiles = [
|
||||
"./nix-support/propagated-build-inputs"
|
||||
"./lib/libtest_lib-HASH.rlib"
|
||||
"./lib/link"
|
||||
];
|
||||
};
|
||||
|
||||
crateLibOutputsDebug = assertOutputs {
|
||||
name="crateLib";
|
||||
output="lib";
|
||||
crateArgs = {
|
||||
release = false;
|
||||
libName = "test_lib";
|
||||
type = [ "rlib" ];
|
||||
libPath = "src/lib.rs";
|
||||
src = mkLib "src/lib.rs";
|
||||
};
|
||||
expectedFiles = [
|
||||
"./nix-support/propagated-build-inputs"
|
||||
"./lib/libtest_lib-HASH.rlib"
|
||||
"./lib/link"
|
||||
];
|
||||
};
|
||||
|
||||
brotliTest = let
|
||||
pkg = brotliCrates.brotli_2_5_0 {};
|
||||
in runCommand "run-brotli-test-cmd" {
|
||||
nativeBuildInputs = [ pkg ];
|
||||
} (if stdenv.hostPlatform == stdenv.buildPlatform then ''
|
||||
${pkg}/bin/brotli -c ${pkg}/bin/brotli > /dev/null && touch $out
|
||||
'' else ''
|
||||
test -x '${pkg}/bin/brotli' && touch $out
|
||||
'');
|
||||
allocNoStdLibTest = let
|
||||
pkg = brotliCrates.alloc_no_stdlib_1_3_0 {};
|
||||
in runCommand "run-alloc-no-stdlib-test-cmd" {
|
||||
nativeBuildInputs = [ pkg ];
|
||||
} ''
|
||||
test -e ${pkg}/bin/example && touch $out
|
||||
'';
|
||||
brotliDecompressorTest = let
|
||||
pkg = brotliCrates.brotli_decompressor_1_3_1 {};
|
||||
in runCommand "run-brotli-decompressor-test-cmd" {
|
||||
nativeBuildInputs = [ pkg ];
|
||||
} ''
|
||||
test -e ${pkg}/bin/brotli-decompressor && touch $out
|
||||
'';
|
||||
};
|
||||
test = releaseTools.aggregate {
|
||||
name = "buildRustCrate-tests";
|
||||
meta = {
|
||||
description = "Test cases for buildRustCrate";
|
||||
maintainers = [ ];
|
||||
};
|
||||
constituents = builtins.attrValues tests;
|
||||
};
|
||||
}
|
||||
159
pkgs/build-support/rust/build-rust-package/default.nix
Normal file
159
pkgs/build-support/rust/build-rust-package/default.nix
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
{ lib
|
||||
, importCargoLock
|
||||
, fetchCargoTarball
|
||||
, rust
|
||||
, stdenv
|
||||
, callPackage
|
||||
, cacert
|
||||
, git
|
||||
, cargoBuildHook
|
||||
, cargoCheckHook
|
||||
, cargoInstallHook
|
||||
, cargoSetupHook
|
||||
, rustc
|
||||
, libiconv
|
||||
, windows
|
||||
}:
|
||||
|
||||
{ name ? "${args.pname}-${args.version}"
|
||||
|
||||
# Name for the vendored dependencies tarball
|
||||
, cargoDepsName ? name
|
||||
|
||||
, src ? null
|
||||
, srcs ? null
|
||||
, unpackPhase ? null
|
||||
, cargoPatches ? []
|
||||
, patches ? []
|
||||
, sourceRoot ? null
|
||||
, logLevel ? ""
|
||||
, buildInputs ? []
|
||||
, nativeBuildInputs ? []
|
||||
, cargoUpdateHook ? ""
|
||||
, cargoDepsHook ? ""
|
||||
, buildType ? "release"
|
||||
, meta ? {}
|
||||
, cargoLock ? null
|
||||
, cargoVendorDir ? null
|
||||
, checkType ? buildType
|
||||
, buildNoDefaultFeatures ? false
|
||||
, checkNoDefaultFeatures ? buildNoDefaultFeatures
|
||||
, buildFeatures ? [ ]
|
||||
, checkFeatures ? buildFeatures
|
||||
, depsExtraArgs ? {}
|
||||
|
||||
# Toggles whether a custom sysroot is created when the target is a .json file.
|
||||
, __internal_dontAddSysroot ? false
|
||||
|
||||
# Needed to `pushd`/`popd` into a subdir of a tarball if this subdir
|
||||
# contains a Cargo.toml, but isn't part of a workspace (which is e.g. the
|
||||
# case for `rustfmt`/etc from the `rust-sources).
|
||||
# Otherwise, everything from the tarball would've been built/tested.
|
||||
, buildAndTestSubdir ? null
|
||||
, ... } @ args:
|
||||
|
||||
assert cargoVendorDir == null && cargoLock == null -> !(args ? cargoSha256) && !(args ? cargoHash)
|
||||
-> throw "cargoSha256, cargoHash, cargoVendorDir, or cargoLock must be set";
|
||||
assert buildType == "release" || buildType == "debug";
|
||||
|
||||
let
|
||||
|
||||
cargoDeps =
|
||||
if cargoVendorDir != null then null
|
||||
else if cargoLock != null then importCargoLock cargoLock
|
||||
else fetchCargoTarball ({
|
||||
inherit src srcs sourceRoot unpackPhase cargoUpdateHook;
|
||||
name = cargoDepsName;
|
||||
patches = cargoPatches;
|
||||
} // lib.optionalAttrs (args ? cargoHash) {
|
||||
hash = args.cargoHash;
|
||||
} // lib.optionalAttrs (args ? cargoSha256) {
|
||||
sha256 = args.cargoSha256;
|
||||
} // depsExtraArgs);
|
||||
|
||||
# If we have a cargoSha256 fixed-output derivation, validate it at build time
|
||||
# against the src fixed-output derivation to check consistency.
|
||||
validateCargoDeps = args ? cargoHash || args ? cargoSha256;
|
||||
|
||||
target = rust.toRustTargetSpec stdenv.hostPlatform;
|
||||
targetIsJSON = lib.hasSuffix ".json" target;
|
||||
useSysroot = targetIsJSON && !__internal_dontAddSysroot;
|
||||
|
||||
# see https://github.com/rust-lang/cargo/blob/964a16a28e234a3d397b2a7031d4ab4a428b1391/src/cargo/core/compiler/compile_kind.rs#L151-L168
|
||||
# the "${}" is needed to transform the path into a /nix/store path before baseNameOf
|
||||
shortTarget = if targetIsJSON then
|
||||
(lib.removeSuffix ".json" (builtins.baseNameOf "${target}"))
|
||||
else target;
|
||||
|
||||
sysroot = callPackage ./sysroot { } {
|
||||
inherit target shortTarget;
|
||||
RUSTFLAGS = args.RUSTFLAGS or "";
|
||||
originalCargoToml = src + /Cargo.toml; # profile info is later extracted
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
# Tests don't currently work for `no_std`, and all custom sysroots are currently built without `std`.
|
||||
# See https://os.phil-opp.com/testing/ for more information.
|
||||
assert useSysroot -> !(args.doCheck or true);
|
||||
|
||||
stdenv.mkDerivation ((removeAttrs args [ "depsExtraArgs" "cargoUpdateHook" "cargoLock" ]) // lib.optionalAttrs useSysroot {
|
||||
RUSTFLAGS = "--sysroot ${sysroot} " + (args.RUSTFLAGS or "");
|
||||
} // {
|
||||
inherit buildAndTestSubdir cargoDeps;
|
||||
|
||||
cargoBuildType = buildType;
|
||||
|
||||
cargoCheckType = checkType;
|
||||
|
||||
cargoBuildNoDefaultFeatures = buildNoDefaultFeatures;
|
||||
|
||||
cargoCheckNoDefaultFeatures = checkNoDefaultFeatures;
|
||||
|
||||
cargoBuildFeatures = buildFeatures;
|
||||
|
||||
cargoCheckFeatures = checkFeatures;
|
||||
|
||||
patchRegistryDeps = ./patch-registry-deps;
|
||||
|
||||
nativeBuildInputs = nativeBuildInputs ++ [
|
||||
cacert
|
||||
git
|
||||
cargoBuildHook
|
||||
cargoCheckHook
|
||||
cargoInstallHook
|
||||
cargoSetupHook
|
||||
rustc
|
||||
];
|
||||
|
||||
buildInputs = buildInputs
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ]
|
||||
++ lib.optionals stdenv.hostPlatform.isMinGW [ windows.pthreads ];
|
||||
|
||||
patches = cargoPatches ++ patches;
|
||||
|
||||
PKG_CONFIG_ALLOW_CROSS =
|
||||
if stdenv.buildPlatform != stdenv.hostPlatform then 1 else 0;
|
||||
|
||||
postUnpack = ''
|
||||
eval "$cargoDepsHook"
|
||||
|
||||
export RUST_LOG=${logLevel}
|
||||
'' + (args.postUnpack or "");
|
||||
|
||||
configurePhase = args.configurePhase or ''
|
||||
runHook preConfigure
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
doCheck = args.doCheck or true;
|
||||
|
||||
strictDeps = true;
|
||||
|
||||
passthru = { inherit cargoDeps; } // (args.passthru or {});
|
||||
|
||||
meta = {
|
||||
# default to Rust's platforms
|
||||
platforms = rustc.meta.platforms;
|
||||
} // meta;
|
||||
})
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
for dir in pkg-config-*; do
|
||||
[ -d "$dir" ] || continue
|
||||
|
||||
echo "Patching pkg-config registry dep"
|
||||
|
||||
substituteInPlace "$dir/src/lib.rs" \
|
||||
--replace '"/usr"' '"'"$NIX_STORE"'/"'
|
||||
done
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
{ stdenv, rust, rustPlatform, buildPackages }:
|
||||
|
||||
{ shortTarget, originalCargoToml, target, RUSTFLAGS }:
|
||||
|
||||
let
|
||||
cargoSrc = import ../../sysroot/src.nix {
|
||||
inherit stdenv rustPlatform buildPackages originalCargoToml;
|
||||
};
|
||||
in rustPlatform.buildRustPackage {
|
||||
inherit target RUSTFLAGS;
|
||||
|
||||
name = "custom-sysroot";
|
||||
src = cargoSrc;
|
||||
|
||||
RUSTC_BOOTSTRAP = 1;
|
||||
__internal_dontAddSysroot = true;
|
||||
cargoSha256 = "0y6dqfhsgk00y3fv5bnjzk0s7i30nwqc1rp0xlrk83hkh80x81mw";
|
||||
|
||||
doCheck = false;
|
||||
|
||||
installPhase = ''
|
||||
export LIBS_DIR=$out/lib/rustlib/${shortTarget}/lib
|
||||
mkdir -p $LIBS_DIR
|
||||
for f in target/${shortTarget}/release/deps/*.{rlib,rmeta}; do
|
||||
cp $f $LIBS_DIR
|
||||
done
|
||||
|
||||
export RUST_SYSROOT=$(rustc --print=sysroot)
|
||||
host=${rust.toRustTarget stdenv.buildPlatform}
|
||||
cp -r $RUST_SYSROOT/lib/rustlib/$host $out
|
||||
'';
|
||||
}
|
||||
259
pkgs/build-support/rust/carnix.nix
Normal file
259
pkgs/build-support/rust/carnix.nix
Normal file
|
|
@ -0,0 +1,259 @@
|
|||
# Generated by carnix 0.9.10: carnix generate-nix
|
||||
{ lib, buildPlatform, buildRustCrate, buildRustCrateHelpers, cratesIO, fetchgit }:
|
||||
with buildRustCrateHelpers;
|
||||
let inherit (lib.lists) fold;
|
||||
inherit (lib.attrsets) recursiveUpdate;
|
||||
in
|
||||
rec {
|
||||
crates = cratesIO;
|
||||
carnix = crates.crates.carnix."0.10.0" deps;
|
||||
__all = [ (carnix {}) ];
|
||||
deps.aho_corasick."0.6.10" = {
|
||||
memchr = "2.2.0";
|
||||
};
|
||||
deps.ansi_term."0.11.0" = {
|
||||
winapi = "0.3.6";
|
||||
};
|
||||
deps.argon2rs."0.2.5" = {
|
||||
blake2_rfc = "0.2.18";
|
||||
scoped_threadpool = "0.1.9";
|
||||
};
|
||||
deps.arrayvec."0.4.10" = {
|
||||
nodrop = "0.1.13";
|
||||
};
|
||||
deps.atty."0.2.11" = {
|
||||
termion = "1.5.1";
|
||||
libc = "0.2.50";
|
||||
winapi = "0.3.6";
|
||||
};
|
||||
deps.autocfg."0.1.2" = {};
|
||||
deps.backtrace."0.3.14" = {
|
||||
cfg_if = "0.1.7";
|
||||
rustc_demangle = "0.1.13";
|
||||
autocfg = "0.1.2";
|
||||
backtrace_sys = "0.1.28";
|
||||
libc = "0.2.50";
|
||||
winapi = "0.3.6";
|
||||
};
|
||||
deps.backtrace_sys."0.1.28" = {
|
||||
libc = "0.2.50";
|
||||
cc = "1.0.32";
|
||||
};
|
||||
deps.bitflags."1.0.4" = {};
|
||||
deps.blake2_rfc."0.2.18" = {
|
||||
arrayvec = "0.4.10";
|
||||
constant_time_eq = "0.1.3";
|
||||
};
|
||||
deps.carnix."0.10.0" = {
|
||||
clap = "2.32.0";
|
||||
dirs = "1.0.5";
|
||||
env_logger = "0.6.1";
|
||||
failure = "0.1.5";
|
||||
failure_derive = "0.1.5";
|
||||
itertools = "0.8.0";
|
||||
log = "0.4.6";
|
||||
nom = "3.2.1";
|
||||
regex = "1.1.2";
|
||||
serde = "1.0.89";
|
||||
serde_derive = "1.0.89";
|
||||
serde_json = "1.0.39";
|
||||
tempdir = "0.3.7";
|
||||
toml = "0.5.0";
|
||||
url = "1.7.2";
|
||||
};
|
||||
deps.cc."1.0.32" = {};
|
||||
deps.cfg_if."0.1.7" = {};
|
||||
deps.clap."2.32.0" = {
|
||||
atty = "0.2.11";
|
||||
bitflags = "1.0.4";
|
||||
strsim = "0.7.0";
|
||||
textwrap = "0.10.0";
|
||||
unicode_width = "0.1.5";
|
||||
vec_map = "0.8.1";
|
||||
ansi_term = "0.11.0";
|
||||
};
|
||||
deps.cloudabi."0.0.3" = {
|
||||
bitflags = "1.0.4";
|
||||
};
|
||||
deps.constant_time_eq."0.1.3" = {};
|
||||
deps.dirs."1.0.5" = {
|
||||
redox_users = "0.3.0";
|
||||
libc = "0.2.50";
|
||||
winapi = "0.3.6";
|
||||
};
|
||||
deps.either."1.5.1" = {};
|
||||
deps.env_logger."0.6.1" = {
|
||||
atty = "0.2.11";
|
||||
humantime = "1.2.0";
|
||||
log = "0.4.6";
|
||||
regex = "1.1.2";
|
||||
termcolor = "1.0.4";
|
||||
};
|
||||
deps.failure."0.1.5" = {
|
||||
backtrace = "0.3.14";
|
||||
failure_derive = "0.1.5";
|
||||
};
|
||||
deps.failure_derive."0.1.5" = {
|
||||
proc_macro2 = "0.4.27";
|
||||
quote = "0.6.11";
|
||||
syn = "0.15.29";
|
||||
synstructure = "0.10.1";
|
||||
};
|
||||
deps.fuchsia_cprng."0.1.1" = {};
|
||||
deps.humantime."1.2.0" = {
|
||||
quick_error = "1.2.2";
|
||||
};
|
||||
deps.idna."0.1.5" = {
|
||||
matches = "0.1.8";
|
||||
unicode_bidi = "0.3.4";
|
||||
unicode_normalization = "0.1.8";
|
||||
};
|
||||
deps.itertools."0.8.0" = {
|
||||
either = "1.5.1";
|
||||
};
|
||||
deps.itoa."0.4.3" = {};
|
||||
deps.lazy_static."1.3.0" = {};
|
||||
deps.libc."0.2.50" = {};
|
||||
deps.log."0.4.6" = {
|
||||
cfg_if = "0.1.7";
|
||||
};
|
||||
deps.matches."0.1.8" = {};
|
||||
deps.memchr."1.0.2" = {
|
||||
libc = "0.2.50";
|
||||
};
|
||||
deps.memchr."2.2.0" = {};
|
||||
deps.nodrop."0.1.13" = {};
|
||||
deps.nom."3.2.1" = {
|
||||
memchr = "1.0.2";
|
||||
};
|
||||
deps.percent_encoding."1.0.1" = {};
|
||||
deps.proc_macro2."0.4.27" = {
|
||||
unicode_xid = "0.1.0";
|
||||
};
|
||||
deps.quick_error."1.2.2" = {};
|
||||
deps.quote."0.6.11" = {
|
||||
proc_macro2 = "0.4.27";
|
||||
};
|
||||
deps.rand."0.4.6" = {
|
||||
rand_core = "0.3.1";
|
||||
rdrand = "0.4.0";
|
||||
fuchsia_cprng = "0.1.1";
|
||||
libc = "0.2.50";
|
||||
winapi = "0.3.6";
|
||||
};
|
||||
deps.rand_core."0.3.1" = {
|
||||
rand_core = "0.4.0";
|
||||
};
|
||||
deps.rand_core."0.4.0" = {};
|
||||
deps.rand_os."0.1.3" = {
|
||||
rand_core = "0.4.0";
|
||||
rdrand = "0.4.0";
|
||||
cloudabi = "0.0.3";
|
||||
fuchsia_cprng = "0.1.1";
|
||||
libc = "0.2.50";
|
||||
winapi = "0.3.6";
|
||||
};
|
||||
deps.rdrand."0.4.0" = {
|
||||
rand_core = "0.3.1";
|
||||
};
|
||||
deps.redox_syscall."0.1.51" = {};
|
||||
deps.redox_termios."0.1.1" = {
|
||||
redox_syscall = "0.1.51";
|
||||
};
|
||||
deps.redox_users."0.3.0" = {
|
||||
argon2rs = "0.2.5";
|
||||
failure = "0.1.5";
|
||||
rand_os = "0.1.3";
|
||||
redox_syscall = "0.1.51";
|
||||
};
|
||||
deps.regex."1.1.2" = {
|
||||
aho_corasick = "0.6.10";
|
||||
memchr = "2.2.0";
|
||||
regex_syntax = "0.6.5";
|
||||
thread_local = "0.3.6";
|
||||
utf8_ranges = "1.0.2";
|
||||
};
|
||||
deps.regex_syntax."0.6.5" = {
|
||||
ucd_util = "0.1.3";
|
||||
};
|
||||
deps.remove_dir_all."0.5.1" = {
|
||||
winapi = "0.3.6";
|
||||
};
|
||||
deps.rustc_demangle."0.1.13" = {};
|
||||
deps.ryu."0.2.7" = {};
|
||||
deps.scoped_threadpool."0.1.9" = {};
|
||||
deps.serde."1.0.89" = {};
|
||||
deps.serde_derive."1.0.89" = {
|
||||
proc_macro2 = "0.4.27";
|
||||
quote = "0.6.11";
|
||||
syn = "0.15.29";
|
||||
};
|
||||
deps.serde_json."1.0.39" = {
|
||||
itoa = "0.4.3";
|
||||
ryu = "0.2.7";
|
||||
serde = "1.0.89";
|
||||
};
|
||||
deps.smallvec."0.6.9" = {};
|
||||
deps.strsim."0.7.0" = {};
|
||||
deps.syn."0.15.29" = {
|
||||
proc_macro2 = "0.4.27";
|
||||
quote = "0.6.11";
|
||||
unicode_xid = "0.1.0";
|
||||
};
|
||||
deps.synstructure."0.10.1" = {
|
||||
proc_macro2 = "0.4.27";
|
||||
quote = "0.6.11";
|
||||
syn = "0.15.29";
|
||||
unicode_xid = "0.1.0";
|
||||
};
|
||||
deps.tempdir."0.3.7" = {
|
||||
rand = "0.4.6";
|
||||
remove_dir_all = "0.5.1";
|
||||
};
|
||||
deps.termcolor."1.0.4" = {
|
||||
wincolor = "1.0.1";
|
||||
};
|
||||
deps.termion."1.5.1" = {
|
||||
libc = "0.2.50";
|
||||
redox_syscall = "0.1.51";
|
||||
redox_termios = "0.1.1";
|
||||
};
|
||||
deps.textwrap."0.10.0" = {
|
||||
unicode_width = "0.1.5";
|
||||
};
|
||||
deps.thread_local."0.3.6" = {
|
||||
lazy_static = "1.3.0";
|
||||
};
|
||||
deps.toml."0.5.0" = {
|
||||
serde = "1.0.89";
|
||||
};
|
||||
deps.ucd_util."0.1.3" = {};
|
||||
deps.unicode_bidi."0.3.4" = {
|
||||
matches = "0.1.8";
|
||||
};
|
||||
deps.unicode_normalization."0.1.8" = {
|
||||
smallvec = "0.6.9";
|
||||
};
|
||||
deps.unicode_width."0.1.5" = {};
|
||||
deps.unicode_xid."0.1.0" = {};
|
||||
deps.url."1.7.2" = {
|
||||
idna = "0.1.5";
|
||||
matches = "0.1.8";
|
||||
percent_encoding = "1.0.1";
|
||||
};
|
||||
deps.utf8_ranges."1.0.2" = {};
|
||||
deps.vec_map."0.8.1" = {};
|
||||
deps.winapi."0.3.6" = {
|
||||
winapi_i686_pc_windows_gnu = "0.4.0";
|
||||
winapi_x86_64_pc_windows_gnu = "0.4.0";
|
||||
};
|
||||
deps.winapi_i686_pc_windows_gnu."0.4.0" = {};
|
||||
deps.winapi_util."0.1.2" = {
|
||||
winapi = "0.3.6";
|
||||
};
|
||||
deps.winapi_x86_64_pc_windows_gnu."0.4.0" = {};
|
||||
deps.wincolor."1.0.1" = {
|
||||
winapi = "0.3.6";
|
||||
winapi_util = "0.1.2";
|
||||
};
|
||||
}
|
||||
7756
pkgs/build-support/rust/crates-io.nix
Normal file
7756
pkgs/build-support/rust/crates-io.nix
Normal file
File diff suppressed because it is too large
Load diff
223
pkgs/build-support/rust/default-crate-overrides.nix
Normal file
223
pkgs/build-support/rust/default-crate-overrides.nix
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, pkg-config
|
||||
, curl
|
||||
, darwin
|
||||
, libgit2
|
||||
, libssh2
|
||||
, openssl
|
||||
, sqlite
|
||||
, zlib
|
||||
, dbus
|
||||
, dbus-glib
|
||||
, gdk-pixbuf
|
||||
, cairo
|
||||
, python3
|
||||
, libsodium
|
||||
, postgresql
|
||||
, gmp
|
||||
, foundationdb
|
||||
, capnproto
|
||||
, nettle
|
||||
, clang
|
||||
, llvmPackages
|
||||
, linux-pam
|
||||
, cmake
|
||||
, glib
|
||||
, freetype
|
||||
, rdkafka
|
||||
, udev
|
||||
, ...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (darwin.apple_sdk.frameworks) CoreFoundation Security;
|
||||
in
|
||||
{
|
||||
cairo-rs = attrs: {
|
||||
buildInputs = [ cairo ];
|
||||
};
|
||||
|
||||
capnp-rpc = attrs: {
|
||||
nativeBuildInputs = [ capnproto ];
|
||||
};
|
||||
|
||||
cargo = attrs: {
|
||||
buildInputs = [ openssl zlib curl ]
|
||||
++ lib.optionals stdenv.isDarwin [ CoreFoundation Security ];
|
||||
};
|
||||
|
||||
libz-sys = attrs: {
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ zlib ];
|
||||
extraLinkFlags = [ "-L${zlib.out}/lib" ];
|
||||
};
|
||||
|
||||
curl-sys = attrs: {
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ zlib curl ];
|
||||
propagatedBuildInputs = [ curl zlib ];
|
||||
extraLinkFlags = [ "-L${zlib.out}/lib" ];
|
||||
};
|
||||
|
||||
dbus = attrs: {
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ dbus ];
|
||||
};
|
||||
|
||||
expat-sys = attrs: {
|
||||
nativeBuildInputs = [ cmake ];
|
||||
};
|
||||
|
||||
foundationdb-sys = attrs: {
|
||||
buildInputs = [ foundationdb ];
|
||||
# needed for 0.4+ release, when the FFI bindings are auto-generated
|
||||
#
|
||||
# patchPhase = ''
|
||||
# substituteInPlace ./foundationdb-sys/build.rs \
|
||||
# --replace /usr/local/include ${foundationdb.dev}/include
|
||||
# '';
|
||||
};
|
||||
|
||||
foundationdb = attrs: {
|
||||
buildInputs = [ foundationdb ];
|
||||
};
|
||||
|
||||
freetype-sys = attrs: {
|
||||
nativeBuildInputs = [ cmake ];
|
||||
buildInputs = [ freetype ];
|
||||
};
|
||||
|
||||
glib-sys = attrs: {
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ glib ];
|
||||
};
|
||||
|
||||
gobject-sys = attrs: {
|
||||
buildInputs = [ dbus-glib ];
|
||||
};
|
||||
|
||||
gio-sys = attrs: {
|
||||
buildInputs = [ dbus-glib ];
|
||||
};
|
||||
|
||||
gdk-pixbuf-sys = attrs: {
|
||||
buildInputs = [ dbus-glib ];
|
||||
};
|
||||
|
||||
gdk-pixbuf = attrs: {
|
||||
buildInputs = [ gdk-pixbuf ];
|
||||
};
|
||||
|
||||
libgit2-sys = attrs: {
|
||||
LIBGIT2_SYS_USE_PKG_CONFIG = true;
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ openssl zlib libgit2 ];
|
||||
};
|
||||
|
||||
libsqlite3-sys = attrs: {
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ sqlite ];
|
||||
};
|
||||
|
||||
libssh2-sys = attrs: {
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ openssl zlib libssh2 ];
|
||||
};
|
||||
|
||||
libdbus-sys = attrs: {
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ dbus ];
|
||||
};
|
||||
|
||||
libudev-sys = attrs: {
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ udev ];
|
||||
};
|
||||
|
||||
nettle-sys = attrs: {
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ nettle clang ];
|
||||
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
|
||||
};
|
||||
|
||||
openssl = attrs: {
|
||||
buildInputs = [ openssl ];
|
||||
};
|
||||
|
||||
openssl-sys = attrs: {
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ openssl ];
|
||||
};
|
||||
|
||||
pam-sys = attr: {
|
||||
buildInputs = [ linux-pam ];
|
||||
};
|
||||
|
||||
pq-sys = attr: {
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ postgresql ];
|
||||
};
|
||||
|
||||
rdkafka-sys = attr: {
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ rdkafka ];
|
||||
};
|
||||
|
||||
rink = attrs: {
|
||||
buildInputs = [ gmp ];
|
||||
crateBin = [{ name = "rink"; path = "src/bin/rink.rs"; }];
|
||||
};
|
||||
|
||||
security-framework-sys = attr: {
|
||||
propagatedBuildInputs = lib.optional stdenv.isDarwin Security;
|
||||
};
|
||||
|
||||
sequoia-openpgp = attrs: {
|
||||
buildInputs = [ gmp ];
|
||||
};
|
||||
|
||||
sequoia-openpgp-ffi = attrs: {
|
||||
buildInputs = [ gmp ];
|
||||
};
|
||||
|
||||
sequoia-ipc = attrs: {
|
||||
buildInputs = [ gmp ];
|
||||
};
|
||||
|
||||
sequoia-guide = attrs: {
|
||||
buildInputs = [ gmp ];
|
||||
};
|
||||
|
||||
sequoia-store = attrs: {
|
||||
nativeBuildInputs = [ capnproto ];
|
||||
buildInputs = [ sqlite gmp ];
|
||||
};
|
||||
|
||||
sequoia-sq = attrs: {
|
||||
buildInputs = [ sqlite gmp ];
|
||||
};
|
||||
|
||||
sequoia-tool = attrs: {
|
||||
nativeBuildInputs = [ capnproto ];
|
||||
buildInputs = [ sqlite gmp ];
|
||||
};
|
||||
|
||||
serde_derive = attrs: {
|
||||
buildInputs = lib.optional stdenv.isDarwin Security;
|
||||
};
|
||||
|
||||
servo-fontconfig-sys = attrs: {
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ freetype ];
|
||||
};
|
||||
|
||||
thrussh-libsodium = attrs: {
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ libsodium ];
|
||||
};
|
||||
|
||||
xcb = attrs: {
|
||||
buildInputs = [ python3 ];
|
||||
};
|
||||
}
|
||||
41
pkgs/build-support/rust/fetch-cargo-tarball/cargo-vendor-normalise.py
Executable file
41
pkgs/build-support/rust/fetch-cargo-tarball/cargo-vendor-normalise.py
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
import toml
|
||||
|
||||
|
||||
def quote(s: str) -> str:
|
||||
escaped = s.replace('"', r"\"").replace("\n", r"\n").replace("\\", "\\\\")
|
||||
return '"{}"'.format(escaped)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
data = toml.load(sys.stdin)
|
||||
|
||||
assert list(data.keys()) == ["source"]
|
||||
|
||||
# this value is non deterministic
|
||||
data["source"]["vendored-sources"]["directory"] = "@vendor@"
|
||||
|
||||
lines = []
|
||||
inner = data["source"]
|
||||
for source, attrs in sorted(inner.items()):
|
||||
lines.append("[source.{}]".format(quote(source)))
|
||||
if source == "vendored-sources":
|
||||
lines.append('"directory" = "@vendor@"\n')
|
||||
else:
|
||||
for key, value in sorted(attrs.items()):
|
||||
attr = "{} = {}".format(quote(key), quote(value))
|
||||
lines.append(attr)
|
||||
lines.append("")
|
||||
|
||||
result = "\n".join(lines)
|
||||
real = toml.loads(result)
|
||||
assert real == data, "output = {} while input = {}".format(real, data)
|
||||
|
||||
print(result)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
87
pkgs/build-support/rust/fetch-cargo-tarball/default.nix
Normal file
87
pkgs/build-support/rust/fetch-cargo-tarball/default.nix
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
{ lib, stdenv, cacert, git, cargo, python3 }:
|
||||
let cargo-vendor-normalise = stdenv.mkDerivation {
|
||||
name = "cargo-vendor-normalise";
|
||||
src = ./cargo-vendor-normalise.py;
|
||||
nativeBuildInputs = [ python3.pkgs.wrapPython ];
|
||||
dontUnpack = true;
|
||||
installPhase = "install -D $src $out/bin/cargo-vendor-normalise";
|
||||
pythonPath = [ python3.pkgs.toml ];
|
||||
postFixup = "wrapPythonPrograms";
|
||||
doInstallCheck = true;
|
||||
installCheckPhase = ''
|
||||
# check that ../fetchcargo-default-config.toml is a fix point
|
||||
reference=${../fetchcargo-default-config.toml}
|
||||
< $reference $out/bin/cargo-vendor-normalise > test;
|
||||
cmp test $reference
|
||||
'';
|
||||
preferLocalBuild = true;
|
||||
};
|
||||
in
|
||||
{ name ? "cargo-deps"
|
||||
, src ? null
|
||||
, srcs ? []
|
||||
, patches ? []
|
||||
, sourceRoot ? ""
|
||||
, cargoUpdateHook ? ""
|
||||
, nativeBuildInputs ? []
|
||||
, ...
|
||||
} @ args:
|
||||
|
||||
let hash_ =
|
||||
if args ? hash then { outputHashAlgo = null; outputHash = args.hash; }
|
||||
else if args ? sha256 then { outputHashAlgo = "sha256"; outputHash = args.sha256; }
|
||||
else throw "fetchCargoTarball requires a hash for ${name}";
|
||||
in stdenv.mkDerivation ({
|
||||
name = "${name}-vendor.tar.gz";
|
||||
nativeBuildInputs = [ cacert git cargo-vendor-normalise cargo ] ++ nativeBuildInputs;
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
# Ensure deterministic Cargo vendor builds
|
||||
export SOURCE_DATE_EPOCH=1
|
||||
|
||||
if [[ ! -f Cargo.lock ]]; then
|
||||
echo
|
||||
echo "ERROR: The Cargo.lock file doesn't exist"
|
||||
echo
|
||||
echo "Cargo.lock is needed to make sure that cargoHash/cargoSha256 doesn't change"
|
||||
echo "when the registry is updated."
|
||||
echo
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Keep the original around for copyLockfile
|
||||
cp Cargo.lock Cargo.lock.orig
|
||||
|
||||
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
||||
CARGO_CONFIG=$(mktemp cargo-config.XXXX)
|
||||
|
||||
${cargoUpdateHook}
|
||||
|
||||
cargo vendor $name | cargo-vendor-normalise > $CARGO_CONFIG
|
||||
|
||||
# Add the Cargo.lock to allow hash invalidation
|
||||
cp Cargo.lock.orig $name/Cargo.lock
|
||||
|
||||
# Packages with git dependencies generate non-default cargo configs, so
|
||||
# always install it rather than trying to write a standard default template.
|
||||
install -D $CARGO_CONFIG $name/.cargo/config;
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
# Build a reproducible tar, per instructions at https://reproducible-builds.org/docs/archives/
|
||||
installPhase = ''
|
||||
tar --owner=0 --group=0 --numeric-owner --format=gnu \
|
||||
--sort=name --mtime="@$SOURCE_DATE_EPOCH" \
|
||||
-czf $out $name
|
||||
'';
|
||||
|
||||
inherit (hash_) outputHashAlgo outputHash;
|
||||
|
||||
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
|
||||
} // (builtins.removeAttrs args [
|
||||
"name" "sha256" "cargoUpdateHook" "nativeBuildInputs"
|
||||
]))
|
||||
7
pkgs/build-support/rust/fetchcargo-default-config.toml
Executable file
7
pkgs/build-support/rust/fetchcargo-default-config.toml
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
[source."crates-io"]
|
||||
"replace-with" = "vendored-sources"
|
||||
|
||||
[source."vendored-sources"]
|
||||
"directory" = "@vendor@"
|
||||
|
||||
|
||||
38
pkgs/build-support/rust/fetchcrate.nix
Normal file
38
pkgs/build-support/rust/fetchcrate.nix
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
{ lib, fetchurl, unzip }:
|
||||
|
||||
{ crateName ? args.pname
|
||||
, pname ? null
|
||||
, version
|
||||
, sha256
|
||||
, ... } @ args:
|
||||
|
||||
assert pname == null || pname == crateName;
|
||||
|
||||
lib.overrideDerivation (fetchurl ({
|
||||
|
||||
name = "${crateName}-${version}.tar.gz";
|
||||
url = "https://crates.io/api/v1/crates/${crateName}/${version}/download";
|
||||
recursiveHash = true;
|
||||
|
||||
downloadToTemp = true;
|
||||
|
||||
postFetch =
|
||||
''
|
||||
export PATH=${unzip}/bin:$PATH
|
||||
|
||||
unpackDir="$TMPDIR/unpack"
|
||||
mkdir "$unpackDir"
|
||||
cd "$unpackDir"
|
||||
|
||||
renamed="$TMPDIR/${crateName}-${version}.tar.gz"
|
||||
mv "$downloadedFile" "$renamed"
|
||||
unpackFile "$renamed"
|
||||
fn=$(cd "$unpackDir" && echo *)
|
||||
if [ -f "$unpackDir/$fn" ]; then
|
||||
mkdir $out
|
||||
fi
|
||||
mv "$unpackDir/$fn" "$out"
|
||||
'';
|
||||
} // removeAttrs args [ "crateName" "pname" "version" ]))
|
||||
# Hackety-hack: we actually need unzip hooks, too
|
||||
(x: {nativeBuildInputs = x.nativeBuildInputs++ [unzip];})
|
||||
54
pkgs/build-support/rust/hooks/cargo-build-hook.sh
Normal file
54
pkgs/build-support/rust/hooks/cargo-build-hook.sh
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
declare -a cargoBuildFlags
|
||||
|
||||
cargoBuildHook() {
|
||||
echo "Executing cargoBuildHook"
|
||||
|
||||
runHook preBuild
|
||||
|
||||
if [ ! -z "${buildAndTestSubdir-}" ]; then
|
||||
# ensure the output doesn't end up in the subdirectory
|
||||
export CARGO_TARGET_DIR="$(pwd)/target"
|
||||
|
||||
pushd "${buildAndTestSubdir}"
|
||||
fi
|
||||
|
||||
if [ "${cargoBuildType}" != "debug" ]; then
|
||||
cargoBuildProfileFlag="--${cargoBuildType}"
|
||||
fi
|
||||
|
||||
if [ -n "${cargoBuildNoDefaultFeatures-}" ]; then
|
||||
cargoBuildNoDefaultFeaturesFlag=--no-default-features
|
||||
fi
|
||||
|
||||
if [ -n "${cargoBuildFeatures-}" ]; then
|
||||
cargoBuildFeaturesFlag="--features=${cargoBuildFeatures// /,}"
|
||||
fi
|
||||
|
||||
(
|
||||
set -x
|
||||
env \
|
||||
"CC_@rustBuildPlatform@=@ccForBuild@" \
|
||||
"CXX_@rustBuildPlatform@=@cxxForBuild@" \
|
||||
"CC_@rustTargetPlatform@=@ccForHost@" \
|
||||
"CXX_@rustTargetPlatform@=@cxxForHost@" \
|
||||
cargo build -j $NIX_BUILD_CORES \
|
||||
--target @rustTargetPlatformSpec@ \
|
||||
--frozen \
|
||||
${cargoBuildProfileFlag} \
|
||||
${cargoBuildNoDefaultFeaturesFlag} \
|
||||
${cargoBuildFeaturesFlag} \
|
||||
${cargoBuildFlags}
|
||||
)
|
||||
|
||||
if [ ! -z "${buildAndTestSubdir-}" ]; then
|
||||
popd
|
||||
fi
|
||||
|
||||
runHook postBuild
|
||||
|
||||
echo "Finished cargoBuildHook"
|
||||
}
|
||||
|
||||
if [ -z "${dontCargoBuild-}" ] && [ -z "${buildPhase-}" ]; then
|
||||
buildPhase=cargoBuildHook
|
||||
fi
|
||||
55
pkgs/build-support/rust/hooks/cargo-check-hook.sh
Normal file
55
pkgs/build-support/rust/hooks/cargo-check-hook.sh
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
declare -a checkFlags
|
||||
declare -a cargoTestFlags
|
||||
|
||||
cargoCheckHook() {
|
||||
echo "Executing cargoCheckHook"
|
||||
|
||||
runHook preCheck
|
||||
|
||||
if [[ -n "${buildAndTestSubdir-}" ]]; then
|
||||
pushd "${buildAndTestSubdir}"
|
||||
fi
|
||||
|
||||
if [[ -z ${dontUseCargoParallelTests-} ]]; then
|
||||
threads=$NIX_BUILD_CORES
|
||||
else
|
||||
threads=1
|
||||
fi
|
||||
|
||||
if [ "${cargoCheckType}" != "debug" ]; then
|
||||
cargoCheckProfileFlag="--${cargoCheckType}"
|
||||
fi
|
||||
|
||||
if [ -n "${cargoCheckNoDefaultFeatures-}" ]; then
|
||||
cargoCheckNoDefaultFeaturesFlag=--no-default-features
|
||||
fi
|
||||
|
||||
if [ -n "${cargoCheckFeatures-}" ]; then
|
||||
cargoCheckFeaturesFlag="--features=${cargoCheckFeatures// /,}"
|
||||
fi
|
||||
|
||||
argstr="${cargoCheckProfileFlag} ${cargoCheckNoDefaultFeaturesFlag} ${cargoCheckFeaturesFlag}
|
||||
--target @rustTargetPlatformSpec@ --frozen ${cargoTestFlags}"
|
||||
|
||||
(
|
||||
set -x
|
||||
cargo test \
|
||||
-j $NIX_BUILD_CORES \
|
||||
${argstr} -- \
|
||||
--test-threads=${threads} \
|
||||
${checkFlags} \
|
||||
${checkFlagsArray+"${checkFlagsArray[@]}"}
|
||||
)
|
||||
|
||||
if [[ -n "${buildAndTestSubdir-}" ]]; then
|
||||
popd
|
||||
fi
|
||||
|
||||
echo "Finished cargoCheckHook"
|
||||
|
||||
runHook postCheck
|
||||
}
|
||||
|
||||
if [ -z "${dontCargoCheck-}" ] && [ -z "${checkPhase-}" ]; then
|
||||
checkPhase=cargoCheckHook
|
||||
fi
|
||||
49
pkgs/build-support/rust/hooks/cargo-install-hook.sh
Normal file
49
pkgs/build-support/rust/hooks/cargo-install-hook.sh
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
cargoInstallPostBuildHook() {
|
||||
echo "Executing cargoInstallPostBuildHook"
|
||||
|
||||
releaseDir=target/@shortTarget@/$cargoBuildType
|
||||
tmpDir="${releaseDir}-tmp";
|
||||
|
||||
mkdir -p $tmpDir
|
||||
cp -r ${releaseDir}/* $tmpDir/
|
||||
bins=$(find $tmpDir \
|
||||
-maxdepth 1 \
|
||||
-type f \
|
||||
-executable ! \( -regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \))
|
||||
|
||||
echo "Finished cargoInstallPostBuildHook"
|
||||
}
|
||||
|
||||
cargoInstallHook() {
|
||||
echo "Executing cargoInstallHook"
|
||||
|
||||
runHook preInstall
|
||||
|
||||
# rename the output dir to a architecture independent one
|
||||
|
||||
releaseDir=target/@shortTarget@/$cargoBuildType
|
||||
tmpDir="${releaseDir}-tmp";
|
||||
|
||||
mapfile -t targets < <(find "$NIX_BUILD_TOP" -type d | grep "${tmpDir}$")
|
||||
for target in "${targets[@]}"; do
|
||||
rm -rf "$target/../../${cargoBuildType}"
|
||||
ln -srf "$target" "$target/../../"
|
||||
done
|
||||
mkdir -p $out/bin $out/lib
|
||||
|
||||
xargs -r cp -t $out/bin <<< $bins
|
||||
find $tmpDir \
|
||||
-maxdepth 1 \
|
||||
-regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \
|
||||
-print0 | xargs -r -0 cp -t $out/lib
|
||||
rmdir --ignore-fail-on-non-empty $out/lib $out/bin
|
||||
runHook postInstall
|
||||
|
||||
echo "Finished cargoInstallHook"
|
||||
}
|
||||
|
||||
|
||||
if [ -z "${dontCargoInstall-}" ] && [ -z "${installPhase-}" ]; then
|
||||
installPhase=cargoInstallHook
|
||||
postBuildHooks+=(cargoInstallPostBuildHook)
|
||||
fi
|
||||
86
pkgs/build-support/rust/hooks/cargo-setup-hook.sh
Normal file
86
pkgs/build-support/rust/hooks/cargo-setup-hook.sh
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
cargoSetupPostUnpackHook() {
|
||||
echo "Executing cargoSetupPostUnpackHook"
|
||||
|
||||
# Some cargo builds include build hooks that modify their own vendor
|
||||
# dependencies. This copies the vendor directory into the build tree and makes
|
||||
# it writable. If we're using a tarball, the unpackFile hook already handles
|
||||
# this for us automatically.
|
||||
if [ -z $cargoVendorDir ]; then
|
||||
unpackFile "$cargoDeps"
|
||||
export cargoDepsCopy=$(stripHash $cargoDeps)
|
||||
else
|
||||
cargoDepsCopy="$sourceRoot/${cargoRoot:+$cargoRoot/}${cargoVendorDir}"
|
||||
fi
|
||||
|
||||
if [ ! -d .cargo ]; then
|
||||
mkdir .cargo
|
||||
fi
|
||||
|
||||
config="$(pwd)/$cargoDepsCopy/.cargo/config";
|
||||
if [[ ! -e $config ]]; then
|
||||
config=@defaultConfig@
|
||||
fi;
|
||||
|
||||
tmp_config=$(mktemp)
|
||||
substitute $config $tmp_config \
|
||||
--subst-var-by vendor "$(pwd)/$cargoDepsCopy"
|
||||
cat ${tmp_config} >> .cargo/config
|
||||
|
||||
cat >> .cargo/config <<'EOF'
|
||||
@rustTarget@
|
||||
EOF
|
||||
|
||||
echo "Finished cargoSetupPostUnpackHook"
|
||||
}
|
||||
|
||||
# After unpacking and applying patches, check that the Cargo.lock matches our
|
||||
# src package. Note that we do this after the patchPhase, because the
|
||||
# patchPhase may create the Cargo.lock if upstream has not shipped one.
|
||||
cargoSetupPostPatchHook() {
|
||||
echo "Executing cargoSetupPostPatchHook"
|
||||
|
||||
cargoDepsLockfile="$NIX_BUILD_TOP/$cargoDepsCopy/Cargo.lock"
|
||||
srcLockfile="$NIX_BUILD_TOP/$sourceRoot/${cargoRoot:+$cargoRoot/}/Cargo.lock"
|
||||
|
||||
echo "Validating consistency between $srcLockfile and $cargoDepsLockfile"
|
||||
if ! @diff@ $srcLockfile $cargoDepsLockfile; then
|
||||
|
||||
# If the diff failed, first double-check that the file exists, so we can
|
||||
# give a friendlier error msg.
|
||||
if ! [ -e $srcLockfile ]; then
|
||||
echo "ERROR: Missing Cargo.lock from src. Expected to find it at: $srcLockfile"
|
||||
echo "Hint: You can use the cargoPatches attribute to add a Cargo.lock manually to the build."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [ -e $cargoDepsLockfile ]; then
|
||||
echo "ERROR: Missing lockfile from cargo vendor. Expected to find it at: $cargoDepsLockfile"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "ERROR: cargoSha256 is out of date"
|
||||
echo
|
||||
echo "Cargo.lock is not the same in $cargoDepsCopy"
|
||||
echo
|
||||
echo "To fix the issue:"
|
||||
echo '1. Use "0000000000000000000000000000000000000000000000000000" as the cargoSha256 value'
|
||||
echo "2. Build the derivation and wait for it to fail with a hash mismatch"
|
||||
echo "3. Copy the 'got: sha256:' value back into the cargoSha256 field"
|
||||
echo
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
unset cargoDepsCopy
|
||||
|
||||
echo "Finished cargoSetupPostPatchHook"
|
||||
}
|
||||
|
||||
if [ -z "${dontCargoSetupPostUnpack-}" ]; then
|
||||
postUnpackHooks+=(cargoSetupPostUnpackHook)
|
||||
fi
|
||||
|
||||
if [ -z ${cargoVendorDir-} ]; then
|
||||
postPatchHooks+=(cargoSetupPostPatchHook)
|
||||
fi
|
||||
105
pkgs/build-support/rust/hooks/default.nix
Normal file
105
pkgs/build-support/rust/hooks/default.nix
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
{ buildPackages
|
||||
, callPackage
|
||||
, cargo
|
||||
, clang
|
||||
, diffutils
|
||||
, lib
|
||||
, makeSetupHook
|
||||
, maturin
|
||||
, rust
|
||||
, rustc
|
||||
, stdenv
|
||||
, target ? rust.toRustTargetSpec stdenv.hostPlatform
|
||||
}:
|
||||
|
||||
let
|
||||
targetIsJSON = lib.hasSuffix ".json" target;
|
||||
|
||||
# see https://github.com/rust-lang/cargo/blob/964a16a28e234a3d397b2a7031d4ab4a428b1391/src/cargo/core/compiler/compile_kind.rs#L151-L168
|
||||
# the "${}" is needed to transform the path into a /nix/store path before baseNameOf
|
||||
shortTarget = if targetIsJSON then
|
||||
(lib.removeSuffix ".json" (builtins.baseNameOf "${target}"))
|
||||
else target;
|
||||
ccForBuild = "${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc";
|
||||
cxxForBuild = "${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}c++";
|
||||
ccForHost = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
|
||||
cxxForHost = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++";
|
||||
rustBuildPlatform = rust.toRustTarget stdenv.buildPlatform;
|
||||
rustTargetPlatform = rust.toRustTarget stdenv.hostPlatform;
|
||||
rustTargetPlatformSpec = rust.toRustTargetSpec stdenv.hostPlatform;
|
||||
in {
|
||||
cargoBuildHook = callPackage ({ }:
|
||||
makeSetupHook {
|
||||
name = "cargo-build-hook.sh";
|
||||
deps = [ cargo ];
|
||||
substitutions = {
|
||||
inherit ccForBuild ccForHost cxxForBuild cxxForHost
|
||||
rustBuildPlatform rustTargetPlatform rustTargetPlatformSpec;
|
||||
};
|
||||
} ./cargo-build-hook.sh) {};
|
||||
|
||||
cargoCheckHook = callPackage ({ }:
|
||||
makeSetupHook {
|
||||
name = "cargo-check-hook.sh";
|
||||
deps = [ cargo ];
|
||||
substitutions = {
|
||||
inherit rustTargetPlatformSpec;
|
||||
};
|
||||
} ./cargo-check-hook.sh) {};
|
||||
|
||||
cargoInstallHook = callPackage ({ }:
|
||||
makeSetupHook {
|
||||
name = "cargo-install-hook.sh";
|
||||
deps = [ ];
|
||||
substitutions = {
|
||||
inherit shortTarget;
|
||||
};
|
||||
} ./cargo-install-hook.sh) {};
|
||||
|
||||
cargoSetupHook = callPackage ({ }:
|
||||
makeSetupHook {
|
||||
name = "cargo-setup-hook.sh";
|
||||
deps = [ ];
|
||||
substitutions = {
|
||||
defaultConfig = ../fetchcargo-default-config.toml;
|
||||
|
||||
# Specify the stdenv's `diff` by abspath to ensure that the user's build
|
||||
# inputs do not cause us to find the wrong `diff`.
|
||||
# The `.nativeDrv` stanza works like nativeBuildInputs and ensures cross-compiling has the right version available.
|
||||
diff = "${diffutils.nativeDrv or diffutils}/bin/diff";
|
||||
|
||||
# Target platform
|
||||
rustTarget = ''
|
||||
[target."${rust.toRustTarget stdenv.buildPlatform}"]
|
||||
"linker" = "${ccForBuild}"
|
||||
${lib.optionalString (stdenv.buildPlatform.config != stdenv.hostPlatform.config) ''
|
||||
[target."${shortTarget}"]
|
||||
"linker" = "${ccForHost}"
|
||||
${# https://github.com/rust-lang/rust/issues/46651#issuecomment-433611633
|
||||
lib.optionalString (stdenv.hostPlatform.isMusl && stdenv.hostPlatform.isAarch64) ''
|
||||
"rustflags" = [ "-C", "target-feature=+crt-static", "-C", "link-arg=-lgcc" ]
|
||||
''}
|
||||
''}
|
||||
'';
|
||||
};
|
||||
} ./cargo-setup-hook.sh) {};
|
||||
|
||||
maturinBuildHook = callPackage ({ }:
|
||||
makeSetupHook {
|
||||
name = "maturin-build-hook.sh";
|
||||
deps = [ cargo maturin rustc ];
|
||||
substitutions = {
|
||||
inherit ccForBuild ccForHost cxxForBuild cxxForHost
|
||||
rustBuildPlatform rustTargetPlatform rustTargetPlatformSpec;
|
||||
};
|
||||
} ./maturin-build-hook.sh) {};
|
||||
|
||||
bindgenHook = callPackage ({}: makeSetupHook {
|
||||
name = "rust-bindgen-hook";
|
||||
substitutions = {
|
||||
libclang = clang.cc.lib;
|
||||
inherit clang;
|
||||
};
|
||||
}
|
||||
./rust-bindgen-hook.sh) {};
|
||||
}
|
||||
39
pkgs/build-support/rust/hooks/maturin-build-hook.sh
Normal file
39
pkgs/build-support/rust/hooks/maturin-build-hook.sh
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
maturinBuildHook() {
|
||||
echo "Executing maturinBuildHook"
|
||||
|
||||
runHook preBuild
|
||||
|
||||
if [ ! -z "${buildAndTestSubdir-}" ]; then
|
||||
pushd "${buildAndTestSubdir}"
|
||||
fi
|
||||
|
||||
(
|
||||
set -x
|
||||
env \
|
||||
"CC_@rustBuildPlatform@=@ccForBuild@" \
|
||||
"CXX_@rustBuildPlatform@=@cxxForBuild@" \
|
||||
"CC_@rustTargetPlatform@=@ccForHost@" \
|
||||
"CXX_@rustTargetPlatform@=@cxxForHost@" \
|
||||
maturin build \
|
||||
--cargo-extra-args="-j $NIX_BUILD_CORES --frozen" \
|
||||
--target @rustTargetPlatformSpec@ \
|
||||
--manylinux off \
|
||||
--strip \
|
||||
--release \
|
||||
${maturinBuildFlags-}
|
||||
)
|
||||
|
||||
runHook postBuild
|
||||
|
||||
if [ ! -z "${buildAndTestSubdir-}" ]; then
|
||||
popd
|
||||
fi
|
||||
|
||||
# Move the wheel to dist/ so that regular Python tooling can find it.
|
||||
mkdir -p dist
|
||||
mv target/wheels/*.whl dist/
|
||||
|
||||
echo "Finished maturinBuildHook"
|
||||
}
|
||||
|
||||
buildPhase=maturinBuildHook
|
||||
13
pkgs/build-support/rust/hooks/rust-bindgen-hook.sh
Normal file
13
pkgs/build-support/rust/hooks/rust-bindgen-hook.sh
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# populates LIBCLANG_PATH and BINDGEN_EXTRA_CLANG_ARGS for rust projects that
|
||||
# depend on the bindgen crate
|
||||
|
||||
# if you modify this, you probably also need to modify the wrapper for the cli
|
||||
# of bindgen in pkgs/development/tools/rust/bindgen/wrapper.sh
|
||||
|
||||
populateBindgenEnv () {
|
||||
export LIBCLANG_PATH=@libclang@/lib
|
||||
BINDGEN_EXTRA_CLANG_ARGS="$(< @clang@/nix-support/cc-cflags) $(< @clang@/nix-support/libc-cflags) $(< @clang@/nix-support/libcxx-cxxflags) $NIX_CFLAGS_COMPILE"
|
||||
export BINDGEN_EXTRA_CLANG_ARGS
|
||||
}
|
||||
|
||||
postHook="${postHook:-}"$'\n'"populateBindgenEnv"$'\n'
|
||||
210
pkgs/build-support/rust/import-cargo-lock.nix
Normal file
210
pkgs/build-support/rust/import-cargo-lock.nix
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
{ fetchgit, fetchurl, lib, runCommand, cargo, jq }:
|
||||
|
||||
{
|
||||
# Cargo lock file
|
||||
lockFile ? null
|
||||
|
||||
# Cargo lock file contents as string
|
||||
, lockFileContents ? null
|
||||
|
||||
# Hashes for git dependencies.
|
||||
, outputHashes ? {}
|
||||
} @ args:
|
||||
|
||||
assert (lockFile == null) != (lockFileContents == null);
|
||||
|
||||
let
|
||||
# Parse a git source into different components.
|
||||
parseGit = src:
|
||||
let
|
||||
parts = builtins.match ''git\+([^?]+)(\?(rev|tag|branch)=(.*))?#(.*)'' src;
|
||||
type = builtins.elemAt parts 2; # rev, tag or branch
|
||||
value = builtins.elemAt parts 3;
|
||||
in
|
||||
if parts == null then null
|
||||
else {
|
||||
url = builtins.elemAt parts 0;
|
||||
sha = builtins.elemAt parts 4;
|
||||
} // lib.optionalAttrs (type != null) { inherit type value; };
|
||||
|
||||
# shadows args.lockFileContents
|
||||
lockFileContents =
|
||||
if lockFile != null
|
||||
then builtins.readFile lockFile
|
||||
else args.lockFileContents;
|
||||
|
||||
packages = (builtins.fromTOML lockFileContents).package;
|
||||
|
||||
# There is no source attribute for the source package itself. But
|
||||
# since we do not want to vendor the source package anyway, we can
|
||||
# safely skip it.
|
||||
depPackages = (builtins.filter (p: p ? "source") packages);
|
||||
|
||||
# Create dependent crates from packages.
|
||||
#
|
||||
# Force evaluation of the git SHA -> hash mapping, so that an error is
|
||||
# thrown if there are stale hashes. We cannot rely on gitShaOutputHash
|
||||
# being evaluated otherwise, since there could be no git dependencies.
|
||||
depCrates = builtins.deepSeq (gitShaOutputHash) (builtins.map mkCrate depPackages);
|
||||
|
||||
# Map package name + version to git commit SHA for packages with a git source.
|
||||
namesGitShas = builtins.listToAttrs (
|
||||
builtins.map nameGitSha (builtins.filter (pkg: lib.hasPrefix "git+" pkg.source) depPackages)
|
||||
);
|
||||
|
||||
nameGitSha = pkg: let gitParts = parseGit pkg.source; in {
|
||||
name = "${pkg.name}-${pkg.version}";
|
||||
value = gitParts.sha;
|
||||
};
|
||||
|
||||
# Convert the attrset provided through the `outputHashes` argument to a
|
||||
# a mapping from git commit SHA -> output hash.
|
||||
#
|
||||
# There may be multiple different packages with different names
|
||||
# originating from the same git repository (typically a Cargo
|
||||
# workspace). By using the git commit SHA as a universal identifier,
|
||||
# the user does not have to specify the output hash for every package
|
||||
# individually.
|
||||
gitShaOutputHash = lib.mapAttrs' (nameVer: hash:
|
||||
let
|
||||
unusedHash = throw "A hash was specified for ${nameVer}, but there is no corresponding git dependency.";
|
||||
rev = namesGitShas.${nameVer} or unusedHash; in {
|
||||
name = rev;
|
||||
value = hash;
|
||||
}) outputHashes;
|
||||
|
||||
# We can't use the existing fetchCrate function, since it uses a
|
||||
# recursive hash of the unpacked crate.
|
||||
fetchCrate = pkg:
|
||||
assert lib.assertMsg (pkg ? checksum) ''
|
||||
Package ${pkg.name} does not have a checksum.
|
||||
Please note that the Cargo.lock format where checksums used to be listed
|
||||
under [metadata] is not supported.
|
||||
If that is the case, running `cargo update` with a recent toolchain will
|
||||
automatically update the format along with the crate's depenendencies.
|
||||
'';
|
||||
fetchurl {
|
||||
name = "crate-${pkg.name}-${pkg.version}.tar.gz";
|
||||
url = "https://crates.io/api/v1/crates/${pkg.name}/${pkg.version}/download";
|
||||
sha256 = pkg.checksum;
|
||||
};
|
||||
|
||||
# Fetch and unpack a crate.
|
||||
mkCrate = pkg:
|
||||
let
|
||||
gitParts = parseGit pkg.source;
|
||||
in
|
||||
if pkg.source == "registry+https://github.com/rust-lang/crates.io-index" then
|
||||
let
|
||||
crateTarball = fetchCrate pkg;
|
||||
in runCommand "${pkg.name}-${pkg.version}" {} ''
|
||||
mkdir $out
|
||||
tar xf "${crateTarball}" -C $out --strip-components=1
|
||||
|
||||
# Cargo is happy with largely empty metadata.
|
||||
printf '{"files":{},"package":"${pkg.checksum}"}' > "$out/.cargo-checksum.json"
|
||||
''
|
||||
else if gitParts != null then
|
||||
let
|
||||
missingHash = throw ''
|
||||
No hash was found while vendoring the git dependency ${pkg.name}-${pkg.version}. You can add
|
||||
a hash through the `outputHashes` argument of `importCargoLock`:
|
||||
|
||||
outputHashes = {
|
||||
"${pkg.name}-${pkg.version}" = "<hash>";
|
||||
};
|
||||
|
||||
If you use `buildRustPackage`, you can add this attribute to the `cargoLock`
|
||||
attribute set.
|
||||
'';
|
||||
sha256 = gitShaOutputHash.${gitParts.sha} or missingHash;
|
||||
tree = fetchgit {
|
||||
inherit sha256;
|
||||
inherit (gitParts) url;
|
||||
rev = gitParts.sha; # The commit SHA is always available.
|
||||
};
|
||||
in runCommand "${pkg.name}-${pkg.version}" {} ''
|
||||
tree=${tree}
|
||||
|
||||
# If the target package is in a workspace, or if it's the top-level
|
||||
# crate, we should find the crate path using `cargo metadata`.
|
||||
# Some packages do not have a Cargo.toml at the top-level,
|
||||
# but only in nested directories.
|
||||
# Only check the top-level Cargo.toml, if it actually exists
|
||||
if [[ -f $tree/Cargo.toml ]]; then
|
||||
crateCargoTOML=$(${cargo}/bin/cargo metadata --format-version 1 --no-deps --manifest-path $tree/Cargo.toml | \
|
||||
${jq}/bin/jq -r '.packages[] | select(.name == "${pkg.name}") | .manifest_path')
|
||||
fi
|
||||
|
||||
# If the repository is not a workspace the package might be in a subdirectory.
|
||||
if [[ -z $crateCargoTOML ]]; then
|
||||
for manifest in $(find $tree -name "Cargo.toml"); do
|
||||
echo Looking at $manifest
|
||||
crateCargoTOML=$(${cargo}/bin/cargo metadata --format-version 1 --no-deps --manifest-path "$manifest" | ${jq}/bin/jq -r '.packages[] | select(.name == "${pkg.name}") | .manifest_path' || :)
|
||||
if [[ ! -z $crateCargoTOML ]]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z $crateCargoTOML ]]; then
|
||||
>&2 echo "Cannot find path for crate '${pkg.name}-${pkg.version}' in the tree in: $tree"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo Found crate ${pkg.name} at $crateCargoTOML
|
||||
tree=$(dirname $crateCargoTOML)
|
||||
|
||||
cp -prvd "$tree/" $out
|
||||
chmod u+w $out
|
||||
|
||||
# Cargo is happy with empty metadata.
|
||||
printf '{"files":{},"package":null}' > "$out/.cargo-checksum.json"
|
||||
|
||||
# Set up configuration for the vendor directory.
|
||||
cat > $out/.cargo-config <<EOF
|
||||
[source."${gitParts.url}"]
|
||||
git = "${gitParts.url}"
|
||||
${lib.optionalString (gitParts ? type) "${gitParts.type} = \"${gitParts.value}\""}
|
||||
replace-with = "vendored-sources"
|
||||
EOF
|
||||
''
|
||||
else throw "Cannot handle crate source: ${pkg.source}";
|
||||
|
||||
vendorDir = runCommand "cargo-vendor-dir" (lib.optionalAttrs (lockFile == null) {
|
||||
inherit lockFileContents;
|
||||
passAsFile = [ "lockFileContents" ];
|
||||
}) ''
|
||||
mkdir -p $out/.cargo
|
||||
|
||||
${
|
||||
if lockFile != null
|
||||
then "ln -s ${lockFile} $out/Cargo.lock"
|
||||
else "cp $lockFileContentsPath $out/Cargo.lock"
|
||||
}
|
||||
|
||||
cat > $out/.cargo/config <<EOF
|
||||
[source.crates-io]
|
||||
replace-with = "vendored-sources"
|
||||
|
||||
[source.vendored-sources]
|
||||
directory = "cargo-vendor-dir"
|
||||
EOF
|
||||
|
||||
declare -A keysSeen
|
||||
|
||||
for crate in ${toString depCrates}; do
|
||||
# Link the crate directory, removing the output path hash from the destination.
|
||||
ln -s "$crate" $out/$(basename "$crate" | cut -c 34-)
|
||||
|
||||
if [ -e "$crate/.cargo-config" ]; then
|
||||
key=$(sed 's/\[source\."\(.*\)"\]/\1/; t; d' < "$crate/.cargo-config")
|
||||
if [[ -z ''${keysSeen[$key]} ]]; then
|
||||
keysSeen[$key]=1
|
||||
cat "$crate/.cargo-config" >> $out/.cargo/config
|
||||
fi
|
||||
fi
|
||||
done
|
||||
'';
|
||||
in
|
||||
vendorDir
|
||||
37
pkgs/build-support/rust/lib/default.nix
Normal file
37
pkgs/build-support/rust/lib/default.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
{ lib }:
|
||||
|
||||
rec {
|
||||
# https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch
|
||||
toTargetArch = platform:
|
||||
if platform.isAarch32 then "arm"
|
||||
else platform.parsed.cpu.name;
|
||||
|
||||
# https://doc.rust-lang.org/reference/conditional-compilation.html#target_os
|
||||
toTargetOs = platform:
|
||||
if platform.isDarwin then "macos"
|
||||
else platform.parsed.kernel.name;
|
||||
|
||||
# Returns the name of the rust target, even if it is custom. Adjustments are
|
||||
# because rust has slightly different naming conventions than we do.
|
||||
toRustTarget = platform: let
|
||||
inherit (platform.parsed) cpu vendor kernel abi;
|
||||
cpu_ = platform.rustc.platform.arch or {
|
||||
"armv7a" = "armv7";
|
||||
"armv7l" = "armv7";
|
||||
"armv6l" = "arm";
|
||||
"armv5tel" = "armv5te";
|
||||
"riscv64" = "riscv64gc";
|
||||
}.${cpu.name} or cpu.name;
|
||||
vendor_ = platform.rustc.platform.vendor or {
|
||||
"w64" = "pc";
|
||||
}.${vendor.name} or vendor.name;
|
||||
in platform.rustc.config
|
||||
or "${cpu_}-${vendor_}-${kernel.name}${lib.optionalString (abi.name != "unknown") "-${abi.name}"}";
|
||||
|
||||
# Returns the name of the rust target if it is standard, or the json file
|
||||
# containing the custom target spec.
|
||||
toRustTargetSpec = platform:
|
||||
if (platform.rustc or {}) ? platform
|
||||
then builtins.toFile (toRustTarget platform + ".json") (builtins.toJSON platform.rustc.platform)
|
||||
else toRustTarget platform;
|
||||
}
|
||||
42
pkgs/build-support/rust/sysroot/Cargo.lock
generated
Normal file
42
pkgs/build-support/rust/sysroot/Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "alloc"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"compiler_builtins",
|
||||
"core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "compiler_builtins"
|
||||
version = "0.1.52"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6591c2442ee984e2b264638a8b5e7ae44fd47b32d28e3a08e2e9c3cdb0c2fb0"
|
||||
dependencies = [
|
||||
"rustc-std-workspace-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core"
|
||||
version = "0.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "nixpkgs-sysroot-stub-crate"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"alloc",
|
||||
"compiler_builtins",
|
||||
"core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-std-workspace-core"
|
||||
version = "1.99.0"
|
||||
dependencies = [
|
||||
"core",
|
||||
]
|
||||
|
||||
[[patch.unused]]
|
||||
name = "rustc-std-workspace-alloc"
|
||||
version = "1.99.0"
|
||||
47
pkgs/build-support/rust/sysroot/cargo.py
Normal file
47
pkgs/build-support/rust/sysroot/cargo.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import os
|
||||
import toml
|
||||
|
||||
rust_src = os.environ['RUSTC_SRC']
|
||||
orig_cargo = os.environ['ORIG_CARGO'] if 'ORIG_CARGO' in os.environ else None
|
||||
|
||||
base = {
|
||||
'package': {
|
||||
'name': 'nixpkgs-sysroot-stub-crate',
|
||||
'version': '0.0.0',
|
||||
'authors': ['The Rust Project Developers'],
|
||||
'edition': '2018',
|
||||
},
|
||||
'dependencies': {
|
||||
'compiler_builtins': {
|
||||
'version': '0.1.0',
|
||||
'features': ['rustc-dep-of-std', 'mem'],
|
||||
},
|
||||
'core': {
|
||||
'path': os.path.join(rust_src, 'core'),
|
||||
},
|
||||
'alloc': {
|
||||
'path': os.path.join(rust_src, 'alloc'),
|
||||
},
|
||||
},
|
||||
'patch': {
|
||||
'crates-io': {
|
||||
'rustc-std-workspace-core': {
|
||||
'path': os.path.join(rust_src, 'rustc-std-workspace-core'),
|
||||
},
|
||||
'rustc-std-workspace-alloc': {
|
||||
'path': os.path.join(rust_src, 'rustc-std-workspace-alloc'),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if orig_cargo is not None:
|
||||
with open(orig_cargo, 'r') as f:
|
||||
src = toml.loads(f.read())
|
||||
if 'profile' in src:
|
||||
base['profile'] = src['profile']
|
||||
|
||||
out = toml.dumps(base)
|
||||
|
||||
with open('Cargo.toml', 'x') as f:
|
||||
f.write(out)
|
||||
26
pkgs/build-support/rust/sysroot/src.nix
Normal file
26
pkgs/build-support/rust/sysroot/src.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{ lib, stdenv, rustPlatform, buildPackages
|
||||
, originalCargoToml ? null
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "cargo-src";
|
||||
preferLocalBuild = true;
|
||||
|
||||
unpackPhase = "true";
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
export RUSTC_SRC=${rustPlatform.rustLibSrc.override { }}
|
||||
''
|
||||
+ lib.optionalString (originalCargoToml != null) ''
|
||||
export ORIG_CARGO=${originalCargoToml}
|
||||
''
|
||||
+ ''
|
||||
${buildPackages.python3.withPackages (ps: with ps; [ toml ])}/bin/python3 ${./cargo.py}
|
||||
mkdir -p $out/src
|
||||
touch $out/src/lib.rs
|
||||
cp Cargo.toml $out/Cargo.toml
|
||||
cp ${./Cargo.lock} $out/Cargo.lock
|
||||
'';
|
||||
}
|
||||
27
pkgs/build-support/rust/sysroot/update-lockfile.sh
Executable file
27
pkgs/build-support/rust/sysroot/update-lockfile.sh
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p python3 python3.pkgs.toml cargo
|
||||
|
||||
set -eu pipefile
|
||||
|
||||
HERE=$(readlink -e $(dirname "${BASH_SOURCE[0]}"))
|
||||
NIXPKGS_ROOT="$HERE/../../../.."
|
||||
|
||||
# https://unix.stackexchange.com/a/84980/390173
|
||||
tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t 'update-lockfile')
|
||||
cd "$tempdir"
|
||||
mkdir -p src
|
||||
touch src/lib.rs
|
||||
|
||||
RUSTC_SRC=$(nix-build "${NIXPKGS_ROOT}" -A pkgs.rustPlatform.rustLibSrc --no-out-link)
|
||||
|
||||
ln -s $RUSTC_SRC/{core,alloc} ./
|
||||
|
||||
export RUSTC_SRC
|
||||
python3 "$HERE/cargo.py"
|
||||
|
||||
export RUSTC_BOOTSTRAP=1
|
||||
cargo generate-lockfile
|
||||
|
||||
cp Cargo.lock "$HERE"
|
||||
|
||||
rm -rf "$tempdir"
|
||||
83
pkgs/build-support/rust/test/import-cargo-lock/basic-dynamic/Cargo.lock
generated
Normal file
83
pkgs/build-support/rust/test/import-cargo-lock/basic-dynamic/Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "basic-dynamic"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.102"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "basic-dynamic"
|
||||
version = "0.1.0"
|
||||
authors = ["Daniël de Kok <me@danieldk.eu>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8"
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
{ rustPlatform }:
|
||||
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "basic-dynamic";
|
||||
version = "0.1.0";
|
||||
|
||||
src = ./.;
|
||||
|
||||
cargoLock.lockFileContents = builtins.readFile ./Cargo.lock;
|
||||
|
||||
doInstallCheck = true;
|
||||
|
||||
installCheckPhase = ''
|
||||
$out/bin/basic-dynamic
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
use rand::Rng;
|
||||
|
||||
fn main() {
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
// Always draw zero :).
|
||||
let roll: u8 = rng.gen_range(0..1);
|
||||
assert_eq!(roll, 0);
|
||||
}
|
||||
83
pkgs/build-support/rust/test/import-cargo-lock/basic/Cargo.lock
generated
Normal file
83
pkgs/build-support/rust/test/import-cargo-lock/basic/Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "basic"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "basic"
|
||||
version = "0.1.0"
|
||||
authors = ["Daniël de Kok <me@danieldk.eu>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8"
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
{ rustPlatform }:
|
||||
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "basic";
|
||||
version = "0.1.0";
|
||||
|
||||
src = ./.;
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
};
|
||||
|
||||
doInstallCheck = true;
|
||||
|
||||
installCheckPhase = ''
|
||||
$out/bin/basic
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
use rand::Rng;
|
||||
|
||||
fn main() {
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
// Always draw zero :).
|
||||
let roll: u8 = rng.gen_range(0..1);
|
||||
assert_eq!(roll, 0);
|
||||
}
|
||||
14
pkgs/build-support/rust/test/import-cargo-lock/default.nix
Normal file
14
pkgs/build-support/rust/test/import-cargo-lock/default.nix
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{ callPackage }:
|
||||
|
||||
# Build like this from nixpkgs root:
|
||||
# $ nix-build -A tests.importCargoLock
|
||||
{
|
||||
basic = callPackage ./basic { };
|
||||
basicDynamic = callPackage ./basic-dynamic { };
|
||||
gitDependency = callPackage ./git-dependency { };
|
||||
gitDependencyRev = callPackage ./git-dependency-rev { };
|
||||
gitDependencyRevNonWorkspaceNestedCrate = callPackage ./git-dependency-rev-non-workspace-nested-crate { };
|
||||
gitDependencyTag = callPackage ./git-dependency-tag { };
|
||||
gitDependencyBranch = callPackage ./git-dependency-branch { };
|
||||
maturin = callPackage ./maturin { };
|
||||
}
|
||||
72
pkgs/build-support/rust/test/import-cargo-lock/git-dependency-branch/Cargo.lock
generated
Normal file
72
pkgs/build-support/rust/test/import-cargo-lock/git-dependency-branch/Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "git-dependency-branch"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.4"
|
||||
source = "git+https://github.com/rust-random/rand.git?branch=master#fcc5baf31565a94f63dce41c2e739e6f182475f4"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.1"
|
||||
source = "git+https://github.com/rust-random/rand.git?branch=master#fcc5baf31565a94f63dce41c2e739e6f182475f4"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.3"
|
||||
source = "git+https://github.com/rust-random/rand.git?branch=master#fcc5baf31565a94f63dce41c2e739e6f182475f4"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "git-dependency-branch"
|
||||
version = "0.1.0"
|
||||
authors = ["Daniël de Kok <me@danieldk.eu>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
rand = { git = "https://github.com/rust-random/rand.git", branch = "master" }
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
{ rustPlatform }:
|
||||
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "git-dependency-branch";
|
||||
version = "0.1.0";
|
||||
|
||||
src = ./.;
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
outputHashes = {
|
||||
"rand-0.8.4" = "1ilk9wvfw3mdm57g199ys8f5nrgdrh0n3a4c8b7nz6lgnqvfrv6z";
|
||||
};
|
||||
};
|
||||
|
||||
doInstallCheck = true;
|
||||
|
||||
installCheckPhase = ''
|
||||
$out/bin/git-dependency-branch
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
use rand::Rng;
|
||||
|
||||
fn main() {
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
// Always draw zero :).
|
||||
let roll: u8 = rng.gen_range(0..1);
|
||||
assert_eq!(roll, 0);
|
||||
}
|
||||
638
pkgs/build-support/rust/test/import-cargo-lock/git-dependency-rev-non-workspace-nested-crate/Cargo.lock
generated
Normal file
638
pkgs/build-support/rust/test/import-cargo-lock/git-dependency-rev-non-workspace-nested-crate/Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,638 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "adler"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "cargo-test-macro"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rust-lang/cargo?branch=rust-1.53.0#4369396ce7d270972955d876eaa4954bea56bcd9"
|
||||
|
||||
[[package]]
|
||||
name = "cargo-test-support"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rust-lang/cargo?branch=rust-1.53.0#4369396ce7d270972955d876eaa4954bea56bcd9"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cargo-test-macro",
|
||||
"cargo-util",
|
||||
"filetime",
|
||||
"flate2",
|
||||
"git2",
|
||||
"glob",
|
||||
"lazy_static",
|
||||
"remove_dir_all",
|
||||
"serde_json",
|
||||
"tar",
|
||||
"toml",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cargo-util"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rust-lang/cargo?branch=rust-1.53.0#4369396ce7d270972955d876eaa4954bea56bcd9"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"core-foundation",
|
||||
"crypto-hash",
|
||||
"filetime",
|
||||
"hex 0.4.3",
|
||||
"jobserver",
|
||||
"libc",
|
||||
"log",
|
||||
"miow",
|
||||
"same-file",
|
||||
"shell-escape",
|
||||
"tempfile",
|
||||
"walkdir",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.71"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "commoncrypto"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007"
|
||||
dependencies = [
|
||||
"commoncrypto-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "commoncrypto-sys"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-hash"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a77162240fd97248d19a564a565eb563a3f592b386e4136fb300909e67dddca"
|
||||
dependencies = [
|
||||
"commoncrypto",
|
||||
"hex 0.3.2",
|
||||
"openssl",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "filetime"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "975ccf83d8d9d0d84682850a38c8169027be83368805971cc4f238c2b245bc98"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crc32fast",
|
||||
"libc",
|
||||
"libz-sys",
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
||||
dependencies = [
|
||||
"foreign-types-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types-shared"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191"
|
||||
dependencies = [
|
||||
"matches",
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "git-dependency-rev-non-workspace-nested-crate"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cargo-test-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "git2"
|
||||
version = "0.13.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a8057932925d3a9d9e4434ea016570d37420ddb1ceed45a174d577f24ed6700"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libc",
|
||||
"libgit2-sys",
|
||||
"log",
|
||||
"openssl-probe",
|
||||
"openssl-sys",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||
|
||||
[[package]]
|
||||
name = "hex"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77"
|
||||
|
||||
[[package]]
|
||||
name = "hex"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8"
|
||||
dependencies = [
|
||||
"matches",
|
||||
"unicode-bidi",
|
||||
"unicode-normalization",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "0.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
|
||||
|
||||
[[package]]
|
||||
name = "jobserver"
|
||||
version = "0.1.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.105"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "869d572136620d55835903746bcb5cdc54cb2851fd0aeec53220b4bb65ef3013"
|
||||
|
||||
[[package]]
|
||||
name = "libgit2-sys"
|
||||
version = "0.12.24+1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ddbd6021eef06fb289a8f54b3c2acfdd85ff2a585dfbb24b8576325373d2152c"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"libssh2-sys",
|
||||
"libz-sys",
|
||||
"openssl-sys",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libssh2-sys"
|
||||
version = "0.2.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b094a36eb4b8b8c8a7b4b8ae43b2944502be3e59cd87687595cf6b0a71b3f4ca"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"libz-sys",
|
||||
"openssl-sys",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libz-sys"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matches"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
|
||||
dependencies = [
|
||||
"adler",
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miow"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
|
||||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
version = "0.10.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d9facdb76fec0b73c406f125d44d86fdad818d66fef0531eec9233ca425ff4a"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"openssl-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-probe"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a"
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.67"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69df2d8dfc6ce3aaf44b40dec6f487d5a886516cf6879c49e98e0710f310a058"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cc",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10e2fcbb64ecbe64c8e040a386c3104d384583af58b956d870aaaf229df6e66d"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3ca011bd0129ff4ae15cd04c4eef202cadf6c51c21e47aba319b4e0501db741"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "remove_dir_all"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.130"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.68"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shell-escape"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f"
|
||||
|
||||
[[package]]
|
||||
name = "tar"
|
||||
version = "0.4.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6f5515d3add52e0bbdcad7b83c388bb36ba7b754dda3b5f5bc2d38640cdba5c"
|
||||
dependencies = [
|
||||
"filetime",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"rand",
|
||||
"redox_syscall",
|
||||
"remove_dir_all",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f83b2a3d4d9091d0abd7eba4dc2710b1718583bd4d8992e2190720ea38f391f7"
|
||||
dependencies = [
|
||||
"tinyvec_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec_macros"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9"
|
||||
dependencies = [
|
||||
"tinyvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c"
|
||||
dependencies = [
|
||||
"form_urlencoded",
|
||||
"idna",
|
||||
"matches",
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
|
||||
dependencies = [
|
||||
"same-file",
|
||||
"winapi",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "git-dependency-rev-non-workspace-nested-crate"
|
||||
version = "0.1.0"
|
||||
authors = ["Stefan Junker <mail@stefanjunker.de>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
cargo-test-support = { git = "https://github.com/rust-lang/cargo", branch = "rust-1.53.0" }
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
{ rustPlatform, pkg-config, openssl, lib, darwin, stdenv }:
|
||||
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "git-dependency-rev-non-workspace-nested-crate";
|
||||
version = "0.1.0";
|
||||
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
openssl
|
||||
] ++ lib.optionals stdenv.isDarwin [
|
||||
darwin.apple_sdk.frameworks.Security
|
||||
];
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
outputHashes = {
|
||||
"cargo-test-macro-0.1.0" = "1yy1y1d523xdzwg1gc77pigbcwsbawmy4b7vw8v21m7q957sk0c4";
|
||||
};
|
||||
};
|
||||
|
||||
doInstallCheck = true;
|
||||
|
||||
installCheckPhase = ''
|
||||
$out/bin/git-dependency-rev-non-workspace-nested-crate
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("{}", cargo_test_support::t!(Result::<&str, &str>::Ok("msg")));
|
||||
}
|
||||
81
pkgs/build-support/rust/test/import-cargo-lock/git-dependency-rev/Cargo.lock
generated
Normal file
81
pkgs/build-support/rust/test/import-cargo-lock/git-dependency-rev/Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "git-dependency-rev"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
source = "git+https://github.com/rust-random/rand.git?rev=0.8.3#6ecbe2626b2cc6110a25c97b1702b347574febc7"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/rust-random/rand.git?rev=0.8.3#6ecbe2626b2cc6110a25c97b1702b347574febc7"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.1"
|
||||
source = "git+https://github.com/rust-random/rand.git?rev=0.8.3#6ecbe2626b2cc6110a25c97b1702b347574febc7"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/rust-random/rand.git?rev=0.8.3#6ecbe2626b2cc6110a25c97b1702b347574febc7"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "git-dependency-rev"
|
||||
version = "0.1.0"
|
||||
authors = ["Daniël de Kok <me@danieldk.eu>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
rand = { git = "https://github.com/rust-random/rand.git", rev = "0.8.3" }
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
{ rustPlatform }:
|
||||
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "git-dependency-rev";
|
||||
version = "0.1.0";
|
||||
|
||||
src = ./.;
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
outputHashes = {
|
||||
"rand-0.8.3" = "0l3p174bpwia61vcvxz5mw65a13ri3wy94z04xrnyy5lzciykz4f";
|
||||
};
|
||||
};
|
||||
|
||||
doInstallCheck = true;
|
||||
|
||||
installCheckPhase = ''
|
||||
$out/bin/git-dependency-rev
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
use rand::Rng;
|
||||
|
||||
fn main() {
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
// Always draw zero :).
|
||||
let roll: u8 = rng.gen_range(0..1);
|
||||
assert_eq!(roll, 0);
|
||||
}
|
||||
81
pkgs/build-support/rust/test/import-cargo-lock/git-dependency-tag/Cargo.lock
generated
Normal file
81
pkgs/build-support/rust/test/import-cargo-lock/git-dependency-tag/Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "git-dependency-tag"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
source = "git+https://github.com/rust-random/rand.git?tag=0.8.3#6ecbe2626b2cc6110a25c97b1702b347574febc7"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/rust-random/rand.git?tag=0.8.3#6ecbe2626b2cc6110a25c97b1702b347574febc7"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.1"
|
||||
source = "git+https://github.com/rust-random/rand.git?tag=0.8.3#6ecbe2626b2cc6110a25c97b1702b347574febc7"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/rust-random/rand.git?tag=0.8.3#6ecbe2626b2cc6110a25c97b1702b347574febc7"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "git-dependency-tag"
|
||||
version = "0.1.0"
|
||||
authors = ["Daniël de Kok <me@danieldk.eu>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
rand = { git = "https://github.com/rust-random/rand.git", tag = "0.8.3" }
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
{ rustPlatform }:
|
||||
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "git-dependency-tag";
|
||||
version = "0.1.0";
|
||||
|
||||
src = ./.;
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
outputHashes = {
|
||||
"rand-0.8.3" = "0l3p174bpwia61vcvxz5mw65a13ri3wy94z04xrnyy5lzciykz4f";
|
||||
};
|
||||
};
|
||||
|
||||
doInstallCheck = true;
|
||||
|
||||
installCheckPhase = ''
|
||||
$out/bin/git-dependency-tag
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
use rand::Rng;
|
||||
|
||||
fn main() {
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
// Always draw zero :).
|
||||
let roll: u8 = rng.gen_range(0..1);
|
||||
assert_eq!(roll, 0);
|
||||
}
|
||||
81
pkgs/build-support/rust/test/import-cargo-lock/git-dependency/Cargo.lock
generated
Normal file
81
pkgs/build-support/rust/test/import-cargo-lock/git-dependency/Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "git-dependency"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
source = "git+https://github.com/rust-random/rand.git#f0e01ee0a7257753cc51b291f62666f4765923ef"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/rust-random/rand.git#f0e01ee0a7257753cc51b291f62666f4765923ef"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.2"
|
||||
source = "git+https://github.com/rust-random/rand.git#f0e01ee0a7257753cc51b291f62666f4765923ef"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/rust-random/rand.git#f0e01ee0a7257753cc51b291f62666f4765923ef"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "git-dependency"
|
||||
version = "0.1.0"
|
||||
authors = ["Daniël de Kok <me@danieldk.eu>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
rand = { git = "https://github.com/rust-random/rand.git" }
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
{ rustPlatform }:
|
||||
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "git-dependency";
|
||||
version = "0.1.0";
|
||||
|
||||
src = ./.;
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
outputHashes = {
|
||||
"rand-0.8.3" = "0ya2hia3cn31qa8894s3av2s8j5bjwb6yq92k0jsnlx7jid0jwqa";
|
||||
};
|
||||
};
|
||||
|
||||
doInstallCheck = true;
|
||||
|
||||
installCheckPhase = ''
|
||||
$out/bin/git-dependency
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
use rand::Rng;
|
||||
|
||||
fn main() {
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
// Always draw zero :).
|
||||
let roll: u8 = rng.gen_range(0..1);
|
||||
assert_eq!(roll, 0);
|
||||
}
|
||||
682
pkgs/build-support/rust/test/import-cargo-lock/maturin/Cargo.lock
generated
Normal file
682
pkgs/build-support/rust/test/import-cargo-lock/maturin/Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,682 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "ahash"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e"
|
||||
|
||||
[[package]]
|
||||
name = "assert_approx_eq"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c07dab4369547dbe5114677b33fbbf724971019f3818172d59a97a61c774ffd"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "const_fn"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6"
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"const_fn",
|
||||
"crossbeam-utils",
|
||||
"lazy_static",
|
||||
"memoffset",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cfg-if",
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctor"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8f45d9ad417bcef4817d614a501ab55cdd96a6fdb24f49aab89a54acfd66b19"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.1.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ghost"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a5bcf1bbeab73aa4cf2fde60a846858dc036163c7c33bec309f8d17de785479"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indoc"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47741a8bc60fb26eb8d6e0238bbb26d8575ff623fdc97b1a2c00c050b9684ed8"
|
||||
dependencies = [
|
||||
"indoc-impl",
|
||||
"proc-macro-hack",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indoc-impl"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce046d161f000fffde5f432a0d034d0341dc152643b2598ed5bfce44c4f3a8f0"
|
||||
dependencies = [
|
||||
"proc-macro-hack",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"unindent",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inventory"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f0f7efb804ec95e33db9ad49e4252f049e37e8b0a4652e3cd61f7999f2eff7f"
|
||||
dependencies = [
|
||||
"ctor",
|
||||
"ghost",
|
||||
"inventory-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inventory-impl"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75c094e94816723ab936484666968f5b58060492e880f3c8d00489a1e244fa51"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.86"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312"
|
||||
dependencies = [
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e9a41747ae4633fce5adffb4d2e81ffc5e89593cb19917f8fb2cc5ff76507bf"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-complex"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "747d632c0c558b87dbabbe6a82f3b4ae03720d0646ac5b7b4dae89394be5f2c5"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb"
|
||||
dependencies = [
|
||||
"instant",
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"instant",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "0.1.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880"
|
||||
dependencies = [
|
||||
"paste-impl",
|
||||
"proc-macro-hack",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste-impl"
|
||||
version = "0.1.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6"
|
||||
dependencies = [
|
||||
"proc-macro-hack",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-hack"
|
||||
version = "0.5.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proptest"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12e6c80c1139113c28ee4670dc50cc42915228b51f56a9e407f0ec60f966646f"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"byteorder",
|
||||
"lazy_static",
|
||||
"num-traits",
|
||||
"quick-error",
|
||||
"rand",
|
||||
"rand_chacha",
|
||||
"rand_xorshift",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyo3"
|
||||
version = "0.13.2"
|
||||
dependencies = [
|
||||
"assert_approx_eq",
|
||||
"cfg-if",
|
||||
"ctor",
|
||||
"hashbrown",
|
||||
"indoc",
|
||||
"inventory",
|
||||
"libc",
|
||||
"num-bigint",
|
||||
"num-complex",
|
||||
"parking_lot",
|
||||
"paste",
|
||||
"proptest",
|
||||
"pyo3",
|
||||
"pyo3-macros",
|
||||
"rustversion",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"trybuild",
|
||||
"unindent",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyo3-macros"
|
||||
version = "0.13.2"
|
||||
dependencies = [
|
||||
"pyo3-macros-backend",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyo3-macros-backend"
|
||||
version = "0.13.2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick-error"
|
||||
version = "1.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_xorshift"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"crossbeam-deque",
|
||||
"either",
|
||||
"rayon-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon-core"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"crossbeam-deque",
|
||||
"crossbeam-utils",
|
||||
"lazy_static",
|
||||
"num_cpus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581"
|
||||
|
||||
[[package]]
|
||||
name = "rustapi-module"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"pyo3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.123"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.123"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.62"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea1c6153794552ea7cf7cf63b1231a25de00ec90db326ba6264440fa08e31486"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "trybuild"
|
||||
version = "1.0.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99471a206425fba51842a9186315f32d91c56eadc21ea4c21f847b59cf778f8b"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"lazy_static",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"termcolor",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||
|
||||
[[package]]
|
||||
name = "unindent"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.9.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "word-count"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"pyo3",
|
||||
"rayon",
|
||||
]
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
{ lib
|
||||
, fetchFromGitHub
|
||||
, python3
|
||||
, rustPlatform
|
||||
}:
|
||||
|
||||
python3.pkgs.buildPythonPackage rec {
|
||||
pname = "word-count";
|
||||
version = "0.13.2";
|
||||
|
||||
format = "pyproject";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "PyO3";
|
||||
repo = "pyo3";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-NOMrrfo8WjlPhtGxWUOPJS/UDDdbLQRCXR++Zd6JmIA=";
|
||||
};
|
||||
|
||||
cargoDeps = rustPlatform.importCargoLock {
|
||||
lockFile = ./Cargo.lock;
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
cp ${./Cargo.lock} Cargo.lock
|
||||
'';
|
||||
|
||||
buildAndTestSubdir = "examples/word-count";
|
||||
|
||||
nativeBuildInputs = with rustPlatform; [
|
||||
cargoSetupHook
|
||||
maturinBuildHook
|
||||
];
|
||||
|
||||
pythonImportsCheck = [ "word_count" ];
|
||||
|
||||
meta = with lib; {
|
||||
description = "PyO3 word count example";
|
||||
homepage = "https://github.com/PyO3/pyo3";
|
||||
license = licenses.asl20;
|
||||
maintainers = [ ];
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue