diff --git a/packages/hxtorch/package.py b/packages/hxtorch/package.py
new file mode 100644
index 0000000000000000000000000000000000000000..36eb4e116d70b82c935d6b25ed42fd0c57a1b812
--- /dev/null
+++ b/packages/hxtorch/package.py
@@ -0,0 +1,135 @@
+# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+from spack import *
+
+
+class Hxtorch(WafPackage):
+    """hxtorch --- a PyTorch-based toplevel for the BrainScaleS-2 neuromorphic hardware systems"""
+
+    homepage = "https://github.com/electronicvisions/hxtorch"
+    # This repo provides a waf binary used for the build below
+    git      = "https://github.com/electronicvisions/pynn-brainscales.git"
+
+    version('2.0-rc5', branch='waf')
+
+    # PPU compiler dependencies
+    depends_on('oppulance@2.0:')
+
+    # host software dependencies
+    depends_on('bitsery', type=('build', 'link', 'run'))
+    depends_on('binutils+gold+ld+plugins', type=('build', 'link', 'run')) # specialize
+    depends_on('boost@1.69.0: +graph+icu+mpi+python+numpy+coroutine+context cxxstd=17', type=('build', 'link', 'run')) # specialize boost (non-clingo, type=('build', 'link', 'run'))
+    depends_on('cereal', type=('build', 'link', 'run'))
+    depends_on('cppcheck', type=('build', 'link', 'run'))
+    depends_on('doxygen+graphviz', type=('build', 'link', 'run'))
+    depends_on('genpybind@ebrains', type=('build', 'link', 'run'))
+    depends_on('gflags', type=('build', 'link', 'run'))
+    depends_on('googletest@1.11.0: +gmock', type=('build', 'link', 'run')) # variadic templates needed
+    depends_on('intel-tbb', type=('build', 'link', 'run'))  # ppu gdbserver
+    depends_on('libelf', type=('build', 'link', 'run'))
+    depends_on('liblockfile', type=('build', 'link', 'run'))
+    depends_on('llvm', type=('build', 'link', 'run'))
+    depends_on('log4cxx', type=('build', 'link', 'run'))
+    depends_on('pkg-config', type=('build', 'link', 'run'))
+    depends_on('python@3.7.0:', type=('build', 'link', 'run')) # BrainScaleS(-2, type=('build', 'link', 'run')) only supports Python >= 3.7
+    depends_on('py-h5py', type=('build', 'link', 'run')) # PyNN tests need it
+    depends_on('py-matplotlib', type=('build', 'link', 'run'))
+    depends_on('py-nose', type=('build', 'link', 'run'))
+    depends_on('py-numpy', type=('build', 'link', 'run'))
+    depends_on('py-pybind11', type=('build', 'link', 'run'))
+    depends_on('py-pybind11-stubgen', type=('build', 'link', 'run'))
+    depends_on('py-pycodestyle', type=('build', 'link', 'run'))
+    depends_on('py-pyelftools', type=('build', 'link', 'run'))
+    depends_on('py-pylint', type=('build', 'link', 'run'))
+    depends_on('py-pynn@0.9.4:', type=('build', 'link', 'run'))
+    depends_on('py-pyyaml', type=('build', 'link', 'run'))
+    depends_on('py-scipy', type=('build', 'link', 'run'))
+    depends_on('py-sqlalchemy', type=('build', 'link', 'run'))
+    depends_on('util-linux', type=('build', 'link', 'run'))
+    depends_on('yaml-cpp+shared', type=('build', 'link', 'run'))
+    extends('python')
+
+    def setup_build_environment(self, env):
+        """waf needs to find headers and libraries by itself (mostly `boost`
+        tool, but also `gtest`); it also needs to run executables during
+        configuration."""
+
+        include = []
+        for dep in self.spec.traverse(deptype='build'):
+            query = self.spec[dep.name]
+            try:
+                include.extend(query.headers.directories)
+                print('headers:', query.headers.directories, "\n")
+            except:
+                pass
+
+        library = []
+        for dep in self.spec.traverse(deptype=('link', 'run')):
+            query = self.spec[dep.name]
+            try:
+                library.extend(query.libs.directories)
+                print('libs:', query.libs.directories, "\n")
+            except:
+                pass
+
+        path = []
+        for dep in self.spec.traverse(deptype=('build', 'link', 'run')):
+            query = self.spec[dep.name]
+            try:
+                path.append(query.prefix.bin)
+                print('bin:', query.prefix.bin, "\n")
+            except:
+                pass
+
+        # llvm might be built with ~shared_libs but still builds shared libs
+        if not any('llvm' in lib for lib in library):
+            library.append(self.spec['llvm'].prefix.lib)
+
+        env.set('CPATH', ':'.join(include))
+        env.set('C_INCLUDE_PATH', ':'.join(include))
+        env.set('CPLUS_INCLUDE_PATH', ':'.join(include))
+        env.set('LIBRARY_PATH', ':'.join(library))
+        env.set('LD_LIBRARY_PATH', ':'.join(library))
+        env.prepend_path('PATH', ':'.join(path))
+
+    def setup_run_environment(self, env):
+        env.prepend_path('PYTHONPATH', self.prefix.lib)
+
+    # override configure step as we perform a project setup first
+    def configure(self, spec, prefix):
+        """Setup and configure the project."""
+
+        self.waf('setup', '--repo-db-url=https://github.com/electronicvisions/projects', '--without-munge',
+            '--project=hxtorch@ebrains-' + str(spec.version),
+            '--project=haldls@ebrains-' + str(spec.version),
+            '--project=grenade@ebrains-' + str(spec.version),
+            '--project=code-format@ebrains-' + str(spec.version),
+            '--project=logger@ebrains-' + str(spec.version),
+            '--project=halco@ebrains-' + str(spec.version),
+            '--project=hate@ebrains-' + str(spec.version),
+            '--project=fisch@ebrains-' + str(spec.version),
+            '--project=ztl@ebrains-' + str(spec.version),
+            '--project=hxcomm@ebrains-' + str(spec.version),
+            '--project=rant@ebrains-' + str(spec.version),
+            '--project=pywrap@ebrains-' + str(spec.version),
+            '--project=lib-boost-patches@ebrains-' + str(spec.version),
+            '--project=sctrltp@ebrains-' + str(spec.version),
+            '--project=hwdb@ebrains-' + str(spec.version),
+            '--project=visions-slurm@ebrains-' + str(spec.version),
+            '--project=flange@ebrains-' + str(spec.version),
+            '--project=lib-rcf@ebrains-' + str(spec.version),
+            '--project=bss-hw-params@ebrains-' + str(spec.version),
+            '--project=libnux@ebrains-' + str(spec.version)
+         )
+
+        args = ['--prefix={0}'.format(self.prefix)]
+        args += self.configure_args()
+
+        self.waf('configure', *args)
+
+    def build_args(self):
+        args = ['--keep', '--test-execnone', '-v']
+
+        return args
diff --git a/spack.yaml b/spack.yaml
index 60a65fdba64664f1a61367033aa31318d999fee5..009886d3e2a7576b26624467b004fe07bb5ab6e7 100644
--- a/spack.yaml
+++ b/spack.yaml
@@ -29,6 +29,7 @@ spack:
     - py-formencode
     - tvb-framework ^binutils+ld+gold
     - pynn-brainscales@2.0-rc5 ^log4cxx@0.10.0 ^googletest@1.11.0:+gmock
+    - hxtorch@2.0-rc5 ^log4cxx@0.10.0 ^googletest@1.11.0:+gmock
     - py-neo
     #- py-cerebstats
     #- py-cerebunit