about summary refs log tree commit diff
path: root/pkgs/development/compilers/silice/default.nix
blob: 287862b5f2b8d26a4ea5b32d88561b5b0d6f469a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{ stdenv, fetchFromGitHub, lib
, cmake, pkg-config, openjdk
, libuuid, python3
, silice, yosys, nextpnr, verilator
, dfu-util, icestorm, trellis
}:

stdenv.mkDerivation rec {
  pname = "silice";
  version = "unstable-2022-08-05";

  src = fetchFromGitHub {
    owner = "sylefeb";
    repo = pname;
    rev = "e26662ac757151e5dd8c60c45291b44906b1299f";
    sha256 = "sha256-Q1JdgDlEErutZh0OfxYy5C4aVijFKlf6Hm5Iv+1jsj4=";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [
    cmake
    pkg-config
    openjdk
  ];
  buildInputs = [
    libuuid
  ];
  propagatedBuildInputs = [
    (python3.withPackages (p: with p; [ edalize ]))
  ];

  postPatch = ''
    patchShebangs antlr/antlr.sh
    # use nixpkgs version
    rm -r python/pybind11
  '';

  installPhase = ''
    make install
    mkdir -p $out
    cp -ar ../{bin,frameworks,lib} $out/
  '';

  passthru.tests =
    let
      testProject = project: stdenv.mkDerivation {
        name = "${silice.name}-test-${project}";
        nativeBuildInputs = [
          silice
          yosys
          nextpnr
          verilator
          dfu-util
          icestorm
          trellis
        ];
        src = "${src}/projects";
        sourceRoot = "projects/${project}";
        buildPhase = ''
          targets=$(cut -d " " -f 2 configs | tr -d '\r')
          for target in $targets ; do
            make $target ARGS="--no_program"
          done
        '';
        installPhase = ''
          mkdir $out
          for target in $targets ; do
            cp -r BUILD_$target $out/
          done
        '';
      };
    in {
      # a selection of test projects that build with the FPGA tools in
      # nixpkgs
      audio_sdcard_streamer = testProject "audio_sdcard_streamer";
      bram_interface = testProject "bram_interface";
      blinky = testProject "blinky";
      pipeline_sort = testProject "pipeline_sort";
    };

  meta = with lib; {
    description = "Open source language that simplifies prototyping and writing algorithms on FPGA architectures";
    homepage = "https://github.com/sylefeb/Silice";
    license = licenses.bsd2;
    maintainers = [ maintainers.astro ];
  };
}