naersk/default.nix

86 lines
2.3 KiB
Nix
Raw Normal View History

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-06-25 15:36:22 +00:00
with
2019-06-27 15:49:59 +00:00
{ libb = import ./lib.nix { inherit lib writeText runCommand remarshal; }; };
2019-06-25 15:36:22 +00:00
2019-08-28 17:21:13 +00:00
let
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-08-28 17:21:13 +00:00
}; in
2019-07-04 14:34:33 +00:00
2019-08-28 17:21:13 +00:00
let
builtinz =
2019-07-04 14:34:33 +00:00
builtins //
2019-07-31 11:41:34 +00:00
import ./builtins
2019-08-28 17:21:13 +00:00
{ inherit lib writeText remarshal runCommand ; }; in
2019-07-04 14:34:33 +00:00
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;
inherit (config) cratePaths crateDependencies preBuild cargoBuild cargoTestCommands compressTarget;
} //
(removeAttrs attrs [ "usePureFromTOML" "cargotomls" "singleStep" ]) //
{ 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;
inherit (config) cratePaths crateDependencies cargoBuild compressTarget;
} //
(removeAttrs attrs [ "usePureFromTOML" "cargotomls" "singleStep"]) //
{ preBuild = "";
cargoTestCommands = map (cmd: "${cmd} || true") config.cargoTestCommands;
copyTarget = true;
copyBins = false;
copyDocsToSeparateOutput = false;
}
)
);
});
in
{
inherit buildPackage;
2019-06-18 12:42:26 +00:00
}