forked from marius851000/naersk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
default.nix
75 lines (69 loc) · 2 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
{ cargo
, darwin
, fetchurl
, jq
, lib
, lndir
, remarshal
, rsync
, runCommand
, rustc
, stdenv
, writeText
, zstd
}@defaultBuildAttrs:
let
libb = import ./lib.nix { inherit lib writeText runCommand remarshal; };
builtinz = builtins // import ./builtins
{ inherit lib writeText remarshal runCommand; };
mkConfig = arg:
import ./config.nix { inherit lib arg libb builtinz; };
buildPackage = arg:
let
config = mkConfig arg;
gitDependencies =
libb.findGitDependencies { inherit (config) cargotomls cargolock; };
cargoconfig =
if builtinz.pathExists (toString config.root + "/.cargo/config")
then builtins.readFile (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;
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; }