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-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-08-28 17:21:13 +00:00
|
|
|
defaultBuildAttrs =
|
2019-07-04 14:34:33 +00:00
|
|
|
{ inherit
|
|
|
|
jq
|
|
|
|
runCommand
|
|
|
|
lib
|
|
|
|
darwin
|
|
|
|
writeText
|
|
|
|
stdenv
|
|
|
|
rsync
|
|
|
|
remarshal
|
|
|
|
symlinkJoin
|
|
|
|
cargo
|
2019-11-13 14:18:08 +00:00
|
|
|
rustc
|
|
|
|
zstd;
|
2019-11-18 15:16:46 +00:00
|
|
|
};
|
2019-08-28 17:21:13 +00:00
|
|
|
builtinz =
|
2019-07-04 14:34:33 +00:00
|
|
|
builtins //
|
2019-07-31 11:41:34 +00:00
|
|
|
import ./builtins
|
2019-11-18 15:16:46 +00:00
|
|
|
{ inherit lib writeText remarshal runCommand ; };
|
|
|
|
in
|
2019-06-13 11:26:19 +00:00
|
|
|
# Crate building
|
2019-11-18 13:59:14 +00:00
|
|
|
let
|
|
|
|
mkConfig = src: attrs:
|
|
|
|
import ./config.nix { inherit lib src attrs libb builtinz; };
|
|
|
|
buildPackage = src: attrs:
|
|
|
|
let config = (mkConfig src attrs); in
|
|
|
|
import ./build.nix src
|
|
|
|
(defaultBuildAttrs //
|
|
|
|
{ pname = config.packageName;
|
|
|
|
version = config.packageVersion;
|
2019-11-18 15:41:28 +00:00
|
|
|
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) cargoTestCommands copyTarget copyBins copyDocsToSeparateOutput ;
|
|
|
|
} // config.buildConfig //
|
2019-11-18 13:59:14 +00:00
|
|
|
{ builtDependencies = lib.optional (! config.isSingleStep)
|
|
|
|
(
|
|
|
|
import ./build.nix
|
|
|
|
(libb.dummySrc
|
|
|
|
{ cargoconfig =
|
|
|
|
if builtinz.pathExists (toString src + "/.cargo/config")
|
|
|
|
then builtins.readFile (src + "/.cargo/config")
|
|
|
|
else null;
|
|
|
|
cargolock = config.cargolock;
|
|
|
|
cargotomls = config.cargotomls;
|
|
|
|
inherit (config) patchedSources;
|
|
|
|
}
|
|
|
|
)
|
|
|
|
(defaultBuildAttrs //
|
|
|
|
{ pname = "${config.packageName}-deps";
|
|
|
|
version = config.packageVersion;
|
2019-11-18 15:41:28 +00:00
|
|
|
} // config.buildConfig //
|
2019-11-18 13:59:14 +00:00
|
|
|
{ preBuild = "";
|
2019-11-18 15:41:28 +00:00
|
|
|
# TODO: custom cargoTestCommands should not be needed here
|
2019-11-18 13:59:14 +00:00
|
|
|
cargoTestCommands = map (cmd: "${cmd} || true") config.cargoTestCommands;
|
|
|
|
copyTarget = true;
|
|
|
|
copyBins = false;
|
|
|
|
copyDocsToSeparateOutput = false;
|
2019-11-18 15:16:46 +00:00
|
|
|
builtDependencies = [];
|
2019-11-18 13:59:14 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
|
|
|
});
|
2019-11-18 15:16:46 +00:00
|
|
|
in { inherit buildPackage; }
|