forked from nix-community/naersk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
78 lines (72 loc) · 2.08 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{ 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; }