├── container ├── workspaces │ └── .gitignore ├── Containerfile ├── Makefile └── README.md ├── nextpnr-chipdb-setup-hook.sh ├── yosys-setup-hook.sh ├── LICENSE ├── nix ├── fasm │ └── default.nix ├── prjxray.nix ├── nextpnr-xilinx.nix ├── nextpnr-xilinx-chipdb.nix └── yosys-synlig.nix ├── flake.lock ├── README.md └── flake.nix /container/workspaces/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /nextpnr-chipdb-setup-hook.sh: -------------------------------------------------------------------------------- 1 | addNextpnrChipdbPaths() { 2 | addToSearchPath NEXTPNR_XILINX_CHIPDB_DIR "$1/" 3 | } 4 | 5 | addEnvHooks "$targetOffset" addNextpnrChipdbPaths 6 | -------------------------------------------------------------------------------- /yosys-setup-hook.sh: -------------------------------------------------------------------------------- 1 | addYosysPluginPath() { 2 | addToSearchPath NIX_YOSYS_PLUGIN_DIRS "$1/share/yosys/plugins" 3 | } 4 | 5 | addEnvHooks "$targetOffset" addYosysPluginPath 6 | -------------------------------------------------------------------------------- /container/Containerfile: -------------------------------------------------------------------------------- 1 | FROM nixos/nix:latest 2 | 3 | ARG workdir=/workspaces 4 | 5 | RUN echo 'experimental-features = nix-command flakes' >> /etc/nix/nix.conf && mkdir $workdir && nix develop github:openxc7/toolchain-nix 6 | 7 | WORKDIR $workdir 8 | 9 | CMD ["nix", "develop", "github:openxc7/toolchain-nix"] 10 | -------------------------------------------------------------------------------- /container/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: run rebuild build clean 2 | 3 | OWNER:=openxc7 4 | CONTAINER:=$(OWNER)/toolchain-nix 5 | 6 | run: 7 | podman run --rm -v $(PWD)/workspaces:/workspaces -it $(CONTAINER) 8 | 9 | rebuild: clean build run 10 | 11 | build: 12 | podman build -t $(CONTAINER) -f Containerfile 13 | 14 | clean: 15 | podman rmi -f $(CONTAINER) 16 | -------------------------------------------------------------------------------- /container/README.md: -------------------------------------------------------------------------------- 1 | # Toolchain container for openXC7 FPGA Development 2 | 3 | ## How to use locally 4 | Please [install podman](https://podman.io/) on your machine. 5 | Podman is supported in Windows, MacOS and Linux and is free & open source. 6 | 7 | Run the following command once to build the local container image: 8 | ```shell 9 | # Build development environment container ... 10 | make build 11 | 12 | # .. and run it 13 | make run 14 | ``` 15 | 16 | ### Example usage ### 17 | To run the development environment locally and compile blinky (see [screen recording](https://youtu.be/3cs_hfdYNE4)): 18 | ```shell 19 | # Whenever you want to compile your project, enter the virtual machine 20 | make run 21 | # ...or to avoid using make: 22 | podman run --rm -v $PWD/workspaces:/workspaces -it openxc7/toolchain-nix 23 | 24 | # In the running container now 25 | git clone https://github.com/openXC7/demo-projects 26 | cd demo-projects/blinky-qmtech 27 | make 28 | exit 29 | 30 | # Back at your host machine you can now see the compiled bitstream 31 | ls -l workspaces/demo-projects/blinky-qmtech/blinky.bit 32 | ``` 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023, openXC7 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE.BSD 3-Clause License 22 | -------------------------------------------------------------------------------- /nix/fasm/default.nix: -------------------------------------------------------------------------------- 1 | # https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/python.section.md 2 | 3 | { lib 4 | , buildPythonPackage 5 | , fetchFromGitHub 6 | , pythonOlder 7 | , cmake 8 | , textx 9 | , cython 10 | , fetchpatch 11 | }: 12 | 13 | buildPythonPackage rec { 14 | name = "fasm"; 15 | version = "0.0.2.r98.g9a73d70"; 16 | format = "setuptools"; 17 | 18 | disabled = pythonOlder "3.7"; 19 | 20 | src = fetchFromGitHub { 21 | inherit name; 22 | owner = "openxc7"; 23 | repo = "fasm"; 24 | rev = "2f57ccb1727a120e8cacbb95c578f3c71bdcc95a"; 25 | hash = "sha256-ZytcNJvXs+GUSIrf4dtYl+Hc5kEQmeJP+3BQOmQImIw="; 26 | }; 27 | 28 | nativeBuildInputs = [ 29 | cmake 30 | cython 31 | ]; 32 | 33 | propagatedBuildInputs = [ 34 | textx 35 | ]; 36 | 37 | dontUseCmakeConfigure = true; 38 | 39 | # Broken upstream. 40 | # https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=python-fasm-git#n76 41 | doCheck = false; 42 | 43 | meta = with lib; { 44 | changelog = "https://github.com/chipsalliance/fasm/releases/tag/${version}"; 45 | homepage = "https://github.com/chipsalliance/fasm/"; 46 | description = "FPGA Assembly (FASM) Parser and Generator"; 47 | license = licenses.asl20; 48 | maintainers = with maintainers; [ jleightcap hansfbaier ]; 49 | }; 50 | } 51 | -------------------------------------------------------------------------------- /nix/prjxray.nix: -------------------------------------------------------------------------------- 1 | { stdenv, lib, fetchFromGitHub, cmake, git, python312Packages, eigen, python312 2 | , ... }: 3 | stdenv.mkDerivation rec { 4 | pname = "prjxray"; 5 | version = "bdbc665852b82f589ff775a8f6498542dbec0a07"; 6 | 7 | src = fetchFromGitHub { 8 | owner = "f4pga"; 9 | repo = "prjxray"; 10 | rev = "bdbc665852b82f589ff775a8f6498542dbec0a07"; 11 | fetchSubmodules = true; 12 | hash = "sha256-lV4o62lS7CMG0EYPhp9bTB4fg0hOixy8CC8yGxKhGQE="; 13 | }; 14 | 15 | nativeBuildInputs = [ cmake git ]; 16 | buildInputs = [ python312Packages.boost python312 eigen ]; 17 | 18 | patchPhase = '' 19 | sed -i 's/cmake /cmake -Wno-deprecated /g' Makefile 20 | sed -i '29 itarget_compile_options(libprjxray PUBLIC "-Wno-deprecated")' lib/CMakeLists.txt 21 | ''; 22 | 23 | installPhase = '' 24 | mkdir -p $out/bin 25 | cp -v tools/xc7frames2bit tools/bitread tools/xc7patch $out/bin 26 | cp -v $srcs/utils/fasm2frames.py $out/bin/fasm2frames 27 | chmod 755 $out/bin/fasm2frames 28 | cp -v $srcs/utils/bit2fasm.py $out/bin/bit2fasm 29 | chmod 755 $out/bin/bit2fasm 30 | mkdir -p $out/usr/share/python3/ 31 | cp -rv $srcs/prjxray $out/usr/share/python3/ 32 | ''; 33 | 34 | doCheck = false; 35 | 36 | meta = with lib; { 37 | description = "Xilinx series 7 FPGA bitstream documentation"; 38 | homepage = "https://github.com/f4pga/prjxray"; 39 | license = licenses.isc; 40 | platforms = platforms.all; 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /nix/nextpnr-xilinx.nix: -------------------------------------------------------------------------------- 1 | { stdenv, cmake, git, lib, fetchFromGitHub, python312Packages, python312, eigen 2 | , llvmPackages, ... }: 3 | stdenv.mkDerivation rec { 4 | pname = "nextpnr-xilinx"; 5 | version = "0.8.2"; 6 | 7 | src = fetchFromGitHub { 8 | owner = "openXC7"; 9 | repo = "nextpnr-xilinx"; 10 | rev = "3374e5a62b54dc346fd5f85188ed24075ddfd5fb"; 11 | hash = "sha256-gW3Z3Cd5/gfX7k/ekRHtPVlbhKszWah1L+HggMFKakA="; 12 | fetchSubmodules = true; 13 | }; 14 | 15 | nativeBuildInputs = [ cmake git ]; 16 | buildInputs = [ python312Packages.boost python312 eigen ] 17 | ++ (lib.optionals stdenv.cc.isClang [ llvmPackages.openmp ]); 18 | 19 | cmakeFlags = [ 20 | "-DCURRENT_GIT_VERSION=${lib.substring 0 7 src.rev}" 21 | "-DARCH=xilinx" 22 | "-DBUILD_GUI=OFF" 23 | "-DBUILD_TESTS=OFF" 24 | "-DUSE_OPENMP=ON" 25 | "-Wno-deprecated" 26 | ]; 27 | 28 | installPhase = '' 29 | mkdir -p $out/bin 30 | cp nextpnr-xilinx bbasm $out/bin/ 31 | mkdir -p $out/share/nextpnr/external 32 | cp -rv ../xilinx/external/prjxray-db $out/share/nextpnr/external/ 33 | cp -rv ../xilinx/external/nextpnr-xilinx-meta $out/share/nextpnr/external/ 34 | cp -rv ../xilinx/python/ $out/share/nextpnr/python/ 35 | cp ../xilinx/constids.inc $out/share/nextpnr 36 | ''; 37 | 38 | meta = with lib; { 39 | description = "Place and route tool for FPGAs"; 40 | homepage = "https://github.com/openXC7/nextpnr-xilinx"; 41 | license = licenses.isc; 42 | platforms = platforms.all; 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "flake-utils": { 4 | "inputs": { 5 | "systems": "systems" 6 | }, 7 | "locked": { 8 | "lastModified": 1710146030, 9 | "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", 10 | "owner": "numtide", 11 | "repo": "flake-utils", 12 | "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", 13 | "type": "github" 14 | }, 15 | "original": { 16 | "owner": "numtide", 17 | "repo": "flake-utils", 18 | "type": "github" 19 | } 20 | }, 21 | "nixpkgs": { 22 | "locked": { 23 | "lastModified": 1725634671, 24 | "narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=", 25 | "owner": "NixOS", 26 | "repo": "nixpkgs", 27 | "rev": "574d1eac1c200690e27b8eb4e24887f8df7ac27c", 28 | "type": "github" 29 | }, 30 | "original": { 31 | "id": "nixpkgs", 32 | "ref": "nixos-unstable", 33 | "type": "indirect" 34 | } 35 | }, 36 | "root": { 37 | "inputs": { 38 | "flake-utils": "flake-utils", 39 | "nixpkgs": "nixpkgs" 40 | } 41 | }, 42 | "systems": { 43 | "locked": { 44 | "lastModified": 1681028828, 45 | "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 46 | "owner": "nix-systems", 47 | "repo": "default", 48 | "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 49 | "type": "github" 50 | }, 51 | "original": { 52 | "owner": "nix-systems", 53 | "repo": "default", 54 | "type": "github" 55 | } 56 | } 57 | }, 58 | "root": "root", 59 | "version": 7 60 | } 61 | -------------------------------------------------------------------------------- /nix/nextpnr-xilinx-chipdb.nix: -------------------------------------------------------------------------------- 1 | { stdenv, nixpkgs, backend, nextpnr-xilinx, prjxray, pypy310, coreutils 2 | , findutils, gnused, gnugrep, ... }: 3 | 4 | stdenv.mkDerivation rec { 5 | pname = "nextpnr-xilinx-chipdb"; 6 | version = nextpnr-xilinx.version; 7 | inherit backend; 8 | 9 | src = "${nextpnr-xilinx.outPath}/share/nextpnr/external/prjxray-db"; 10 | # Don't try to unpack src, it already exists 11 | dontUnpack = true; 12 | 13 | buildInputs = 14 | [ prjxray nextpnr-xilinx pypy310 coreutils findutils gnused gnugrep ]; 15 | buildPhase = '' 16 | mkdir -p $out 17 | find ${src}/ -type d -name "*-*" -mindepth 1 -maxdepth 2 |\ 18 | sed -e 's,.*/\(.*\)-.*$,\1,g' -e 's,\./,,g' |\ 19 | sort |\ 20 | uniq >\ 21 | $out/footprints.txt 22 | 23 | touch $out/built-footprints.txt 24 | 25 | for i in `cat $out/footprints.txt` 26 | do 27 | if [[ $i = xc7a* ]]; then ARCH=artix7 28 | elif [[ $i = xc7k* ]]; then ARCH=kintex7 29 | elif [[ $i = xc7s* ]]; then ARCH=spartan7 30 | elif [[ $i = xc7z* ]]; then ARCH=zynq7 31 | else 32 | echo "unsupported architecture for footprint $i" 33 | exit 1 34 | fi 35 | 36 | if [[ $ARCH != "${backend}" ]]; then 37 | continue 38 | fi 39 | 40 | FIRST_SPEEDGRADE_DIR=`ls -d ${src}/$ARCH/$i-* | sort -n | head -1` 41 | FIRST_SPEEDGRADE=`echo $FIRST_SPEEDGRADE_DIR | tr '/' '\n' | tail -1` 42 | pypy3.10 ${nextpnr-xilinx}/share/nextpnr/python/bbaexport.py --device $FIRST_SPEEDGRADE --bba $i.bba 2>&1 43 | bbasm -l $i.bba $out/$i.bin 44 | echo $i >> $out/built-footprints.txt 45 | done 46 | 47 | mv -f $out/built-footprints.txt $out/footprints.txt 48 | 49 | # make the chipdb directory available 50 | mkdir -p $out/bin 51 | cat > $out/bin/get_chipdb_${backend}.sh < third_party/Build.yosys.mk << "EOF" 54 | t := yosys 55 | ts := ''$(call GetTargetStructName,''${t}) 56 | 57 | ''${ts}.src_dir := ''$(shell yosys-config --datdir/include) 58 | ''${ts}.mod_dir := ''${TOP_DIR}third_party/yosys_mod/ 59 | EOF 60 | 61 | make -j $NIX_BUILD_CORES build@systemverilog-plugin \ 62 | LDFLAGS="''$(yosys-config --ldflags --ldlibs)" 63 | runHook postBuild 64 | ''; 65 | 66 | # Check that the plugin can be loaded successfully and parse simple file. 67 | doCheck = true; 68 | checkPhase = '' 69 | runHook preCheck 70 | echo "module litmustest(); endmodule;" > litmustest.sv 71 | yosys -p "plugin -i build/release/systemverilog-plugin/systemverilog.so;\ 72 | read_systemverilog litmustest.sv" 73 | runHook postCheck 74 | ''; 75 | 76 | installPhase = '' 77 | runHook preInstall 78 | mkdir -p $out/share/yosys/plugins 79 | cp ./build/release/systemverilog-plugin/systemverilog.so \ 80 | $out/share/yosys/plugins/systemverilog.so 81 | runHook postInstall 82 | ''; 83 | 84 | meta = with lib; { 85 | description = "SystemVerilog support plugin for Yosys"; 86 | homepage = "https://github.com/chipsalliance/synlig"; 87 | license = licenses.asl20; 88 | maintainers = with maintainers; [ hzeller ]; 89 | platforms = platforms.all; 90 | }; 91 | }) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # openXC7 toolchain 2 | 3 | The openXC7 FPGA toolchain's integration with the Nix package manager offers precise control over software builds and dependencies, emphasizing reproducibility and configuration transparency. Conversely, the adaptation to a containerized environment using [Podman](https://podman.io/) or [Docker](https://www.docker.com/products/docker-desktop/) facilitates cross-platform operation, notably on Windows WSL and MacOS x86, and encapsulates the toolchain for consistent execution across varied systems. While Nix provides a robust, integrated environment, the container approach introduces portability and simplifies the toolchain's utilization for users less versed in Nix's specifics. 4 | 5 | ## How to use with Nix package manager 6 | 7 | 1. [Install the Nix package manager](https://nixos.org/download#download-nix) on your Linux distribution of choice 8 | (or [use NixOS](https://nixos.org/download.html)): 9 | ``` 10 | $ sh <(curl -L https://nixos.org/nix/install) --daemon 11 | ``` 12 | 13 | 2. Enable flakes: 14 | Add the following to `~/.config/nix/nix.conf` or `/etc/nix/nix.conf`: 15 | ``` 16 | experimental-features = nix-command flakes 17 | ``` 18 | 19 | 3. Then you will get a development shell with the complete toolchain with: 20 | ``` 21 | $ nix develop github:openxc7/toolchain-nix 22 | ``` 23 | 24 | 4. Compile and load a demo project onto an FPGA: 25 | ``` 26 | $ git clone https://github.com/openXC7/demo-projects 27 | $ cd demo-projects/blinky-qmtech 28 | $ make 29 | $ make program 30 | ``` 31 | 32 | ## How to use as a container 33 | ### `docker` 34 | To build a docker container for `x86_64-linux`, use: 35 | ``` 36 | $ nix build -L ".#dockerImage.x86_64-linux" 37 | ``` 38 | The resulting container is then the file `./result`, which you can install 39 | with: 40 | ``` 41 | $ docker image load --input result 42 | a7cd1bb3e14c: Loading layer [==================================================>] 2.34GB/2.34GB 43 | Loaded image: openxc7-docker:ifnarr8fs6vln2sbxwswrxlmwvxjmri0 44 | ``` 45 | You can then run this image with: 46 | ``` 47 | docker run -v ./demo-projects/:/work -it openxc7-docker:ifnarr8fs6vln2sbxwswrxlmwvxjmri0 48 | ``` 49 | 50 | ### `podman` 51 | To utilize the openXC7 FPGA toolchain in a Podman container, users must first ensure Podman is installed on their system. The process involves building the container image with the toolchain using a specific build command. Once the image is built, the toolchain is executed within the container through a run command. This containerized approach ensures a consistent development environment across various operating systems like Windows, MacOS (x86 only), and Linux, streamlining the deployment and usage of the toolchain. 52 | 53 | For installation and contaienr usage, please refer to the [detailed instructions](container). 54 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "Open RTL synthesis framework and tools"; 3 | nixConfig.bash-prompt = "[nix(openXC7)] "; 4 | 5 | # Nixpkgs / NixOS version to use. 6 | inputs.nixpkgs.url = "nixpkgs/nixos-unstable"; 7 | inputs.flake-utils.url = "github:numtide/flake-utils"; 8 | outputs = { self, nixpkgs, flake-utils, ... }: 9 | let 10 | 11 | # to work with older version of flakes 12 | lastModifiedDate = 13 | self.lastModifiedDate or self.lastModified or "19700101"; 14 | 15 | # Generate a user-friendly version number. 16 | version = builtins.substring 0 8 lastModifiedDate; 17 | 18 | # System types to support. 19 | supportedSystems = 20 | [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; 21 | 22 | # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. 23 | forAllSystems = nixpkgs.lib.genAttrs supportedSystems; 24 | 25 | # Nixpkgs instantiated for supported system types. 26 | nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); 27 | in { 28 | # Provide some binary packages for selected system types. 29 | packages = forAllSystems (system: 30 | let 31 | pkgs = nixpkgsFor.${system}; 32 | inherit (pkgs) lib callPackage stdenv fetchgit fetchFromGitHub; 33 | in rec { 34 | nextpnr-xilinx = callPackage ./nix/nextpnr-xilinx.nix { }; 35 | 36 | prjxray = callPackage ./nix/prjxray.nix { }; 37 | 38 | fasm = with pkgs; 39 | with python3Packages; 40 | callPackage ./nix/fasm { 41 | # NOTE(jleightcap): calling this package here is clucky. 42 | # contorted structure here to make the `nix/fasm` directory be 43 | # drop-in to upstream python-modules in nixpkgs. 44 | inherit buildPythonPackage pythonOlder textx cython fetchpatch; 45 | }; 46 | 47 | nextpnr-xilinx-chipdb = { 48 | artix7 = callPackage ./nix/nextpnr-xilinx-chipdb.nix { 49 | backend = "artix7"; 50 | nixpkgs = pkgs; 51 | inherit nextpnr-xilinx; 52 | inherit prjxray; 53 | }; 54 | kintex7 = callPackage ./nix/nextpnr-xilinx-chipdb.nix { 55 | backend = "kintex7"; 56 | nixpkgs = pkgs; 57 | inherit nextpnr-xilinx; 58 | inherit prjxray; 59 | }; 60 | spartan7 = callPackage ./nix/nextpnr-xilinx-chipdb.nix { 61 | backend = "spartan7"; 62 | nixpkgs = pkgs; 63 | inherit nextpnr-xilinx; 64 | inherit prjxray; 65 | } ; 66 | zynq7 = callPackage ./nix/nextpnr-xilinx-chipdb.nix { 67 | backend = "zynq7"; 68 | nixpkgs = pkgs; 69 | inherit nextpnr-xilinx; 70 | inherit prjxray; 71 | }; 72 | }; 73 | 74 | fpga-assembler = (builtins.getFlake "github:lromor/fpga-assembler/6ff89a2d53edc9d74a402c28096450473b67de13").packages.${system}.default; 75 | 76 | # disable yosys-synlig for now: synlig is not very good and it does not compile with recent yosys 77 | # yosys-synlig = callPackage ./nix/yosys-synlig.nix { }; 78 | }); 79 | 80 | # contains a mutually consistent set of packages for a full toolchain using nextpnr-xilinx. 81 | devShell = forAllSystems (system: 82 | nixpkgsFor.${system}.mkShell { 83 | buildInputs = (with self.packages.${system}; [ 84 | fasm 85 | fpga-assembler 86 | prjxray 87 | nextpnr-xilinx 88 | # disabled, see above 89 | # yosys-synlig 90 | ]) ++ (with nixpkgsFor.${system}; [ 91 | yosys 92 | ghdl 93 | yosys-ghdl 94 | openfpgaloader 95 | pypy310 96 | python312Packages.pyyaml 97 | python312Packages.textx 98 | python312Packages.simplejson 99 | python312Packages.intervaltree 100 | ]); 101 | 102 | shellHook = 103 | let mypkgs = self.packages.${system}; 104 | nixpkgs = nixpkgsFor.${system}; 105 | pyPkgPath = "/lib/python3.12/site-packages/:"; 106 | in nixpkgs.lib.concatStrings [ 107 | "export NEXTPNR_XILINX_DIR=" mypkgs.nextpnr-xilinx.outPath "\n" 108 | "export NEXTPNR_XILINX_PYTHON_DIR=" mypkgs.nextpnr-xilinx.outPath "/share/nextpnr/python/\n" 109 | "export PRJXRAY_DB_DIR=" mypkgs.nextpnr-xilinx.outPath "/share/nextpnr/external/prjxray-db\n" 110 | "export PRJXRAY_PYTHON_DIR=" mypkgs.prjxray.outPath "/usr/share/python3/\n" 111 | ''export PYTHONPATH=''$PYTHONPATH:''$PRJXRAY_PYTHON_DIR:'' 112 | mypkgs.fasm.outPath pyPkgPath 113 | nixpkgs.python312Packages.textx.outPath pyPkgPath 114 | nixpkgs.python312Packages.arpeggio.outPath pyPkgPath 115 | nixpkgs.python312Packages.pyyaml.outPath pyPkgPath 116 | nixpkgs.python312Packages.simplejson.outPath pyPkgPath 117 | nixpkgs.python312Packages.intervaltree.outPath pyPkgPath 118 | nixpkgs.python312Packages.sortedcontainers.outPath pyPkgPath 119 | "\n" 120 | "export PYPY3=" nixpkgs.pypy310.outPath "/bin/pypy3.10" 121 | ]; 122 | } 123 | ); 124 | 125 | dockerImage = forAllSystems (system: 126 | let 127 | pkgs = nixpkgsFor.${system}; 128 | mypkgs = self.packages.${system}; 129 | chipdb = mypkgs.nextpnr-xilinx-chipdb; 130 | pyPkgPath = "/lib/python3.10/site-packages/:"; 131 | in 132 | pkgs.dockerTools.buildImage { 133 | name = "openxc7-docker"; 134 | copyToRoot = pkgs.buildEnv { 135 | name = "image-root"; 136 | paths = self.devShell.${system}.buildInputs ++ (with pkgs; [ 137 | bashInteractive 138 | findutils 139 | gnused 140 | gnugrep 141 | coreutils 142 | gnumake 143 | python312 144 | ]) ++ (with chipdb; [ 145 | spartan7 146 | artix7 147 | kintex7 148 | zynq7 149 | ]); 150 | pathsToLink = [ "/bin" ] ++ (with pkgs.dockerTools; [ 151 | usrBinEnv 152 | binSh 153 | ]); 154 | }; 155 | 156 | runAsRoot = pkgs.lib.concatStrings [ '' 157 | #!${pkgs.runtimeShell} 158 | mkdir -p /work 159 | cat > /bin/devshell <