@@ -0,0 +1,40 @@
1+{ lib, stdenv, fetchFromGitHub
2+, withPlatform ? "generic"
3+, withPayload ? null
4+, withFDT ? null
5+}:
6+
7+stdenv.mkDerivation rec {
8+ pname = "opensbi";
9+ version = "1.0";
10+
11+ src = fetchFromGitHub {
12+ owner = "riscv-software-src";
13+ repo = "opensbi";
14+ rev = "v${version}";
15+ sha256 = "sha256-OgzcH+RLU680qF3+lUiWFFbif6YtjIknJriGlRqcOGs=";
16+ };
17+
18+ installFlags = [
19+ "I=$(out)"
20+ ];
21+
22+ makeFlags = [
23+ "PLATFORM=${withPlatform}"
24+ ] ++ lib.optionals (withPayload != null) [
25+ "FW_PAYLOAD_PATH=${withPayload}"
26+ ] ++ lib.optionals (withFDT != null) [
27+ "FW_FDT_PATH=${withFDT}"
28+ ];
29+
30+ dontStrip = true;
31+ dontPatchELF = true;
32+
33+ meta = with lib; {
34+ description = "RISC-V Open Source Supervisor Binary Interface";
35+ homepage = "https://github.com/riscv-software-src/opensbi";
36+ license = licenses.bsd2;
37+ maintainers = with maintainers; [ ius nickcao zhaofengli ];
38+ platforms = [ "riscv64-linux" ];
39+ };
40+}