about summary refs log tree commit diff
path: root/pkgs/applications/virtualization
diff options
context:
space:
mode:
authorRyan Lahfa <masterancpp@gmail.com>2023-03-28 22:27:21 +0200
committerGitHub <noreply@github.com>2023-03-28 22:27:21 +0200
commit7a25cbdf711c9886c315b3c1ce61c2f438a4fd91 (patch)
treec2c45ac5fd8ef0921d1747136ecaf645619ae380 /pkgs/applications/virtualization
parentfd46812f7e1145a6d178afcaf2d752d16a02e35f (diff)
parent5cc9cef25d20a4d392a3076808763fcbfa9d0bf7 (diff)
downloadnixlib-7a25cbdf711c9886c315b3c1ce61c2f438a4fd91.tar
nixlib-7a25cbdf711c9886c315b3c1ce61c2f438a4fd91.tar.gz
nixlib-7a25cbdf711c9886c315b3c1ce61c2f438a4fd91.tar.bz2
nixlib-7a25cbdf711c9886c315b3c1ce61c2f438a4fd91.tar.lz
nixlib-7a25cbdf711c9886c315b3c1ce61c2f438a4fd91.tar.xz
nixlib-7a25cbdf711c9886c315b3c1ce61c2f438a4fd91.tar.zst
nixlib-7a25cbdf711c9886c315b3c1ce61c2f438a4fd91.zip
Merge pull request #223168 from astro/rust-hypervisor-firmware
rust-hypervisor-firmware: init at 0.4.2
Diffstat (limited to 'pkgs/applications/virtualization')
-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"]
+  }
+}