Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
callPythonPackage = lib.callPackageWith (pkgs' // pypkgs');
in
{
pybind11_3 = callPythonPackage ./nix/pybind11_3.nix { };
cocotb = callPythonPackage ./nix/cocotb.nix {
ghdl =
if (lib.lists.any (el: el == pkgs'.system) pkgs'.ghdl-bin.meta.platforms) then
Expand Down
14 changes: 0 additions & 14 deletions nix/patches/yosys/abc-editline.patch

This file was deleted.

16 changes: 0 additions & 16 deletions nix/patches/yosys/new-bitwuzla.patch

This file was deleted.

46 changes: 0 additions & 46 deletions nix/patches/yosys/plugin-search-dirs.patch

This file was deleted.

21 changes: 21 additions & 0 deletions nix/pybind11_3.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2025 nix-eda Contributors
{
lib,
fetchPypi,
buildPythonPackage,
}:
buildPythonPackage rec {
pname = "pybind11";
version = "3.0.1";
format = "wheel";

src = fetchPypi {
pname = "pybind11";
inherit version;
inherit format;
dist = "py3";
python = "py3";
sha256 = "sha256-qo8KpuCpTTtkrfw49WDzPxXlib4hdeEDwKM8a85V7ok=";
};
}
4 changes: 2 additions & 2 deletions nix/yosys-eqy.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
yosys-sby,
python3,
makeBinaryWrapper,
version ? "0.54",
sha256 ? "sha256-Km6layPDTAfd6oWnztJRdbiFkJeVT0YU06xWb/ewAms=",
version ? "0.59",
sha256 ? "sha256-dDDU3ld4e3CcqLzCwcV+AU2C8ZNFStRLpqlD3fIfdMw=",
}:
yosys.stdenv.mkDerivation (finalAttrs: {
pname = "yosys-eqy";
Expand Down
4 changes: 2 additions & 2 deletions nix/yosys-sby.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
boolector,
z3,
yices,
version ? "0.54",
sha256 ? "sha256-onVeK23KgCodEoaUtfh3R0MraaXuoNuQ2BAX5k4RNis=",
version ? "0.59",
sha256 ? "sha256-WNJ390nN2+vjWGIc842e/5CX2wKI/cyo+NnuCfbHSbQ=",
}:
yosys.stdenv.mkDerivation (finalAttrs: {
pname = "yosys-sby";
Expand Down
77 changes: 43 additions & 34 deletions nix/yosys.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
libffi,
zlib,
fetchurl,
fetchGitHubSnapshot,
bash,
version ? "0.54",
sha256 ? "sha256-meKlZh6ZiiPHwQCvS7Y667lvE9XWgIaual8c6SDpeDw=",
version ? "0.59.1",
rev ? null,
sha256 ? "sha256-XUQu07i6kBR745OZU/UQTwGbRt/uZHKpBNRrcUP87Bo=",
darwin, # To fix codesigning issue for pyosys
# For environments
yosys,
Expand All @@ -48,12 +50,10 @@
makeBinaryWrapper,
}:
let
boost-python = boost.override {
python = python3;
enablePython = true;
};
yosys-python3-env = python3.withPackages (
ps: with ps; [
cxxheaderparser
pybind11_3
click
setuptools
wheel
Expand All @@ -71,14 +71,19 @@ let
"python"
];

src = fetchurl {
url = "https://github.com/YosysHQ/yosys/releases/download/v${version}/yosys.tar.gz";
inherit sha256;
};

unpackPhase = ''
tar -xzvC . -f ${finalAttrs.src}
'';
src =
if rev != null then
fetchGitHubSnapshot {
owner = "yosyshq";
repo = "yosys";
inherit rev;
hash = sha256;
}
else
fetchurl {
url = "https://github.com/YosysHQ/yosys/releases/download/v${version}/yosys.tar.gz";
inherit sha256;
};

nativeBuildInputs = [
pkg-config
Expand All @@ -92,7 +97,6 @@ let
libbsd
libffi
zlib
boost-python
];

buildInputs = [
Expand Down Expand Up @@ -121,15 +125,15 @@ let
postBuild = ''
cat <<SCRIPT > $out/bin/with_yosys_plugin_env
#!${bash}/bin/bash
export NIX_YOSYS_PLUGIN_DIRS='$out/share/yosys/plugins'
export YOSYS_PLUGIN_PATH='$out/share/yosys/plugins'
exec "\$@"
SCRIPT
chmod +x $out/bin/with_yosys_plugin_env
cp $out/bin/yosys $out/bin/yosys_with_plugins
wrapProgram $out/bin/yosys \
--set NIX_YOSYS_PLUGIN_DIRS $out/share/yosys/plugins
--suffix YOSYS_PLUGIN_PATH : $out/share/yosys/plugins
wrapProgram $out/bin/yosys_with_plugins \
--set NIX_YOSYS_PLUGIN_DIRS $out/share/yosys/plugins \
--suffix YOSYS_PLUGIN_PATH : $out/share/yosys/plugins \
${module_flags}
'';
inherit (yosys) passthru;
Expand All @@ -145,6 +149,23 @@ let
};
};

unpackPhase = ''
runHook preUnpack
if [ -d ${finalAttrs.src} ]; then
cp -r ${finalAttrs.src}/* .
chmod u+w -R .
else
tar -xzC . -f ${finalAttrs.src}
fi
runHook postUnpack
'';

configurePhase = ''
runHook preConfigure
CC=clang CXX=clang++ make config-clang
runHook postConfigure
'';

makeFlags = [
"PRETTY=0"
"PREFIX=${placeholder "out"}"
Expand All @@ -153,33 +174,21 @@ let
"ENABLE_YOSYS=1"
"ENABLE_PYOSYS=1"
"PYTHON_DESTDIR=${placeholder "python"}/${site-packages}"
"BOOST_PYTHON_LIB=${boost-python}/lib/libboost_${python3.pythonAttr}${clangStdenv.hostPlatform.extensions.sharedLibrary}"
];

patches = [
./patches/yosys/plugin-search-dirs.patch
"PYOSYS_USE_UV=0"
];

postPatch = ''
substituteInPlace ./Makefile \
--replace 'echo UNKNOWN' 'echo ${version}'

chmod +x ./misc/yosys-config.in
set -x
'';

postInstall = ''
python3 ./setup.py dist_info -o $python/${site-packages}
'';

doCheck = false;
enableParallelBuilding = true;

meta = with lib; {
meta = {
description = "Yosys Open SYnthesis Suite";
license = with licenses; [ mit ];
license = [ lib.licenses.mit ];
homepage = "https://www.yosyshq.com/";
platforms = platforms.all;
platforms = lib.platforms.all;
};
});
in
Expand Down
Loading