This commit is contained in:
Roland Coeurjoly 2024-08-03 02:10:14 +02:00 committed by GitHub
commit 16444ee6b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 160 additions and 48 deletions

13
.github/workflows/nix.yml vendored Normal file
View File

@ -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
.gitignore vendored
View File

@ -44,3 +44,4 @@ install_manifest.txt
*.phys
*.dcp
*.bit
result

61
flake.lock Normal file
View File

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1709126324,
"narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "d465f4819400de7c8d874d50b982301f28a84605",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1709150264,
"narHash": "sha256-HofykKuisObPUfj0E9CJVfaMhawXkYx3G8UIFR/XQ38=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9099616b93301d5cf84274b184a3a5ec69e94e08",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

85
flake.nix Normal file
View File

@ -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 {
inputsFrom = [ self.packages.${system}.default ];
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";
'';
};
});
}

View File

@ -1,48 +0,0 @@
{ pkgs ? import (fetchTarball https://github.com/NixOS/nixpkgs/archive/23.05.tar.gz) {} }:
let
pythonPkgs = pkgs.python3Packages;
boostPython = pkgs.boost.override { python = pythonPkgs.python; enablePython = true; };
vscode = pkgs.vscode-with-extensions.override {
vscodeExtensions = with pkgs.vscode-extensions; [
bbenoist.nix
ms-vscode.cpptools
ms-vscode.cmake-tools
twxs.cmake
usernamehw.errorlens
llvm-vs-code-extensions.vscode-clangd
] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [
{
name = "VerilogHDL";
publisher = "mshr-h";
version = "1.11.4";
sha256 = "sha256-4JY0eaN2IkwHv8u8X6ejDXk6vT1qB4vJjWdIy8b/jj4=";
}
];
};
in pkgs.mkShell {
buildInputs = with pkgs; [
cmake
eigen
boostPython
pythonPkgs.python
pythonPkgs.apycula
libsForQt5.qt5.qtbase
llvmPackages.openmp
icestorm
trellis
mold
yosys
clang
valgrind
cling
gdb
vscode
];
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";
'';
}