diff --git a/nixos/tests/spike.nix b/nixos/tests/spike.nix new file mode 100644 index 00000000000..47763e75ffa --- /dev/null +++ b/nixos/tests/spike.nix @@ -0,0 +1,22 @@ +import ./make-test-python.nix ({ pkgs, ... }: + +let + riscvPkgs = import ../.. { crossSystem = pkgs.stdenv.lib.systems.examples.riscv64-embedded; }; +in +{ + name = "spike"; + meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ blitz ]; }; + + machine = { pkgs, lib, ... }: { + environment.systemPackages = [ pkgs.spike riscvPkgs.riscv-pk riscvPkgs.hello ]; + }; + + # Run the RISC-V hello applications using the proxy kernel on the + # Spike emulator and see whether we get the expected output. + testScript = + '' + machine.wait_for_unit("multi-user.target") + output = machine.succeed("spike -m64 $(which pk) $(which hello)") + assert output == "Hello, world!\n" + ''; +}) diff --git a/pkgs/applications/virtualization/spike/default.nix b/pkgs/applications/virtualization/spike/default.nix new file mode 100644 index 00000000000..4dbb7fbe4a5 --- /dev/null +++ b/pkgs/applications/virtualization/spike/default.nix @@ -0,0 +1,30 @@ +{ stdenv, fetchgit, dtc }: + +stdenv.mkDerivation rec { + pname = "spike"; + version = "1.0.0"; + + src = fetchgit { + url = "https://github.com/riscv/riscv-isa-sim.git"; + rev = "v${version}"; + sha256 = "1hcl01nj96s3rkz4mrq747s5lkw81lgdjdimb8b1b9h8qnida7ww"; + }; + + nativeBuildInputs = [ dtc ]; + enableParallelBuilding = true; + + patchPhase = '' + patchShebangs scripts/*.sh + patchShebangs tests/ebreak.py + ''; + + doCheck = true; + + meta = with stdenv.lib; { + description = "A RISC-V ISA Simulator"; + homepage = "https://github.com/riscv/riscv-isa-sim"; + license = licenses.bsd3; + platforms = [ "x86_64-linux" "aarch64-linux" ]; + maintainers = with maintainers; [ blitz ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fb992084797..2114bd3ce1d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -20942,6 +20942,8 @@ in spice-vdagent = callPackage ../applications/virtualization/spice-vdagent { }; + spike = callPackage ../applications/virtualization/spike { }; + spideroak = callPackage ../applications/networking/spideroak { }; split2flac = callPackage ../applications/audio/split2flac { };