-
Notifications
You must be signed in to change notification settings - Fork 0
/
slang.nix
75 lines (66 loc) · 2.04 KB
/
slang.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{ lib, stdenv, slang-src, fetchFromGitHub
, cmake
, python3
, catch2_3
}:
let
getRev = src: src.shortRev or "dirty";
mkVer = src:
let
date = builtins.substring 0 8 (src.lastModifiedDate or src.lastModified or "19700101");
in
"g${date}_${getRev src}";
tag = "7.0";
version = "${tag}${mkVer slang-src}";
fmt_src = fetchFromGitHub {
owner = "fmtlib";
repo = "fmt";
rev = "11.0.2";
sha256 = "IKNt4xUoVi750zBti5iJJcCk3zivTt7nU12RIf8pM+0=";
};
# Drop for "catch2_3" once bump nixpkgs.
catch2_3_pinned = catch2_3.overrideAttrs(o:
let version = "3.7.1"; in {
src = fetchFromGitHub {
owner = "catchorg";
repo = "catch2";
rev = "v${version}";
sha256 = "Zt53Qtry99RAheeh7V24Csg/aMW25DT/3CN/h+BaeoM=";
};
inherit version;
});
in stdenv.mkDerivation {
pname = "slang";
inherit version;
nativeBuildInputs = [ cmake python3 ];
buildInputs = [ python3 catch2_3_pinned ];
src = slang-src;
patches = [
./patches/slang_git-don-t-fetch-fmt.patch
./patches/slang_git-pkgconfig.patch
];
postPatch = ''
ln -s ${fmt_src} external/fmt
substituteInPlace source/util/VersionInfo.cpp.in \
--subst-var SLANG_VERSION_MAJOR \
--subst-var SLANG_VERSION_MINOR \
--subst-var SLANG_VERSION_PATCH \
--subst-var SLANG_VERSION_HASH
substituteInPlace CMakeLists.txt \
--replace-fail 'VERSION ''${SLANG_VERSION_STRING}' \
'VERSION "${tag}"'
'';
SLANG_VERSION_MAJOR = lib.versions.major tag;
SLANG_VERSION_MINOR = lib.versions.minor tag;
SLANG_VERSION_PATCH = 0; # patch isn't safe if no patch level :(
SLANG_VERSION_HASH = getRev slang-src;
# Disable mimalloc, adding as build input isn't enough (?).
cmakeFlags = [ "-DSLANG_USE_MIMALLOC=OFF" ];
# TODO: tests
meta = with lib; {
description = "SystemVerilog compiler and language services";
homepage = "https://sv-lang.com";
license = with licenses; [ mit ]; # (ASL2.0 w/LLVM Exception)
maintainers = with maintainers; [ dtzWill ];
};
}