2020-04-15 13:10:42 +00:00
|
|
|
{ cargo
|
2019-07-02 10:50:32 +00:00
|
|
|
, darwin
|
2020-04-15 13:10:42 +00:00
|
|
|
, fetchurl
|
|
|
|
, jq
|
|
|
|
, lib
|
|
|
|
, lndir
|
2019-07-02 10:50:32 +00:00
|
|
|
, remarshal
|
2023-07-14 09:21:27 +00:00
|
|
|
, formats
|
2020-04-15 13:10:42 +00:00
|
|
|
, rsync
|
2022-05-05 14:31:01 +00:00
|
|
|
, runCommandLocal
|
2019-07-02 10:50:32 +00:00
|
|
|
, rustc
|
2020-04-15 13:10:42 +00:00
|
|
|
, stdenv
|
|
|
|
, writeText
|
2019-11-13 14:18:08 +00:00
|
|
|
, zstd
|
2023-06-03 15:05:27 +00:00
|
|
|
, clippy
|
2024-05-16 17:39:16 +00:00
|
|
|
, pkgs
|
2020-04-15 13:10:42 +00:00
|
|
|
}@defaultBuildAttrs:
|
2019-06-13 11:26:19 +00:00
|
|
|
|
2019-08-28 17:21:13 +00:00
|
|
|
let
|
2023-07-14 09:21:27 +00:00
|
|
|
libb = import ./lib.nix { inherit lib writeText runCommandLocal remarshal formats; };
|
2019-11-19 20:10:53 +00:00
|
|
|
|
|
|
|
builtinz = builtins // import ./builtins
|
2023-07-14 09:21:27 +00:00
|
|
|
{ inherit lib writeText remarshal runCommandLocal formats; };
|
2020-04-15 13:10:42 +00:00
|
|
|
|
2019-11-18 13:49:27 +00:00
|
|
|
mkConfig = arg:
|
2024-05-16 17:39:16 +00:00
|
|
|
import ./config.nix { inherit lib arg libb builtinz pkgs; };
|
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 =
|
2022-03-28 16:35:59 +00:00
|
|
|
libb.findGitDependencies { inherit (config) cargolock gitAllRefs gitSubmodules; };
|
2020-04-15 13:10:42 +00:00
|
|
|
cargoconfig =
|
|
|
|
if builtinz.pathExists (toString config.root + "/.cargo/config")
|
2023-08-17 10:39:58 +00:00
|
|
|
then (config.root + "/.cargo/config")
|
2020-04-15 13:10:42 +00:00
|
|
|
else null;
|
|
|
|
build = args: import ./build.nix (
|
|
|
|
{
|
|
|
|
inherit gitDependencies;
|
|
|
|
version = config.packageVersion;
|
|
|
|
} // config.buildConfig // defaultBuildAttrs // args
|
|
|
|
);
|
|
|
|
|
|
|
|
# the dependencies from crates.io
|
|
|
|
buildDeps =
|
|
|
|
build
|
|
|
|
{
|
|
|
|
pname = "${config.packageName}-deps";
|
|
|
|
src = libb.dummySrc {
|
|
|
|
inherit cargoconfig;
|
2020-12-31 04:55:28 +00:00
|
|
|
inherit (config) cargolock cargotomls copySources copySourcesFrom;
|
2020-04-15 13:10:42 +00:00
|
|
|
};
|
|
|
|
inherit (config) userAttrs;
|
|
|
|
# TODO: custom cargoTestCommands should not be needed here
|
|
|
|
cargoTestCommands = map (cmd: "${cmd} || true") config.buildConfig.cargoTestCommands;
|
|
|
|
copyTarget = true;
|
|
|
|
copyBins = false;
|
|
|
|
copyBinsFilter = ".";
|
|
|
|
copyDocsToSeparateOutput = false;
|
2022-05-15 08:48:34 +00:00
|
|
|
postInstall = false;
|
2020-04-15 13:10:42 +00:00
|
|
|
builtDependencies = [];
|
|
|
|
};
|
|
|
|
|
|
|
|
# the top-level build
|
|
|
|
buildTopLevel =
|
2020-10-08 10:51:54 +00:00
|
|
|
let
|
|
|
|
drv =
|
|
|
|
build
|
|
|
|
{
|
|
|
|
pname = config.packageName;
|
|
|
|
inherit (config) userAttrs src;
|
|
|
|
builtDependencies = lib.optional (! config.isSingleStep) buildDeps;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
drv.overrideAttrs config.overrideMain;
|
2020-04-15 13:10:42 +00:00
|
|
|
in
|
|
|
|
buildTopLevel;
|
2019-11-19 19:30:49 +00:00
|
|
|
in
|
2020-04-15 13:10:42 +00:00
|
|
|
{ inherit buildPackage; }
|