naersk/default.nix

80 lines
2.1 KiB
Nix
Raw Permalink Normal View History

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
, 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
, 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
libb = import ./lib.nix { inherit lib writeText runCommandLocal remarshal formats; };
builtinz = builtins // import ./builtins
{ 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-18 13:49:27 +00:00
buildPackage = arg:
let
config = mkConfig arg;
gitDependencies =
libb.findGitDependencies { inherit (config) cargolock gitAllRefs gitSubmodules; };
2020-04-15 13:10:42 +00:00
cargoconfig =
if builtinz.pathExists (toString config.root + "/.cargo/config")
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;
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;
postInstall = false;
2020-04-15 13:10:42 +00:00
builtDependencies = [];
};
# the top-level build
buildTopLevel =
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;
in
2020-04-15 13:10:42 +00:00
{ inherit buildPackage; }