From e45e92593d3f89baae5cbcb1d19fc2964efa70b9 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 29 Aug 2019 12:18:17 +0800 Subject: [PATCH] add nix-shell file for Glasgow --- shell.nix | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 shell.nix diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..08635d5 --- /dev/null +++ b/shell.nix @@ -0,0 +1,85 @@ +let + yosys_overlay = self: super: + rec { + yosys = super.yosys.overrideAttrs(oa: rec { + name = "yosys-${version}"; + version = "0.9"; + srcs = [ + (super.fetchFromGitHub { + owner = "yosyshq"; + repo = "yosys"; + rev = "yosys-${version}"; + sha256 = "0lb9r055h8y1vj2z8gm4ip0v06j5mk7f9zx9gi67kkqb7g4rhjli"; + name = "yosys"; + }) + # NOTE: the version of abc used here is synchronized with + # the one in the yosys Makefile of the version above; + # keep them the same for quality purposes. + (super.fetchFromGitHub { + owner = "berkeley-abc"; + repo = "abc"; + rev = "3709744c60696c5e3f4cc123939921ce8107fe04"; + sha256 = "18a9cjng3qfalq8m9az5ck1y5h4l2pf9ycrvkzs9hn82b1j7vrax"; + name = "yosys-abc"; + }) + ]; + buildInputs = oa.buildInputs ++ [ super.zlib ]; + }); + }; + pkgs = import { overlays = [ yosys_overlay ]; }; + fx2 = pkgs.python3Packages.buildPythonPackage rec { + pname = "fx2"; + version = "0.7"; + # not using Pypi as it lacks the firmware sources + src = pkgs.fetchFromGitHub { + owner = "whitequark"; + repo = "libfx2"; + rev = "v${version}"; + sha256 = "0xvlmx6ym0ylrvnlqzf18d475wa0mfci7wkdbv30gl3hgdhsppjz"; + }; + nativeBuildInputs = with pkgs; [ gnumake sdcc ]; + propagatedBuildInputs = with pkgs.python3Packages; [ libusb1 crcmod ]; + preBuild = '' + cd software + python setup.py build_ext + ''; + }; + nmigen = pkgs.python3Packages.buildPythonPackage { + name = "nmigen"; + version = "2019-08-26"; + src = pkgs.fetchFromGitHub { + owner = "m-labs"; + repo = "nmigen"; + rev = "2168ff512bfe04806b35c09d3b1d265a16c4ddbc"; + sha256 = "1zs2xkihdkvzy5lw5kr08aw9irjn4d1imalv49zxvf6zqanghx6z"; + }; + checkPhase = "PATH=${pkgs.yosys}/bin:${pkgs.symbiyosys}/bin:${pkgs.yices}/bin:$PATH python -m unittest discover nmigen.test -v"; + propagatedBuildInputs = with pkgs.python3Packages; [ bitarray pyvcd jinja2 ]; + }; + glasgow = pkgs.python3Packages.buildPythonApplication rec { + pname = "glasgow"; + version = "2019-08-28"; + src = pkgs.fetchFromGitHub { + owner = "GlasgowEmbedded"; + repo = "Glasgow"; + rev = "c103a8fc7945a0e46fb8b50fab63c51efe27e242"; + sha256 = "0mfzjf74w71yasbj9jvdx86ipc3wrmxiqa819b586k9dsskzgw32"; + fetchSubmodules = true; + }; + patches = [ ./glasgow-applet.diff ]; + nativeBuildInputs = with pkgs; [ gnumake sdcc ]; + propagatedBuildInputs = ( + [ fx2 nmigen ] ++ + (with pkgs.python3Packages; [ libusb1 aiohttp pyvcd bitarray crcmod ]) ++ + (with pkgs; [ yosys nextpnr icestorm ])); + preBuild = '' + cd software + python setup.py build_ext + ''; + # tests are currently broken since nMigen migration + doCheck = false; + }; +in + pkgs.mkShell { + buildInputs = [ glasgow pkgs.rustc pkgs.cargo ]; + }