nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 boost,
6 catch2_3,
7 cmake,
8 ninja,
9 fmt,
10 mimalloc,
11 python3,
12}:
13
14stdenv.mkDerivation (finalAttrs: {
15 pname = "sv-lang";
16 version = "9.1";
17
18 src = fetchFromGitHub {
19 owner = "MikePopoloski";
20 repo = "slang";
21 tag = "v${finalAttrs.version}";
22 hash = "sha256-IfRh6F6vA+nFa+diPKD2aMv9kRbvVIY80IqX0d+d5JA=";
23 };
24
25 postPatch = ''
26 substituteInPlace external/CMakeLists.txt --replace-fail \
27 'set(mimalloc_min_version "2.2")' \
28 'set(mimalloc_min_version "${lib.versions.majorMinor mimalloc.version}")'
29 '';
30
31 cmakeFlags = [
32 # fix for https://github.com/NixOS/nixpkgs/issues/144170
33 "-DCMAKE_INSTALL_INCLUDEDIR=include"
34 "-DCMAKE_INSTALL_LIBDIR=lib"
35
36 "-DSLANG_INCLUDE_TESTS=${if finalAttrs.finalPackage.doCheck then "ON" else "OFF"}"
37 ];
38
39 nativeBuildInputs = [
40 cmake
41 python3
42 ninja
43 ];
44
45 strictDeps = true;
46
47 buildInputs = [
48 boost
49 fmt
50 mimalloc
51 # though only used in tests, cmake will complain its absence when configuring
52 catch2_3
53 ];
54
55 # TODO: a mysterious linker error occurs when building the unittests on darwin.
56 # The error occurs when using catch2_3 in nixpkgs, not when fetching catch2_3 using CMake
57 doCheck = !stdenv.hostPlatform.isDarwin;
58
59 meta = {
60 description = "SystemVerilog compiler and language services";
61 homepage = "https://github.com/MikePopoloski/slang";
62 license = lib.licenses.mit;
63 maintainers = with lib.maintainers; [ sharzy ];
64 mainProgram = "slang";
65 platforms = lib.platforms.all;
66 broken = stdenv.hostPlatform.isDarwin;
67 };
68})