diff options
Diffstat (limited to 'pkgs/development/compilers/yosys/default.nix')
-rw-r--r-- | pkgs/development/compilers/yosys/default.nix | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/pkgs/development/compilers/yosys/default.nix b/pkgs/development/compilers/yosys/default.nix index 8f7de8736264f..30b9b83939870 100644 --- a/pkgs/development/compilers/yosys/default.nix +++ b/pkgs/development/compilers/yosys/default.nix @@ -6,13 +6,19 @@ , fetchFromGitHub , flex , libffi +, makeWrapper , pkg-config , protobuf , python3 , readline +, symlinkJoin , tcl , verilog , zlib +, yosys +, yosys-bluespec +, yosys-ghdl +, yosys-symbiflow }: # NOTE: as of late 2020, yosys has switched to an automation robot that @@ -32,7 +38,39 @@ # yosys version number helps users report better bugs upstream, and is # ultimately less confusing than using dates. -stdenv.mkDerivation rec { +let + + # Provides a wrapper for creating a yosys with the specifed plugins preloaded + # + # Example: + # + # my_yosys = yosys.withPlugins (with yosys.allPlugins; [ + # fasm + # bluespec + # ]); + withPlugins = plugins: + let + paths = lib.closePropagation plugins; + module_flags = with builtins; concatStringsSep " " + (map (n: "--add-flags -m --add-flags ${n.plugin}") plugins); + in lib.appendToName "with-plugins" ( symlinkJoin { + inherit (yosys) name; + paths = paths ++ [ yosys ] ; + buildInputs = [ makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/yosys \ + --set NIX_YOSYS_PLUGIN_DIRS $out/share/yosys/plugins \ + ${module_flags} + ''; + }); + + allPlugins = { + bluespec = yosys-bluespec; + ghdl = yosys-ghdl; + } // (yosys-symbiflow); + + +in stdenv.mkDerivation rec { pname = "yosys"; version = "0.12+54"; @@ -99,6 +137,10 @@ stdenv.mkDerivation rec { setupHook = ./setup-hook.sh; + passthru = { + inherit withPlugins allPlugins; + }; + meta = with lib; { description = "Open RTL synthesis framework and tools"; homepage = "http://www.clifford.at/yosys/"; |