diff --git a/nix/README.rst b/nix/README.rst
new file mode 100644
index 000000000..c2d6df2eb
--- /dev/null
+++ b/nix/README.rst
@@ -0,0 +1,22 @@
+Install ARTIQ via the Nix Package Manager
+===========================
+
+Nix does not support windows.
+
+* Install the nix package manager
+
+ * many linux distros already have a package for the `nix package manager `_
+
+ * for example: $ apt-get install nix
+
+ * if you would like to install via sh (please be sure you `understand `_ the dangers involved when curl piping to sh. Also ensure you have read the contents of the script and feel comfortable executing it. Otherwise there is the `manual `_)
+
+ * $ curl https://nixos.org/nix/install | sh
+
+ * $ 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.
diff --git a/nix/artiq.nix b/nix/artiq.nix
new file mode 100644
index 000000000..af5c20737
--- /dev/null
+++ b/nix/artiq.nix
@@ -0,0 +1,125 @@
+{ stdenv, fetchFromGitHub, fetchsvn, python35Packages, qt5Full, llvm-or1k, llvmlite, python35}:
+
+let
+
+levenshtein = python35Packages.buildPythonPackage rec {
+ name = "levenshtein";
+ src = fetchFromGitHub {
+ owner = "ztane";
+ repo = "python-Levenshtein";
+ rev = "854e61a05bb8b750e990add96df412cd5448b75e";
+ sha256 = "1yf21kg1g2ivm5a4dx1jra9k0c33np54d0hk5ymnfyc4f6pg386q";
+ };
+ doCheck = false;
+};
+
+sphinx-argparse = python35Packages.buildPythonPackage rec {
+ name = "sphinx-argparse";
+ src = fetchFromGitHub {
+ owner = "ribozz";
+ repo = "sphinx-argparse";
+ rev = "cc95938b8fbf870f7a5c012d4d84a29cfbac5e06";
+ sha256 = "1rsjlsnrpd4i4zx2sylilf6lfi77k0fclbhilrgx1m53ixllwg38";
+ };
+ buildInputs = with python35Packages; [ sphinx ];
+ doCheck = false;
+};
+
+pythonparser = python35Packages.buildPythonPackage rec {
+ name = "pythonparser";
+ src = fetchFromGitHub {
+ owner = "m-labs";
+ repo = "pythonparser";
+ rev = "8bdc7badbd08e2196b864e12889ea9191ca6e09c";
+ sha256 = "1f538wnjlqah0dsvq256k2rv7s7bffsvjcxy8fq0x3a4g0s6pm9d";
+ };
+ buildInputs = with python35Packages; [ regex ];
+ doCheck = false;
+};
+
+ml-pyserial = python35Packages.buildPythonPackage rec {
+ name = "pyserial";
+ src = fetchFromGitHub {
+ owner = "m-labs";
+ repo = "pyserial";
+ rev = "f30653b23f01c1cc27eb9731afc8ad66a723a4c0";
+ sha256 = "18xwsmpklggrm07b17ficpyjxnfgpw0k9lbz44nq4iflr8gmf33f";
+ };
+ buildInputs = with python35Packages; [ regex ];
+ doCheck = false;
+};
+
+pyqtgraph = python35Packages.buildPythonPackage rec {
+ name = "pyqtgraph";
+ src = fetchFromGitHub {
+ owner = "m-labs";
+ repo = "pyqtgraph";
+ rev = "8e9ee6fd3cabcc06d25cde5f13921e5d9d11c588";
+ sha256 = "0ynhsd4nlbz4pgwch0w767a9ybazn5f33rakpjdrcwldvrrrng6y";
+ };
+ buildInputs = with python35Packages; [ numpy ];
+ doCheck = false;
+};
+
+outputcheck = python35Packages.buildPythonPackage rec {
+ name = "outputcheck";
+ version = "0.4.2";
+ src = fetchFromGitHub {
+ owner = "stp";
+ repo = "OutputCheck";
+ rev = "e0f533d3c5af2949349856c711bf4bca50022b48";
+ sha256 = "1y27vz6jq6sywas07kz3v01sqjd0sga9yv9w2cksqac3v7wmf2a0";
+ };
+ prePatch = ''
+ substituteInPlace setup.py \
+ --replace "version.get_git_version()" "\"${version}\"" \
+ --replace "import version" ""
+ '';
+ doCheck = false;
+};
+
+quamash = python35Packages.buildPythonPackage rec {
+ name = "quamash";
+ src = fetchFromGitHub {
+ owner = "harvimt";
+ repo = "quamash";
+ rev = "bbab9e30e10b71a95687b03a93524173fb7b43f0";
+ sha256 = "08hp2q4ifj6z2ww05c7zsy0cd732k9rnaims1j43vr4hhxx950mk";
+ };
+ buildInputs = with python35Packages; [ pyqt5 ];
+ doCheck = false;
+};
+
+lit = python35Packages.buildPythonPackage rec {
+ name = "lit";
+ version = "262719";
+ source = fetchsvn {
+ url = "http://llvm.org/svn/llvm-project/llvm/trunk/";
+ rev = "${version}";
+ sha256 = "1iashczfh30v9ark4xijk6z2q07c1kb70nar00mwnfix77gkb2v6";
+ };
+ src = source + /utils/lit;
+ doCheck = false;
+};
+
+in
+
+python35Packages.buildPythonPackage rec {
+ version = "336482";
+ name = "artiq-${version}";
+ src = ./..;
+ buildInputs = with python35Packages; [
+ llvm-or1k llvmlite sphinx-argparse levenshtein
+ pyqtgraph aiohttp pygit2 pythonparser numpy
+ dateutil sphinx quamash scipy outputcheck
+ prettytable lit ml-pyserial h5py cython regex qt5Full pyqt5 ];
+ doCheck = false;
+ meta = with stdenv.lib; {
+ description = "";
+ homepage = https://m-labs/artiq;
+ license = licenses.gpl3;
+ maintainers = [ maintainers.sjmackenzie ];
+ platforms = [ "x86_64-linux" ];
+ };
+}
+
diff --git a/nix/binutils-or1k.nix b/nix/binutils-or1k.nix
new file mode 100644
index 000000000..0ebdbcd24
--- /dev/null
+++ b/nix/binutils-or1k.nix
@@ -0,0 +1,32 @@
+{ stdenv
+, fetchurl
+}:
+
+stdenv.mkDerivation rec {
+ basename = "binutils";
+ platform = "or1k";
+ version = "2.26";
+ name = "${basename}_${platform}-${version}";
+ src = fetchurl {
+ url = "https://ftp.gnu.org/gnu/binutils/${basename}-${version}.tar.bz2";
+ sha256 = "1ngc2h3knhiw8s22l8y6afycfaxr5grviqy7mwvm4bsl14cf9b62";
+ };
+ configureFlags =
+ [ "--enable-shared" "--enable-deterministic-archives" "--target=or1k-linux"];
+ 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";
+ };
+}
+
diff --git a/nix/default.nix b/nix/default.nix
new file mode 100644
index 000000000..3561ff763
--- /dev/null
+++ b/nix/default.nix
@@ -0,0 +1,15 @@
+{system ? builtins.currentSystem}:
+let
+ pkgs = import {inherit system;};
+ callPackage = pkgs.lib.callPackageWith (pkgs // self );
+
+self = {
+ binutils-ork1 = 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
diff --git a/nix/fetch-llvm-clang.nix b/nix/fetch-llvm-clang.nix
new file mode 100644
index 000000000..cb53f93d0
--- /dev/null
+++ b/nix/fetch-llvm-clang.nix
@@ -0,0 +1,22 @@
+{ runCommand, fetchFromGitHub, git }:
+
+let
+llvm-src = fetchFromGitHub {
+ rev = "ff2fe8c318eb7c934a2f2ac8da61a00d62becf1f";
+ owner = "openrisc";
+ repo = "llvm-or1k";
+ sha256 = "061pvc4z5i92s1xwz9ir6yqnk5vb0xd8cs9php4yy01dyvpblql7";
+};
+clang-src = fetchFromGitHub {
+ rev = "030259ccc14261d02163cce28adb0c11243d0a99";
+ owner = "openrisc";
+ repo = "clang-or1k";
+ sha256 = "1w7dk469svskr1c7ywcl9xsxbnvl40c28nffivpclijcvsh43463";
+};
+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
+''
diff --git a/nix/llvm-or1k.nix b/nix/llvm-or1k.nix
new file mode 100644
index 000000000..95d74061e
--- /dev/null
+++ b/nix/llvm-or1k.nix
@@ -0,0 +1,36 @@
+{ 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; [
+ "-DLLVM_TARGETS_TO_BUILD=OR1K;X86"
+ "-DCMAKE_BUILD_TYPE=Rel"
+ "-DLLVM_ENABLE_ASSERTIONS=ON"
+ "-DCMAKE_BUILD_TYPE=Release"
+ ];
+
+ 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;
+ };
+}
+
diff --git a/nix/llvmlite.nix b/nix/llvmlite.nix
new file mode 100644
index 000000000..4fd99a482
--- /dev/null
+++ b/nix/llvmlite.nix
@@ -0,0 +1,20 @@
+{ stdenv, fetchgit, llvm-or1k, makeWrapper, python35, ncurses, zlib }:
+let
+version = "0f4ebae";
+in
+stdenv.mkDerivation rec {
+ name = "llvmlite-${version}";
+ src = fetchgit {
+ url = "https://github.com/m-labs/llvmlite";
+ rev = "0f4ebae43c2d2a084deb8b693e3d42a7b2c82222";
+ sha256 = "0lnxxyjw2dapzqanms6jx64zxwhyrcria1yz49dzlb1306hzclj0";
+ leaveDotGit = true;
+ };
+
+ buildInputs = [ makeWrapper python35 ncurses zlib llvm-or1k];
+
+ installPhase = ''
+ LLVM_CONFIG=${llvm-or1k}/llvm_or1k/bin/llvm-config
+ python3 setup.py install --prefix=$out
+ '';
+}