diff --git a/README.md b/README.md index de5a1c5..56126b4 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,6 @@ If you prefer, you can build the container image locally by running: ```bash make -C ci/docker build ``` - --- **NOTE** @@ -139,6 +138,30 @@ locally. --- +## Using the Bao-Project Nix Shell + +Nix provides a robust and reproducible environment by encapsulating all necessary dependencies within a controlled environment. This approach effectively eliminates issues associated with version conflicts and missing packages/dependencies, ensuring a seamless and reliable development experience. + +We offer a nix-shell environment containing all essential Bao-Project dependencies, allowing developers to effortlessly work across all Bao-Project repositories. The required dependencies will be automatically fetched. If you already have the necessary packages/dependencies installed, Nix will prioritize the ones it fetched, ensuring reproducibility. Once you exit the nix-shell environment, those packages are no longer accessible. The Nix packages are isolated from your system packages, eliminating any risk of corruption. + +You can utilize the Bao-Project nix-shell in two ways: (1) run a standalone command within the Bao-Project nix-shell environment; (2) or open an interactive Bao-Project nix-shell environment. + +**Running a Standalone Command** + +This command opens a nix-shell, executes the provided user command, and automatically closes the shell. + +```bash +make nix-shell-run cmd="your command" +``` + +**Opening a Nix-Shell Environment** + +This command opens an interactive nix-shell with all the Bao-Project dependencies. + +```bash +make nix-shell +``` + ## Setting up GitHub Actions When setting up GitHub Actions' workflows for you repo, each step should make diff --git a/ci.mk b/ci.mk index 95b42a7..e7dab68 100644 --- a/ci.mk +++ b/ci.mk @@ -340,5 +340,32 @@ endef ############################################################################# +# Nix-shell +# Provides a nix-shell with the bao-project environment (i.e, all bao-project +# dependencies) which can be used to run the commands/tools used accross all +# bao-project repositories. +# To open an interactive nix-shell with the bao-project environment: +# make nix-shell +# To run a standalone commnand inside the nix-shell use: +# make nix-shell-run cmd="command-to-run" +# @param The command to run inside the nix-shell. +# @example make nix-shell-run cmd="ls" +# @example $(call ci, nix-shell-run, ls) + +nix-shell: + @nix-shell $(ci_dir)/shell.nix + +nix-shell-run: + @nix-shell $(ci_dir)/shell.nix --run "$(cmd)" + +.PHONY: nix-shell nix-shell-run +non_build_targets+=nix-shell nix-shell-run + +define nix-shell-run +cmd:=$1 +endef + +############################################################################# + ci=$(eval $(call $1, $2, $3, $4, $5, $6, $7, $8, $9)) diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..7c49539 --- /dev/null +++ b/shell.nix @@ -0,0 +1,22 @@ +let + pkgs = import {}; + +in +pkgs.mkShell { + buildInputs = [ + pkgs.docutils + pkgs.sphinx + pkgs.python311Packages.sphinxcontrib-spelling + pkgs.python311Packages.sphinx-tabs + pkgs.python311Packages.pyenchant + pkgs.python311Packages.doc8 + pkgs.enchant + pkgs.python311Packages.sphinx-rtd-theme + ]; + shellHook = '' + echo "" + echo "######################################################################" + echo "# Welcome to bao-project Nix shell environment! #" + echo "######################################################################" + ''; +}