summaryrefslogtreecommitdiffstats
path: root/pkgs/applications/virtualization/rust-hypervisor-firmware
diff options
context:
space:
mode:
authorAstro <astro@spaceboyz.net>2023-03-26 01:29:36 +0100
committerAstro <astro@spaceboyz.net>2023-03-28 20:44:50 +0200
commit5cc9cef25d20a4d392a3076808763fcbfa9d0bf7 (patch)
treedaef364700fb9914a6f959db366c14483d316549 /pkgs/applications/virtualization/rust-hypervisor-firmware
parent0fc009e24c99846b7265d41904456a4c09abd0e1 (diff)
rust-hypervisor-firmware: init at 0.4.2
Diffstat (limited to 'pkgs/applications/virtualization/rust-hypervisor-firmware')
-rw-r--r--pkgs/applications/virtualization/rust-hypervisor-firmware/default.nix57
-rw-r--r--pkgs/applications/virtualization/rust-hypervisor-firmware/x86_64-unknown-none.json20
2 files changed, 77 insertions, 0 deletions
diff --git a/pkgs/applications/virtualization/rust-hypervisor-firmware/default.nix b/pkgs/applications/virtualization/rust-hypervisor-firmware/default.nix
new file mode 100644
index 000000000000..a4ab7c0805c8
--- /dev/null
+++ b/pkgs/applications/virtualization/rust-hypervisor-firmware/default.nix
@@ -0,0 +1,57 @@
+{ lib
+, fetchFromGitHub
+, makeRustPlatform
+, hostPlatform
+, targetPlatform
+, lld
+}:
+
+let
+ arch = targetPlatform.qemuArch;
+
+ target = ./. + "/${arch}-unknown-none.json";
+
+ cross = import ../../../.. {
+ system = hostPlatform.system;
+ crossSystem = lib.systems.examples."${arch}-embedded" // {
+ rustc.config = "${arch}-unknown-none";
+ rustc.platform = lib.importJSON target;
+ };
+ };
+
+ inherit (cross) rustPlatform;
+
+in
+
+rustPlatform.buildRustPackage rec {
+ pname = "rust-hypervisor-firmware";
+ version = "0.4.2";
+
+ src = fetchFromGitHub {
+ owner = "cloud-hypervisor";
+ repo = pname;
+ rev = version;
+ sha256 = "sha256-hKk5pcop8rb5Q+IVchcl+XhMc3DCBBPn5P+AkAb9XxI=";
+ };
+
+ cargoSha256 = "sha256-edi6/Md6KebKM3wHArZe1htUCg0/BqMVZKA4xEH25GI=";
+
+ RUSTC_BOOTSTRAP = 1;
+
+ nativeBuildInputs = [
+ lld
+ ];
+
+ RUSTFLAGS = "-C linker=lld -C linker-flavor=ld.lld";
+
+ # Tests don't work for `no_std`. See https://os.phil-opp.com/testing/
+ doCheck = false;
+
+ meta = with lib; {
+ homepage = "https://github.com/cloud-hypervisor/rust-hypervisor-firmware";
+ description = "A simple firmware that is designed to be launched from anything that supports loading ELF binaries and running them with the PVH booting standard";
+ license = with licenses; [ asl20 ];
+ maintainers = with maintainers; [ astro ];
+ platforms = [ "x86_64-none" ];
+ };
+}
diff --git a/pkgs/applications/virtualization/rust-hypervisor-firmware/x86_64-unknown-none.json b/pkgs/applications/virtualization/rust-hypervisor-firmware/x86_64-unknown-none.json
new file mode 100644
index 000000000000..f42155ae32ee
--- /dev/null
+++ b/pkgs/applications/virtualization/rust-hypervisor-firmware/x86_64-unknown-none.json
@@ -0,0 +1,20 @@
+{
+ "llvm-target": "x86_64-unknown-none",
+ "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
+ "arch": "x86_64",
+ "target-endian": "little",
+ "target-pointer-width": "64",
+ "target-c-int-width": "32",
+ "os": "none",
+ "executables": true,
+ "linker": "rust-lld",
+ "linker-flavor": "ld.lld",
+ "panic-strategy": "abort",
+ "disable-redzone": true,
+ "features": "-mmx,-sse,+soft-float",
+ "code-model": "small",
+ "relocation-model": "pic",
+ "pre-link-args": {
+ "ld.lld": ["--script=x86_64-unknown-none.ld"]
+ }
+}