diff --git a/pkgs/default.nix b/pkgs/default.nix index 41ec94f9..a257d6ac 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -28,7 +28,9 @@ container-hotplug = pkgs.callPackage ./container-hotplug {}; surfer = pkgs.callPackage ./surfer/default.nix {}; uf2conv = pkgs.callPackage ./uf2conv.nix {}; - sv-lang_6 = pkgs.callPackage ./sv-lang.nix {}; + + inherit (pkgs.callPackage ./sv-lang.nix {}) sv-lang_6 sv-lang_7; + sv-bugpoint = pkgs.callPackage ./sv-bugpoint.nix {sv-lang = sv-lang_7;}; veridian = pkgs.callPackage ./veridian/default.nix {inherit sv-lang_6;}; peakrdl = pkgs.callPackage ./peakrdl.nix {}; diff --git a/pkgs/sv-bugpoint.nix b/pkgs/sv-bugpoint.nix new file mode 100644 index 00000000..f0efd176 --- /dev/null +++ b/pkgs/sv-bugpoint.nix @@ -0,0 +1,48 @@ +# SPDX-FileCopyrightText: lowRISC contributors +# SPDX-License-Identifier: MIT +{ + lib, + stdenv, + fetchFromGitHub, + cmake, + ninja, + sv-lang, + fmt_10, + python3, +}: let + rev = "1e078fa961ac5ade9e2506ce63c091b53ad9dbdb"; +in + stdenv.mkDerivation { + pname = "sv-bugpoint"; + # take the first 10 characters of the revision + version = builtins.head (builtins.match "(.{10}).*" rev); + + src = fetchFromGitHub { + owner = "antmicro"; + repo = "sv-bugpoint"; + inherit rev; + hash = "sha256-HGWPtadi+L+cXHSWSPelOv0KOPnkjVGKchRaYfZwwFg="; + }; + + cmakeFlags = [ + "-DFETCHCONTENT_SOURCE_DIR_SLANG=${sv-lang.src.outPath}" + "-DFETCHCONTENT_SOURCE_DIR_FMT=${fmt_10.src.outPath}" + "-DSLANG_USE_MIMALLOC=OFF" + ]; + + nativeBuildInputs = [ + cmake + ninja + python3 + sv-lang + ]; + + meta = with lib; { + description = "Minimizes SystemVerilog code while preserving a user-defined property of that code."; + homepage = "https://github.com/antmicro/sv-bugpoint"; + license = licenses.asl20; + maintainers = []; + mainProgram = "sv-bugpoint"; + platforms = platforms.all; + }; + } diff --git a/pkgs/sv-lang.nix b/pkgs/sv-lang.nix index d43219a7..6648e32e 100644 --- a/pkgs/sv-lang.nix +++ b/pkgs/sv-lang.nix @@ -6,74 +6,67 @@ fetchFromGitHub, boost182, catch2_3, + fmt_10, cmake, ninja, python3, }: let - fmt = fetchFromGitHub { - owner = "fmtlib"; - repo = "fmt"; - rev = "10.2.1"; - hash = "sha256-pEltGLAHLZ3xypD/Ur4dWPWJ9BGVXwqQyKcDWVmC3co="; - }; - catch2 = fetchFromGitHub { - owner = "catchorg"; - repo = "Catch2"; - rev = "v3.5.3"; - hash = "sha256-A7vVRHMabm75Udy0fXwsPw4/JkXfjQq/MwmJukdS1Ic="; - }; -in - stdenv.mkDerivation rec { - pname = "sv-lang"; - version = "6.0"; + svLangDerivation = version: hash: + stdenv.mkDerivation rec { + pname = "sv-lang"; + inherit version; - src = fetchFromGitHub { - owner = "MikePopoloski"; - repo = "slang"; - rev = "v${version}"; - sha256 = "sha256-mT8sfUz0H4jWM/SkV/uW4kmVKE9UQy6XieG65yJvIA8="; - }; + src = fetchFromGitHub { + owner = "MikePopoloski"; + repo = "slang"; + rev = "v${version}"; + inherit hash; + }; - cmakeFlags = [ - # fix for https://github.com/NixOS/nixpkgs/issues/144170 - "-DCMAKE_INSTALL_INCLUDEDIR=include" - "-DCMAKE_INSTALL_LIBDIR=lib" + cmakeFlags = [ + # fix for https://github.com/NixOS/nixpkgs/issues/144170 + "-DCMAKE_INSTALL_INCLUDEDIR=include" + "-DCMAKE_INSTALL_LIBDIR=lib" - "-DFETCHCONTENT_SOURCE_DIR_FMT=${fmt}" - "-DFETCHCONTENT_SOURCE_DIR_CATCH2=${catch2}" + "-DFETCHCONTENT_SOURCE_DIR_FMT=${fmt_10.src.outPath}" + "-DFETCHCONTENT_SOURCE_DIR_CATCH2=${catch2_3.src.outPath}" - "-DSLANG_INCLUDE_TESTS=${ - if doCheck - then "ON" - else "OFF" - }" - "-DSLANG_USE_MIMALLOC=OFF" - ]; + "-DSLANG_INCLUDE_TESTS=${ + if doCheck + then "ON" + else "OFF" + }" + "-DSLANG_USE_MIMALLOC=OFF" + ]; - nativeBuildInputs = [ - cmake - python3 - ninja + nativeBuildInputs = [ + cmake + python3 + ninja - # though only used in tests, cmake will complain its absence when configuring - catch2_3 - ]; + # though only used in tests, cmake will complain its absence when configuring + catch2_3 + ]; - buildInputs = [ - boost182 - ]; + buildInputs = [ + boost182 + ]; - # TODO: a mysterious linker error occurs when building the unittests on darwin. - # The error occurs when using catch2_3 in nixpkgs, not when fetching catch2_3 using CMake - doCheck = !stdenv.isDarwin; + # TODO: a mysterious linker error occurs when building the unittests on darwin. + # The error occurs when using catch2_3 in nixpkgs, not when fetching catch2_3 using CMake + doCheck = !stdenv.isDarwin; - meta = with lib; { - description = "SystemVerilog compiler and language services"; - homepage = "https://github.com/MikePopoloski/slang"; - license = licenses.mit; - maintainers = with maintainers; [sharzy]; - mainProgram = "slang"; - broken = stdenv.isDarwin; - platforms = platforms.all; + meta = with lib; { + description = "SystemVerilog compiler and language services"; + homepage = "https://github.com/MikePopoloski/slang"; + license = licenses.mit; + maintainers = with maintainers; [sharzy]; + mainProgram = "slang"; + broken = stdenv.isDarwin; + platforms = platforms.all; + }; }; - } +in { + sv-lang_6 = svLangDerivation "6.0" "sha256-mT8sfUz0H4jWM/SkV/uW4kmVKE9UQy6XieG65yJvIA8="; + sv-lang_7 = svLangDerivation "7.0" "sha256-msSc6jw2xbEZfOwtqwFEDIKcwf5SDKp+j15lVbNO98g="; +}