1{
2 lib,
3 fetchFromGitHub,
4 stdenv,
5 lld,
6}:
7
8let
9 arch = stdenv.hostPlatform.qemuArch;
10
11 target = ./. + "/${arch}-unknown-none.json";
12
13in
14
15let
16 cross = import ../../../.. {
17 system = stdenv.hostPlatform.system;
18 crossSystem = lib.systems.examples."${arch}-embedded" // {
19 rust.rustcTarget = "${arch}-unknown-none";
20 rust.platform =
21 assert lib.assertMsg (builtins.pathExists target) "Target spec not found";
22 lib.importJSON target;
23 };
24 };
25
26 inherit (cross) rustPlatform;
27
28in
29
30rustPlatform.buildRustPackage rec {
31 pname = "rust-hypervisor-firmware";
32 version = "0.5.0";
33
34 src = fetchFromGitHub {
35 owner = "cloud-hypervisor";
36 repo = "rust-hypervisor-firmware";
37 tag = version;
38 sha256 = "sha256-iLYmPBJH7I6EJ8VTUbR0+lZaebvbZlRv2KglbjKX76Q=";
39 };
40
41 cargoHash = "sha256-iqsU4t8Zz9UTtAu+a6kqwnPZ6qdGAriQ7hcU58KDQ8M=";
42
43 # lld: error: unknown argument '-Wl,--undefined=AUDITABLE_VERSION_INFO'
44 # https://github.com/cloud-hypervisor/rust-hypervisor-firmware/issues/249
45 auditable = false;
46
47 RUSTC_BOOTSTRAP = 1;
48
49 nativeBuildInputs = [
50 lld
51 ];
52
53 RUSTFLAGS = "-C linker=lld -C linker-flavor=ld.lld";
54
55 # Tests don't work for `no_std`. See https://os.phil-opp.com/testing/
56 doCheck = false;
57
58 meta = with lib; {
59 homepage = "https://github.com/cloud-hypervisor/rust-hypervisor-firmware";
60 description = "Simple firmware that is designed to be launched from anything that supports loading ELF binaries and running them with the PVH booting standard";
61 license = with licenses; [ asl20 ];
62 maintainers = with maintainers; [ astro ];
63 platforms = [ "x86_64-none" ];
64 mainProgram = "hypervisor-fw";
65 };
66}