Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building nextpnr with nix flakes #1296

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "build nix flake"
on:
pull_request:
push:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: cachix/install-nix-action@v25
- run: nix build '.?submodules=1'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ install_manifest.txt
*.phys
*.dcp
*.bit
result
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

85 changes: 85 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
description = "A flake for the nextpnr FPGA place and route tool";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [];
};
# Define custom overrides or additional packages
myPythonPackages = pkgs.python3Packages.override {
overrides = self: super: {
apycula = super.apycula.override {
# Place any necessary overrides here
};
};
};
enableGui = false;
in
{
packages = {
nextpnr = pkgs.stdenv.mkDerivation {
pname = "nextpnr";
version = "0.6";
src = ./.;

nativeBuildInputs = [ pkgs.cmake ]
++ (pkgs.lib.optional enableGui pkgs.qt6.wrapQtAppsHook);
buildInputs = [
(pkgs.boost.override { python = pkgs.python3; enablePython = true; })
pkgs.python3
pkgs.eigen
myPythonPackages.apycula
pkgs.icestorm
pkgs.trellis
pkgs.tcl
pkgs.zlib
pkgs.capnproto
pkgs.lzma
pkgs.tk
pkgs.wget
] ++ (pkgs.lib.optional enableGui pkgs.qt6.qtbase)
++ (pkgs.lib.optional pkgs.stdenv.cc.isClang pkgs.llvmPackages.openmp);

cmakeFlags = [
"-DARCH=all"
"-DBUILD_TESTS=ON"
"-DICESTORM_INSTALL_PREFIX=${pkgs.icestorm}"
"-DTRELLIS_INSTALL_PREFIX=${pkgs.trellis}"
"-DTRELLIS_LIBDIR=${pkgs.trellis}/lib/trellis"
"-DGOWIN_BBA_EXECUTABLE=${myPythonPackages.apycula}/bin/gowin_bba"
"-DUSE_OPENMP=ON"
# warning: high RAM usage
"-DSERIALIZE_CHIPDBS=OFF"
] ++ (pkgs.lib.optional enableGui "-DBUILD_GUI=ON");

meta = with pkgs.lib; {
description = "Place and route tool for FPGAs";
homepage = "https://github.com/yosyshq/nextpnr";
license = licenses.isc;
platforms = platforms.all;
maintainers = with maintainers; [ ];
};
};
};

packages.default = self.packages.${system}.nextpnr;

devShell = pkgs.mkShell {
buildInputs = [ self.packages.${system}.default ];
RCoeurjoly marked this conversation as resolved.
Show resolved Hide resolved

shellHook = ''
export TRELLIS_INSTALL_PREFIX=${pkgs.trellis}
export ICESTORM_INSTALL_PREFIX=${pkgs.icestorm}
export QT_QPA_PLATFORM_PLUGIN_PATH="${pkgs.libsForQt5.qt5.qtbase.bin}/lib/qt-${pkgs.libsForQt5.qt5.qtbase.version}/plugins";
'';
};
});
}
48 changes: 0 additions & 48 deletions shell.nix

This file was deleted.