From 1c699c568720929d44500a5dc02174409f29d8c1 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Wed, 3 Jan 2024 17:15:13 +0000 Subject: [PATCH] Introduce bazel_ot package This is bazelisk with auto completion stolen from bazel package. --- dev/opentitan.nix | 4 ++-- flake.nix | 2 +- pkgs/bazel_ot/default.nix | 20 ++++++++++++++++++++ pkgs/default.nix | 1 + 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 pkgs/bazel_ot/default.nix diff --git a/dev/opentitan.nix b/dev/opentitan.nix index 766c4e5..5cc4b77 100644 --- a/dev/opentitan.nix +++ b/dev/opentitan.nix @@ -1,6 +1,7 @@ { pkgs, ncurses5-fhs, + bazel_ot, python_ot, verilator_ot, edaTools ? [], @@ -29,8 +30,7 @@ in targetPkgs = _: with pkgs; [ - bazelisk - + bazel_ot python_ot verilator_ot diff --git a/flake.nix b/flake.nix index 69765ee..078bf9b 100644 --- a/flake.nix +++ b/flake.nix @@ -30,7 +30,7 @@ packages = import ./pkgs {inherit pkgs inputs;}; devShells = { opentitan = pkgs.callPackage ./dev/opentitan.nix { - inherit (packages) ncurses5-fhs verilator_ot python_ot; + inherit (packages) ncurses5-fhs bazel_ot verilator_ot python_ot; }; }; formatter = pkgs.alejandra; diff --git a/pkgs/bazel_ot/default.nix b/pkgs/bazel_ot/default.nix new file mode 100644 index 0000000..f7ea11b --- /dev/null +++ b/pkgs/bazel_ot/default.nix @@ -0,0 +1,20 @@ +{ + runCommand, + bazelisk, + bazel_6, + ... +}: +# OpenTitan requires a specific version of Bazel. +# We *could* package our own Bazel, but it can't be a simple override since Bazel build process +# require a lot of Internet dependencies. +# +# For simplicity we'll just let bazelisk do the heavyloading. +# +# This package basically just creates an alias from bazel to bazelisk and adds the auto completion +# which is absent in bazelisk. +runCommand "bazel" {} '' + cp -r ${bazelisk} $out + chmod -R +w $out + ln -s $out/bin/bazelisk $out/bin/bazel + cp -r ${bazel_6}/share $out/share +'' diff --git a/pkgs/default.nix b/pkgs/default.nix index 21ecba4..36858bd 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -11,6 +11,7 @@ verilator_ot = import ./verilator {inherit pkgs;}; python_ot = pkgs.callPackage ./python_ot {inherit inputs;}; + bazel_ot = pkgs.callPackage ./bazel_ot {}; } // pkgs.lib.optionalAttrs (pkgs.system == "x86_64-linux") { lowrisc-toolchain-gcc-rv32imcb = pkgs.callPackage ./lowrisc-toolchain-gcc-rv32imcb.nix {};