base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / ve / verible / package.nix
blob3ca60e332c8e4952acc319036f3ec7994cf41f13
2   lib,
3   stdenv,
4   buildBazelPackage,
5   fetchFromGitHub,
6   bazel_6,
7   jdk,
8   bison,
9   flex,
10   python3,
13 let
14   system = stdenv.hostPlatform.system;
16 buildBazelPackage rec {
17   pname = "verible";
19   # These environment variables are read in bazel/build-version.py to create
20   # a build string shown in the tools --version output.
21   # If env variables not set, it would attempt to extract it from .git/.
22   GIT_DATE = "2024-10-16";
23   GIT_VERSION = "v0.0-3836-g86ee9bab";
25   # Derive nix package version from GIT_VERSION: "v1.2-345-abcde" -> "1.2.345"
26   version = builtins.concatStringsSep "." (
27     lib.take 3 (lib.drop 1 (builtins.splitVersion GIT_VERSION))
28   );
30   src = fetchFromGitHub {
31     owner = "chipsalliance";
32     repo = "verible";
33     rev = "${GIT_VERSION}";
34     hash = "sha256-hV02x0b/taBqa6kyy3gvm3lomJrXBeelAbxrkC0s6EU=";
35   };
37   bazel = bazel_6;
38   bazelFlags = [
39     "--//bazel:use_local_flex_bison"
40   ];
42   fetchAttrs = {
43     hash = "sha256-bKASgc5KftCWtMvJkGA4nweBAtgdnyC9uXIJxPjKYS0=";
44   };
46   nativeBuildInputs = [
47     jdk # bazel uses that.
48     bison # We use local flex and bison as WORKSPACE sources fail
49     flex # .. to compile with newer glibc
50     python3
51   ];
53   postPatch = ''
54     patchShebangs\
55       bazel/build-version.py \
56       bazel/sh_test_with_runfiles_lib.sh \
57       common/lsp/dummy-ls_test.sh \
58       common/tools/patch_tool_test.sh \
59       common/tools/verible-transform-interactive.sh \
60       common/tools/verible-transform-interactive-test.sh \
61       kythe-browse.sh \
62       verilog/tools
63   '';
65   removeRulesCC = false;
66   bazelTargets = [ ":install-binaries" ];
67   bazelBuildFlags = [ "-c opt" ];
69   doCheck = true;
70   bazelTestTargets = [ "//..." ];
71   bazelTestFlags = [ "-c opt" ];
73   buildAttrs = {
74     installPhase = ''
75       mkdir -p "$out/bin"
77       install bazel-bin/common/tools/verible-patch-tool "$out/bin"
79       V_TOOLS_DIR=bazel-bin/verilog/tools
80       install $V_TOOLS_DIR/diff/verible-verilog-diff "$out/bin"
81       install $V_TOOLS_DIR/formatter/verible-verilog-format "$out/bin"
82       install $V_TOOLS_DIR/kythe/verible-verilog-kythe-extractor "$out/bin"
83       install $V_TOOLS_DIR/lint/verible-verilog-lint "$out/bin"
84       install $V_TOOLS_DIR/ls/verible-verilog-ls "$out/bin"
85       install $V_TOOLS_DIR/obfuscator/verible-verilog-obfuscate "$out/bin"
86       install $V_TOOLS_DIR/preprocessor/verible-verilog-preprocessor "$out/bin"
87       install $V_TOOLS_DIR/project/verible-verilog-project "$out/bin"
88       install $V_TOOLS_DIR/syntax/verible-verilog-syntax "$out/bin"
89     '';
90   };
92   meta = with lib; {
93     description = "Suite of SystemVerilog developer tools. Including a style-linter, indexer, formatter, and language server";
94     homepage = "https://github.com/chipsalliance/verible";
95     license = licenses.asl20;
96     maintainers = with maintainers; [
97       hzeller
98       newam
99     ];
100     # Platforms linux only currently; some LIBTOOL issue on Darwin w/ bazel
101     platforms = platforms.linux;
102   };