2019-07-02 10:50:32 +00:00
|
|
|
{ lib
|
|
|
|
, runCommand
|
|
|
|
, symlinkJoin
|
|
|
|
, stdenv
|
|
|
|
, writeText
|
|
|
|
, jq
|
|
|
|
, rsync
|
|
|
|
, darwin
|
|
|
|
, remarshal
|
|
|
|
, cargo
|
|
|
|
, rustc
|
2019-11-13 14:18:08 +00:00
|
|
|
, zstd
|
2019-11-21 09:34:16 +00:00
|
|
|
, fetchurl
|
2019-06-13 11:26:19 +00:00
|
|
|
}:
|
|
|
|
|
2019-08-28 17:21:13 +00:00
|
|
|
let
|
2019-11-18 15:16:46 +00:00
|
|
|
libb = import ./lib.nix { inherit lib writeText runCommand remarshal; };
|
2019-11-19 20:10:53 +00:00
|
|
|
|
|
|
|
defaultBuildAttrs = {
|
|
|
|
inherit
|
|
|
|
jq
|
|
|
|
runCommand
|
|
|
|
lib
|
|
|
|
darwin
|
|
|
|
writeText
|
|
|
|
stdenv
|
|
|
|
rsync
|
|
|
|
remarshal
|
|
|
|
symlinkJoin
|
|
|
|
cargo
|
|
|
|
rustc
|
|
|
|
zstd
|
2019-11-21 09:34:16 +00:00
|
|
|
fetchurl
|
2019-11-19 20:10:53 +00:00
|
|
|
;
|
|
|
|
};
|
|
|
|
|
|
|
|
builtinz = builtins // import ./builtins
|
|
|
|
{ inherit lib writeText remarshal runCommand; };
|
2019-11-18 15:16:46 +00:00
|
|
|
in
|
2019-11-19 19:30:49 +00:00
|
|
|
# Crate building
|
2019-11-18 13:59:14 +00:00
|
|
|
let
|
2019-11-18 13:49:27 +00:00
|
|
|
mkConfig = arg:
|
|
|
|
import ./config.nix { inherit lib arg libb builtinz; };
|
2019-11-19 20:10:53 +00:00
|
|
|
|
2019-11-18 13:49:27 +00:00
|
|
|
buildPackage = arg:
|
2019-11-19 19:30:49 +00:00
|
|
|
let
|
2019-11-19 20:10:53 +00:00
|
|
|
config = mkConfig arg;
|
2019-12-13 15:37:19 +00:00
|
|
|
gitDependencies =
|
2019-12-17 16:03:10 +00:00
|
|
|
libb.findGitDependencies { inherit (config) cargotomls; };
|
2019-11-19 19:30:49 +00:00
|
|
|
in
|
|
|
|
import ./build.nix
|
|
|
|
(
|
|
|
|
defaultBuildAttrs // {
|
|
|
|
pname = config.packageName;
|
|
|
|
version = config.packageVersion;
|
|
|
|
preBuild = lib.optionalString (!config.isSingleStep) ''
|
|
|
|
# Cargo uses mtime, and we write `src/lib.rs` and `src/main.rs`in
|
|
|
|
# the dep build step, so make sure cargo rebuilds stuff
|
|
|
|
if [ -f src/lib.rs ] ; then touch src/lib.rs; fi
|
|
|
|
if [ -f src/main.rs ] ; then touch src/main.rs; fi
|
|
|
|
'';
|
|
|
|
inherit (config) src cargoTestCommands copyTarget copyBins copyDocsToSeparateOutput;
|
2019-12-13 15:37:19 +00:00
|
|
|
inherit gitDependencies;
|
2019-11-19 19:30:49 +00:00
|
|
|
} // config.buildConfig // {
|
|
|
|
builtDependencies = lib.optional (! config.isSingleStep)
|
2019-11-18 13:49:27 +00:00
|
|
|
(
|
2019-11-19 19:30:49 +00:00
|
|
|
import ./build.nix
|
|
|
|
(
|
|
|
|
{
|
2019-12-13 15:37:19 +00:00
|
|
|
inherit gitDependencies;
|
2019-11-19 20:10:53 +00:00
|
|
|
src = libb.dummySrc {
|
|
|
|
cargoconfig =
|
2019-11-21 09:35:00 +00:00
|
|
|
if builtinz.pathExists (toString config.root + "/.cargo/config")
|
|
|
|
then builtins.readFile (config.root + "/.cargo/config")
|
2019-11-19 20:10:53 +00:00
|
|
|
else null;
|
|
|
|
cargolock = config.cargolock;
|
|
|
|
cargotomls = config.cargotomls;
|
|
|
|
inherit (config) patchedSources;
|
|
|
|
};
|
2019-11-19 19:30:49 +00:00
|
|
|
} // (
|
|
|
|
defaultBuildAttrs // {
|
|
|
|
pname = "${config.packageName}-deps";
|
|
|
|
version = config.packageVersion;
|
|
|
|
} // config.buildConfig // {
|
|
|
|
preBuild = "";
|
|
|
|
# TODO: custom cargoTestCommands should not be needed here
|
|
|
|
cargoTestCommands = map (cmd: "${cmd} || true") config.cargoTestCommands;
|
|
|
|
copyTarget = true;
|
|
|
|
copyBins = false;
|
|
|
|
copyDocsToSeparateOutput = false;
|
|
|
|
builtDependencies = [];
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
in
|
|
|
|
{ inherit buildPackage; }
|