mirror of
https://github.com/nix-community/naersk
synced 2024-11-10 06:04:17 +00:00
78789c30d6
Before https://github.com/nix-community/naersk/pull/300, our `builtinz.toTOML` used to return a string representing the serialized document which was later redirected into a file: https://github.com/nix-community/naersk/pull/300/files#diff-b6b537316f2d29c8faf178a110366796811d1bc72f694262c7d2efad79aa984bL238 Over that merge request, this was changed to return a path, to make it consistent with how nixpkgs' formatters work - but I haven't noticed one place that still _read_ the file instead of returning a path (which was fine before, since the code did `echo ... > ...`, but is not a correct thing to do for `cp`). Closes https://github.com/nix-community/naersk/issues/305.
78 lines
2.1 KiB
Nix
78 lines
2.1 KiB
Nix
{ cargo
|
|
, darwin
|
|
, fetchurl
|
|
, jq
|
|
, lib
|
|
, lndir
|
|
, remarshal
|
|
, formats
|
|
, rsync
|
|
, runCommandLocal
|
|
, rustc
|
|
, stdenv
|
|
, writeText
|
|
, zstd
|
|
, clippy
|
|
}@defaultBuildAttrs:
|
|
|
|
let
|
|
libb = import ./lib.nix { inherit lib writeText runCommandLocal remarshal formats; };
|
|
|
|
builtinz = builtins // import ./builtins
|
|
{ inherit lib writeText remarshal runCommandLocal formats; };
|
|
|
|
mkConfig = arg:
|
|
import ./config.nix { inherit lib arg libb builtinz; };
|
|
|
|
buildPackage = arg:
|
|
let
|
|
config = mkConfig arg;
|
|
gitDependencies =
|
|
libb.findGitDependencies { inherit (config) cargolock gitAllRefs gitSubmodules; };
|
|
cargoconfig =
|
|
if builtinz.pathExists (toString config.root + "/.cargo/config")
|
|
then (config.root + "/.cargo/config")
|
|
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;
|
|
};
|
|
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;
|
|
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;
|
|
in
|
|
buildTopLevel;
|
|
in
|
|
{ inherit buildPackage; }
|