diff --git a/glasgow.nix b/glasgow.nix new file mode 100644 index 0000000..801561c --- /dev/null +++ b/glasgow.nix @@ -0,0 +1,62 @@ +{ lib +, python3Packages +, fetchFromGitHub +, sdcc +, yosys +, icestorm +, nextpnr +}: + +with python3Packages; + +buildPythonApplication rec { + pname = "glasgow"; + version = "unstable-2019-08-31"; + realVersion = lib.substring 0 7 src.rev; + + src = fetchFromGitHub { + owner = "GlasgowEmbedded"; + repo = "Glasgow"; + rev = "21641a13c6a0daaf8618aff3c5bfffcb26ef6cca"; + sha256 = "1dpm1jmm4fg8xf17s6h9g5sc09gq8b6xq955sv2x11nrbqf98l4v"; + }; + + nativeBuildInputs = [ sdcc ]; + + propagatedBuildInputs = [ + nmigen + fx2 + libusb1 + aiohttp + pyvcd + bitarray + crcmod + ]; + + patches = [ ./glasgow-applet.diff ]; + postPatch = '' + substituteInPlace software/setup.py \ + --replace 'versioneer.get_version()' '"${realVersion}"' + ''; + + preBuild = '' + make -C firmware LIBFX2=${fx2}/share/libfx2 + cp firmware/glasgow.ihex software/glasgow + cd software + ''; + + # a couple failing tests and also installCheck tries to build_ext again + doInstallCheck = false; + doCheck = false; + + checkPhase = '' + python -m unittest discover + ''; + + meta = with lib; { + description = "Software for Glasgow, a digital interface multitool"; + homepage = https://github.com/GlasgowEmbedded/Glasgow; + license = licenses.bsd0; + maintainers = with maintainers; [ emily ]; + }; +} diff --git a/shell.nix b/shell.nix index 4cdec26..97b9cb0 100644 --- a/shell.nix +++ b/shell.nix @@ -1,58 +1,8 @@ +# This is for nixpkgs 19.09 + let pkgs = import { }; - fx2 = pkgs.python3Packages.buildPythonPackage rec { - pname = "fx2"; - version = "0.8"; - # not using Pypi as it lacks the firmware sources - src = pkgs.fetchFromGitHub { - owner = "whitequark"; - repo = "libfx2"; - rev = "v${version}"; - sha256 = "0b3zp50mschsxi2v3192dmnpw32gwblyl8aswlz9a0vx1qg3ibzn"; - }; - nativeBuildInputs = with pkgs; [ gnumake sdcc ]; - propagatedBuildInputs = with pkgs.python3Packages; [ libusb1 crcmod ]; - preBuild = '' - cd software - python setup.py build_ext - ''; - }; - nmigen = pkgs.python3Packages.buildPythonPackage rec { - name = "nmigen"; - version = "0.1rc1"; - src = pkgs.fetchgit { - url = "https://github.com/m-labs/nmigen"; - rev = "v${version}"; - sha256 = "002kyxazpc2azarfzahr17imizs0m9m5silggzx8yyy1kljxl796"; - leaveDotGit = true; - }; - checkPhase = "PATH=${pkgs.yosys}/bin:${pkgs.symbiyosys}/bin:${pkgs.yices}/bin:$PATH python -m unittest discover nmigen.test -v"; - nativeBuildInputs = with pkgs; [ python3Packages.setuptools_scm git ]; - propagatedBuildInputs = with pkgs.python3Packages; [ bitarray pyvcd jinja2 ]; - }; - glasgow = pkgs.python3Packages.buildPythonApplication rec { - pname = "glasgow"; - version = "2019-10-07"; - src = pkgs.fetchgit { - url = "https://github.com/GlasgowEmbedded/Glasgow"; - rev = "bfe49bebc4483b32eed8ec127a98a9fa2e77e7d4"; - sha256 = "0sh7l57pr49mmiqxq6g12pcln9h474gvlkfh3c439aqiv3p3jvyl"; - fetchSubmodules = true; - leaveDotGit = true; - }; - patches = [ ./glasgow-applet.diff ]; - nativeBuildInputs = with pkgs; [ python3Packages.setuptools_scm git gnumake sdcc ]; - propagatedBuildInputs = ( - [ fx2 nmigen ] ++ - (with pkgs.python3Packages; [ setuptools 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; - }; + glasgow = pkgs.callPackage ./glasgow.nix {}; pyqtgraph-qt5 = pkgs.python3Packages.buildPythonPackage rec { name = "pyqtgraph_qt5-${version}"; version = "0.10.0";