Merge branch 'nix'

This commit is contained in:
Sebastien Bourdeauducq 2018-08-24 19:03:52 +08:00
commit c9d8bd1566
8 changed files with 252 additions and 0 deletions

28
nix/README.rst Normal file
View File

@ -0,0 +1,28 @@
Install ARTIQ via the Nix Package Manager
=========================================
These instructions provide an alternative route to install ARTIQ for people who do not wish to use conda.
This sets up an environment suitable for using ARTIQ, including the ARTIQ-Python compiler, device drivers, and the graphical user interfaces. This works correctly on Linux, and partially works (but not to a level that we would consider usable) with WSL introduced in Windows 10.
ARTIQ firmware and gateware development tools (e.g. rustc, Migen) and ARTIQ core device flashing tools (OpenOCD, proxy bitstreams) are currently not available on Nix. Pull requests welcome!
* Install the Nix package manager
* many Linux distros already have a package for the `Nix package manager <http://nixos.org/nix/>`_
* for example: ``$ apt-get install nix``
* if you would like to install via sh
* $ ``wget https://nixos.org/nix/install``
* $ ``sh install``
* $ ``source ~/.nix-profile/etc/profile.d/nix.sh``
* $ ``git clone github.com/m-labs/artiq``
* $ ``cd artiq/nix``
* $ ``nix-env -i -f default.nix``
The above command will setup your entire environment. Note that it will compile LLVM and Clang, which uses a lot of CPU time and disk space.

79
nix/artiq.nix Normal file
View File

@ -0,0 +1,79 @@
{ stdenv, fetchFromGitHub, fetchsvn, python3Packages, qt5Full, binutils-or1k, llvm-or1k, llvmlite, python3 }:
let
levenshtein = python3Packages.buildPythonPackage rec {
name = "levenshtein";
src = fetchFromGitHub {
owner = "ztane";
repo = "python-Levenshtein";
rev = "854e61a05bb8b750e990add96df412cd5448b75e";
sha256 = "1yf21kg1g2ivm5a4dx1jra9k0c33np54d0hk5ymnfyc4f6pg386q";
};
doCheck = false;
};
pythonparser = python3Packages.buildPythonPackage rec {
name = "pythonparser";
src = fetchFromGitHub {
owner = "m-labs";
repo = "pythonparser";
rev = "5b391fe86f43bb9f4f96c5bc0532e2a112db2936";
sha256 = "1gw1fk4y2l6bwq0fg2a9dfc1rvq8cv492dyil96amjdhsxvnx35b";
};
propagatedBuildInputs = with python3Packages; [ regex ];
doCheck = false;
};
asyncserial = python3Packages.buildPythonPackage rec {
name = "asyncserial";
src = fetchFromGitHub {
owner = "m-labs";
repo = "asyncserial";
rev = "d95bc1d6c791b0e9785935d2f62f628eb5cdf98d";
sha256 = "0yzkka9jk3612v8gx748x6ziwykq5lr7zmr9wzkcls0v2yilqx9k";
};
propagatedBuildInputs = with python3Packages; [ pyserial ];
doCheck = false;
};
quamash = python3Packages.buildPythonPackage rec {
name = "quamash";
src = fetchFromGitHub {
owner = "harvimt";
repo = "quamash";
rev = "bbab9e30e10b71a95687b03a93524173fb7b43f0";
sha256 = "08hp2q4ifj6z2ww05c7zsy0cd732k9rnaims1j43vr4hhxx950mk";
};
propagatedBuildInputs = with python3Packages; [ pyqt5 ];
doCheck = false;
};
pyqtgraph-qt5 = python3Packages.buildPythonPackage rec {
name = "pyqtgraph_qt5-${version}";
version = "0.10.0";
doCheck = false;
src = fetchFromGitHub {
owner = "pyqtgraph";
repo = "pyqtgraph";
rev = "1426e334e1d20542400d77c72c132b04c6d17ddb";
sha256 = "1079haxyr316jf0wpirxdj0ry6j8mr16cqr0dyyrd5cnxwl7zssh";
};
propagatedBuildInputs = with python3Packages; [ scipy numpy pyqt5 pyopengl ];
};
in
python3Packages.buildPythonPackage rec {
name = "artiq";
src = ./..;
propagatedBuildInputs = with python3Packages; [ binutils-or1k llvm-or1k llvmlite levenshtein pyqtgraph-qt5 aiohttp pygit2 pythonparser numpy dateutil quamash scipy prettytable pyserial asyncserial h5py cython regex qt5Full pyqt5 ];
doCheck = false;
meta = with stdenv.lib; {
description = "";
homepage = https://m-labs/artiq;
license = licenses.lgpl3;
maintainers = [ maintainers.sjmackenzie ];
platforms = [ "x86_64-linux" ];
};
}

34
nix/binutils-or1k.nix Normal file
View File

