From e68abc5d076e9a3f69e91aeee978b357b034ac4c Mon Sep 17 00:00:00 2001 From: deftdawg Date: Wed, 20 Nov 2024 09:01:31 -0500 Subject: [PATCH] Tools: Add Devbox+DirEnv integration to simplify build tool setup (#11406) Co-authored-by: Laurent Cozic --- .envrc | 9 +++++++++ devbox.json | 41 +++++++++++++++++++++++++++++++++++++++++ readme/dev/BUILD.md | 14 ++++++++------ 3 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 .envrc create mode 100644 devbox.json diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..2f05af981 --- /dev/null +++ b/.envrc @@ -0,0 +1,9 @@ +#!/bin/bash + +# 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 diff --git a/devbox.json b/devbox.json new file mode 100644 index 000000000..16225415d --- /dev/null +++ b/devbox.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.13.4/.schema/devbox.schema.json", + "packages": { + "cocoapods": { + "version": "latest", + "platforms": ["aarch64-darwin", "x86_64-darwin"], + }, + "yarn": "latest", + "vips.dev": { + "platforms": ["aarch64-darwin"], + }, + "nodejs": "latest", + "pkg-config": "latest", + "pixman": "latest", + "cairo.dev": "", + "pango.dev": "", + "darwin.apple_sdk.frameworks.Foundation": { // satisfies missing CoreText/CoreText.h + // https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/darwin/apple-sdk/default.nix + "version": "", + "platforms": ["aarch64-darwin", "x86_64-darwin"], + }, + "python": "latest", + "bat": "latest", + "electron": { + "version": "latest", + "excluded_platforms": ["aarch64-darwin", "x86_64-darwin"], + }, + "git": "latest", + }, + "shell": { + "init_hook": [ + "export COLOR_BLACK='\\e[0;30m' COLOR_GRAY='\\e[1;30m' COLOR_RED='\\e[0;31m' COLOR_LIGHT_RED='\\e[1;31m' COLOR_GREEN='\\e[0;32m' COLOR_LIGHT_GREEN='\\e[1;32m' COLOR_BROWN='\\e[0;33m' COLOR_YELLOW='\\e[1;33m' COLOR_BLUE='\\e[0;34m' COLOR_LIGHT_BLUE='\\e[1;34m' COLOR_PURPLE='\\e[0;35m' COLOR_LIGHT_PURPLE='\\e[1;35m' COLOR_CYAN='\\e[0;36m'; export COLOR_LIGHT_CYAN='\\e[1;36m'; export COLOR_LIGHT_GRAY='\\e[0;37m'; export COLOR_WHITE='\\e[1;37m'", + ". $VENV_DIR/bin/activate", + "pip -q install -U pip setuptools wheel", // Newer Pythons are missing distutils + "echo -e \"${COLOR_LIGHT_PURPLE}Build ${COLOR_LIGHT_BLUE}Joplin${COLOR_LIGHT_PURPLE}: ${COLOR_LIGHT_GREEN}yarn install ${COLOR_GRAY}\"", + "echo -e \"${COLOR_LIGHT_PURPLE}Run ${COLOR_LIGHT_BLUE}Joplin Desktop${COLOR_LIGHT_PURPLE}: ${COLOR_LIGHT_GREEN}cd packages/app-desktop && ${COLOR_YELLOW}$(grep -q '^ID=nixos$' /etc/os-release 2>/dev/null && echo 'ELECTRON_OVERRIDE_DIST_PATH=$(dirname $(which electron)) ')${COLOR_LIGHT_GREEN}yarn start ${COLOR_GRAY}\"", + "echo -e \"${COLOR_LIGHT_PURPLE}Run ${COLOR_LIGHT_BLUE}Joplin CLI${COLOR_LIGHT_PURPLE}: ${COLOR_LIGHT_GREEN}cd packages/app-cli && yarn start ${COLOR_GRAY}\"", + "echo -e \"${COLOR_LIGHT_PURPLE}Read ${COLOR_LIGHT_BLUE}Full Build Instructions${COLOR_LIGHT_PURPLE}: ${COLOR_LIGHT_GREEN}bat readme/dev/BUILD.md ${COLOR_GRAY}\"", + ], + }, +} diff --git a/readme/dev/BUILD.md b/readme/dev/BUILD.md index a0d5e5938..57c92a222 100644 --- a/readme/dev/BUILD.md +++ b/readme/dev/BUILD.md @@ -18,13 +18,15 @@ There are also a few forks of existing packages under the "fork-*" name. ## Required dependencies -- Install Node 18+. On Windows, also install the build tools - https://nodejs.org/en/ - - [Enable Yarn](https://yarnpkg.com/getting-started/install): `corepack enable` -- macOS: Install Cocoapods - `brew install cocoapods`. Apple Silicon [may require libvips](https://github.com/laurent22/joplin/pull/5966#issuecomment-1007158597) - `brew install vips`. -- Linux: Install dependencies - `sudo apt install build-essential libnss3 libsecret-1-dev python rsync libgbm-dev libatk-bridge2.0-0 libgtk-3.0 libasound2` +All of the required dependencies are listed within the [devbox.json](../../devbox.json) file in the project root. You can either manually install them based on that list, or you can automatically install them on Linux or MacOS by using: -If using the `onenote-converter` you will require Rust: -- Install Rust 1.80+. Follow the instructions on [Rust toolchain website](https://rustup.rs/) +```sh +devbox shell +``` + +If you don't already have devbox, please [follow these instructions](https://www.jetify.com/docs/devbox/quickstart/). + +If working on the `onenote-converter` packages you will need to install the [Rust toolchain](https://rustup.rs/). ## Building