Skip to content

Commit

Permalink
NO-ISSUE: Add Nix-based development environment using devbox (apache#…
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagoelg authored Apr 18, 2024
1 parent 764c37f commit a1455fe
Show file tree
Hide file tree
Showing 10 changed files with 631 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Automatically sets up your devbox environment whenever you cd into this
# directory via our direnv integration:

eval "$(devbox generate direnv --print-envrc)"

# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/
# for more details
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,6 @@ fabric.properties
packages/bpmn-marshaller/**/ts-gen
packages/dmn-marshaller/**/ts-gen
packages/scesim-marshaller/**/ts-gen

# devbox
.devbox
8 changes: 7 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint", "ms-kubernetes-tools.vscode-kubernetes-tools"]
"recommendations": [
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"ms-kubernetes-tools.vscode-kubernetes-tools",
"mkhl.direnv",
"jetpack-io.devbox"
]
}
65 changes: 65 additions & 0 deletions NIX_DEV_ENV.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
## Nix-based development environment shell

### Installing

- [Install Nix](https://nixos.org/download/) using the multi-user installation. (You can use the single-user installation, but things may not work as expected)
- Enable nix-command and flakes:
- Open the Nix config:
- `sudo nano /etc/nix/nix.conf`
- Add the following at the bottom of the file:
- `experimental-features = nix-command flakes`
- Test your installation by running the Hello World Nix package:
- Open a new shell;
- Run the hello world Nix package:
- `nix run 'nixpkgs#hello'`
- You should see `Hello, world!` printed on your terminal.
- Install [devbox](https://www.jetify.com/devbox/docs/installing_devbox/).

### Running

- Start the development environment:
- `devbox shell`
- To exit the devbox shell, terminate it with `exit` or _Ctrl+D_.

---

### Automating

The steps below are optional but can make your life easier.

#### Starting the shell automatically when navigating into the kie-tools directory

- [Install direnv](https://direnv.net/docs/installation.html);
- Remember to [hook it into your shell](https://direnv.net/docs/hook.html);
- Reload your shell (`source ~/.bashrc` or `source ~/.zshrc`, for example) or open a new one;
- `cd` back into the kie-tools directory;
- Run `direnv allow` to allow direnv to exectue;
- If `devbox` is not loaded, run `cd .` to trigger it.

#### Make VSCode use the devbox shell automatically

- Install the [devbox VSCode extension](vscode:extension/jetify-com.devbox);
- Install the [direnv VSCode extension](vscode:extension/mkhl.direnv);
- Run the steps above, if not already;
- Open your Devbox project in VSCode. Direnv extension should show a prompt notification to reload your environment.

---

### Maintaining

#### Adding new packages

- Search for them in [nixhub.io](https://www.nixhub.io/) or via `devbox search <package_name>`;
<blockquote>
If you can't find it there, it may have a different name or belong to a package set.

Try searching for the package name in [search.nixos.org](https://search.nixos.org/), and then finding the equivalent package in [nixhub.io](https://www.nixhub.io/).
</blockquote>

- Copy and run the `devbox add <package_name>@<version>` command.

#### Upgrading packages

- Run `devbox add <package_name>@<new_version>` and it should update both `devbox.json` and `devbox.lock`.

#### Learn more about [devbox](https://www.jetify.com/devbox/docs/)!
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ This repository contains tooling applications and libraries for KIE projects.

## Build from source

> **💡 Nix development environment**: A _devbox_ configuration is provided to automatically setup all the tools above, read more in [here](./NIX_DEV_ENV.md).
To start building the Apache KIE Tools project, you're going to need:

- Node `18` _(To install, follow these instructions: https://nodejs.org/en/download/package-manager/)_
Expand All @@ -31,24 +33,17 @@ To start building the Apache KIE Tools project, you're going to need:

> **ℹ️ NOTE:** Some packages will require that `make` is available as well.
> **ℹ️ NOTE:** \*nix users will also need:
>
> - `lib-gtk-3-dev`
> - `appindicator3-0.1` (`libayatana-appindicator3-dev` or `libappindicator-gtk3-devel` and `gir1.2-appindicator3-0.1`)
> **ℹ️ NOTE:** Users of Fedora or RHEL will need to add a repository:
>
> `sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm`
After installing the tools above, you'll need to download the dependencies and link the packages locally. Simply run:

- `pnpm bootstrap`

> **ℹ️ NOTE:** If you plan on running Playwright tests, set the `PLAYWRIGHT_BASE__installDeps` environment variable to `true` before running the command above: `PLAYWRIGHT_BASE__installDeps=true pnpm bootstrap`. This will install all Playwright dependencies (such as browsers engines and OS specific libraries).
To install only the dependencies that are relevant to the package called `[pkg-name]`.

- `pnpm bootstrap -F [pkg-name]...`

> **⚠️ NOTE:** Here, `...` is actually **necessary**! They're part of a [`pnpm` filter](https://pnpm.io/filtering#--filter-package_name-1).
> **ℹ️ NOTE:** Here, `...` is actually **necessary**! They're part of a [`pnpm` filter](https://pnpm.io/filtering#--filter-package_name-1).
After dependencies are installed, you'll be able to build. To do so, you'll have two choices - `dev`, or `prod`.

Expand All @@ -57,7 +52,7 @@ Note that it is recommended that you specify which package you want to build, so
- `pnpm -F [pkg-name]... build:dev` - This is fast, but not as strict. It skips tests, linters, and some type checks. Be prepared for the CI to fail on your PRs.
- `pnpm -F [pkg-name]... build:prod` - The default command to build production-ready packages. Use that to make sure your changes are correct.

> **⚠️ NOTE:** Here, `...` is actually **necessary**! They're part of a [`pnpm` filter](https://pnpm.io/filtering#--filter-package_name-1).
> **ℹ️ NOTE:** Here, `...` is actually **necessary**! They're part of a [`pnpm` filter](https://pnpm.io/filtering#--filter-package_name-1).
> **ℹ️ NOTE:** If you want to build _everything_, run `pnpm -r build:dev` or `pnpm -r build:prod`. It's going to take a while, though :)
Expand Down
30 changes: 30 additions & 0 deletions devbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://raw.githubusercontent.com/jetpack-io/devbox/0.10.4/.schema/devbox.schema.json",
"packages": {
"temurin-bin-17": "17.0.9",
"nodejs": "18.19.1",
"maven": "3.9.6",
"kubernetes-helm": "3.13.3",
"gnumake": "4.4.1",
"go": "1.21.8",
"python": "3.12.2",
"operator-sdk": "1.34.1",
"kubebuilder": "3.14.0"
},
"env": {
"PLAYWRIGHT_BROWSERS_PATH": "0",
"PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS": "true",
"DEVBOX_COREPACK_ENABLED": "true",
"GOFLAGS": "-modcacherw",
"GOPATH": "$DEVBOX_PROJECT_ROOT/.devbox/gopkgs",
"PATH": "$PATH:$DEVBOX_PROJECT_ROOT/.devbox/gopkgs/bin"
},
"shell": {
"init_hook": [". $VENV_DIR/bin/activate"],
"scripts": {
"versions": [
"java --version && mvn -v && node -v && pnpm -v && go version && helm version && make -v && python --version && pip --version"
]
}
}
}
Loading

0 comments on commit a1455fe

Please sign in to comment.