@ -0,0 +1,34 @@
{ stdenv, buildPackages
, fetchurl, zlib
}:
stdenv.mkDerivation rec {
basename = "binutils";
platform = "or1k";
version = "2.30";
name = "${basename}_${platform}-${version}";
src = fetchurl {
url = "https://ftp.gnu.org/gnu/binutils/binutils-${version}.tar.bz2";
sha256 = "028cklfqaab24glva1ks2aqa1zxa6w6xmc8q34zs1sb7h22dxspg";
};
configureFlags =
[ "--enable-shared" "--enable-deterministic-archives" "--target=or1k-linux"];
outputs = [ "out" "info" "man" ];
depsBuildBuild = [ buildPackages.stdenv.cc ];
buildInputs = [ zlib ];
enableParallelBuilding = true;
meta = {
description = "Tools for manipulating binaries (linker, assembler, etc.)";
longDescription = ''
The GNU Binutils are a collection of binary tools. The main
ones are `ld' (the GNU linker) and `as' (the GNU assembler).
They also include the BFD (Binary File Descriptor) library,
`gprof', `nm', `strip', etc.
'';
homepage = http://www.gnu.org/software/binutils/;
license = stdenv.lib.licenses.gpl3Plus;
/* Give binutils a lower priority than gcc-wrapper to prevent a
collision due to the ld/as wrappers/symlinks in the latter. */
priority = "10";
};
}

15
nix/default.nix Normal file
View File

@ -0,0 +1,15 @@
{system ? builtins.currentSystem}:
let
pkgs = import <nixpkgs> {inherit system;};
callPackage = pkgs.lib.callPackageWith (pkgs // self );
self = {
binutils-or1k = callPackage ./binutils-or1k.nix {};
llvm-src = callPackage ./fetch-llvm-clang.nix {};
llvm-or1k = callPackage ./llvm-or1k.nix {};
llvmlite = callPackage ./llvmlite.nix {};
artiq = callPackage ./artiq.nix { };
};
artiq = self.artiq;
in
artiq

22
nix/fetch-llvm-clang.nix Normal file
View File

@ -0,0 +1,22 @@
{ runCommand, fetchFromGitHub, git }:
let
llvm-src = fetchFromGitHub {
rev = "527aa86b578da5dfb9cf4510b71f0f46a11249f7";
owner = "m-labs";
repo = "llvm-or1k";
sha256 = "0lmcg9xj66pf4mb6racipw67vm8kwm84dl861hyqnywd61kvhrwa";
};
clang-src = fetchFromGitHub {
rev = "9e996136d52ed506ed8f57ef8b13b0f0f735e6a3";
owner = "m-labs";
repo = "clang-or1k";
sha256 = "0w5f450i76y162aswi2c7jip8x3arzljaxhbqp8qfdffm0rdbjp4";
};
in
runCommand "llvm_or1k_src" {}''
mkdir -p $out
mkdir -p $out/tools/clang
cp -r ${llvm-src}/* $out/
cp -r ${clang-src}/* $out/tools/clang
''

46
nix/llvm-or1k.nix Normal file
View File

@ -0,0 +1,46 @@
{ stdenv
, git
, llvm-src
, perl, groff, cmake, libxml2, python, libffi, valgrind
, ...
}:
stdenv.mkDerivation rec {
name = "llvm_or1k";
src = llvm-src;
buildInputs = [ perl groff cmake libxml2 python libffi ] ++ stdenv.lib.optional stdenv.isLinux valgrind;
preBuild = ''
NIX_BUILD_CORES=4
makeFlagsArray=(-j''$NIX_BUILD_CORES)
mkdir -p $out/
'';
cmakeFlags = with stdenv; [
"-DCMAKE_BUILD_TYPE=Release"
"-DLLVM_BUILD_LLVM_DYLIB=ON"
"-DLLVM_LINK_LLVM_DYLIB=ON"
"-DLLVM_TARGETS_TO_BUILD=X86"
"-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=OR1K"
"-DLLVM_ENABLE_ASSERTIONS=OFF"
"-DLLVM_INSTALL_UTILS=ON"
"-DLLVM_INCLUDE_TESTS=OFF"
"-DLLVM_INCLUDE_DOCS=OFF"
"-DLLVM_INCLUDE_EXAMPLES=OFF"
"-DCLANG_ENABLE_ARCMT=OFF"
"-DCLANG_ENABLE_STATIC_ANALYZER=OFF"
"-DCLANG_INCLUDE_TESTS=OFF"
"-DCLANG_INCLUDE_DOCS=OFF"
];
enableParallelBuilding = true;
meta = {
description = "Collection of modular and reusable compiler and toolchain technologies";
homepage = http://llvm.org/;
license = stdenv.lib.licenses.bsd3;
maintainers = with stdenv.lib.maintainers; [ sj_mackenzie ];
platforms = stdenv.lib.platforms.all;
};
}

20
nix/llvmlite.nix Normal file
View File

@ -0,0 +1,20 @@
{ stdenv, fetchgit, llvm-or1k, makeWrapper, python3, ncurses, zlib, python3Packages }:
let
version = "0f4ebae";
in
stdenv.mkDerivation rec {
name = "llvmlite-${version}";
src = fetchgit {
url = "https://github.com/m-labs/llvmlite";
rev = "401dfb713166bdd2bc0d3ab2b7ebf12e7a434130";
sha256 = "1ci1pnpspv1pqz712yix1nmplq7568vpsr6gzzl3a33w9s0sw2nq";
leaveDotGit = true;
};
buildInputs = [ makeWrapper python3 ncurses zlib llvm-or1k python3Packages.setuptools ];
installPhase = ''
LLVM_CONFIG=${llvm-or1k}/bin/llvm-config
python3 setup.py install --prefix=$out
'';
}

8
nix/shell.nix Normal file
View File

@ -0,0 +1,8 @@
{system ? builtins.currentSystem}:
let
pkgs = import <nixpkgs> {inherit system;};
artiq = pkgs.callPackage ./default.nix {};
in
pkgs.mkShell {
buildInputs = [ artiq ];
}