1{
2 lib,
3 stdenv,
4 buildGoModule,
5 fetchFromGitHub,
6 git,
7 Cocoa,
8 Virtualization,
9 sigtool,
10 testers,
11 linuxkit,
12}:
13
14buildGoModule rec {
15 pname = "linuxkit";
16 version = "1.5.2";
17
18 src = fetchFromGitHub {
19 owner = "linuxkit";
20 repo = "linuxkit";
21 rev = "v${version}";
22 sha256 = "sha256-M/M4m/vsvvtSDnNNy8p6x+xpv1QmVzyfPRf/BNBX7zA=";
23 };
24
25 vendorHash = null;
26
27 modRoot = "./src/cmd/linuxkit";
28
29 patches = [
30 ./darwin-os-version.patch
31 ./support-apple-11-sdk.patch
32 ];
33
34 # - On macOS, an executable must be signed with the right entitlement(s) to be
35 # able to use the Virtualization framework at runtime.
36 # - sigtool is allows us to validly sign such executables with a dummy
37 # authority.
38 nativeBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ sigtool ];
39 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
40 Cocoa
41 Virtualization
42 ];
43
44 ldflags = [
45 "-s"
46 "-w"
47 "-X github.com/linuxkit/linuxkit/src/cmd/linuxkit/version.Version=${version}"
48 ];
49
50 nativeCheckInputs = [ git ];
51
52 # - Because this package definition doesn't build using the source's Makefile,
53 # we must manually call the sign target.
54 # - The binary stripping that nixpkgs does by default in the
55 # fixup phase removes such signing and entitlements, so we have to sign
56 # after stripping.
57 # - Finally, at the start of the fixup phase, the working directory is
58 # $sourceRoot/src/cmd/linuxkit, so it's simpler to use the sign target from
59 # the Makefile in that directory rather than $sourceRoot/Makefile.
60 postFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
61 make sign LOCAL_TARGET=$out/bin/linuxkit
62 '';
63 passthru.tests.version = testers.testVersion {
64 package = linuxkit;
65 command = "linuxkit version";
66 };
67
68 meta = with lib; {
69 description = "Toolkit for building secure, portable and lean operating systems for containers";
70 mainProgram = "linuxkit";
71 license = licenses.asl20;
72 homepage = "https://github.com/linuxkit/linuxkit";
73 maintainers = with maintainers; [ nicknovitski ];
74 };
75}