forked from includeos/IncludeOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault-cross.nix
More file actions
84 lines (62 loc) · 2.06 KB
/
default-cross.nix
File metadata and controls
84 lines (62 loc) · 2.06 KB
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
79
80
81
82
83
84
# ./default.nix
{
nixpkgs ? ./pinned.nix
, overlays ? [
( import ./overlay-cross.nix {inherit withCcache smp;} )
]
# default target, can also be passed via command line: --argstr target <string>
, target ? "x86_64"
# Enable ccache support. See overlay.nix for details.
, withCcache ? false
# WARN:
# None of the args listed below are used by this overlay,
# they only exist to provide compatability with the
# projects older *.nix files.
# Enable multicore suport.
, smp ? false
}:
let
# default nix packages, so we can perform asserts even if provided target doesn't exist
defaultNixpkgs = import nixpkgs {};
# cross compile configured nix packages
supportedTargets.pkgs = {
x86_64 = import nixpkgs {
overlays = overlays;
crossSystem = { config = "x86_64-unknown-linux-musl"; };
};
aarch64 = import nixpkgs {
overlays = overlays;
crossSystem = { config = "aarch64-unknown-linux-musl"; };
};
i686 = import nixpkgs {
overlays = overlays;
crossSystem = { config = "i686-unknown-linux-musl"; };
};
};
# Select pkgs configuration
pkgs = supportedTargets.pkgs.${target};
# assert helpers
supportedTargets.name = [
"x86_64"
"aarch64"
"i686"
];
supportedTargets.system = [
"x86_64-linux"
"aarch64-linux"
"i686-linux"
];
assertMsg = defaultNixpkgs.lib.asserts.assertMsg;
assertOneOf = defaultNixpkgs.lib.asserts.assertOneOf;
buildPlatform = pkgs.pkgsIncludeOS.stdenv.buildPlatform;
compilerEnv = pkgs.pkgsIncludeOS.stdenv.hostPlatform;
targetPlatform = pkgs.pkgsIncludeOS.stdenv.targetPlatform;
in
# WARN: this assert must be at the top, as an invalid target will break further execution.
assert assertOneOf "--argstr target <string>" "${target}" supportedTargets.name;
assert assertMsg buildPlatform.isLinux
"Currently only Linux builds are supported";
assert assertMsg compilerEnv.isMusl
"Stdenv should be based on Musl";
assert assertOneOf "crossSystem.system" targetPlatform.system supportedTargets.system;
pkgs.pkgsIncludeOS.includeos