-
-
Notifications
You must be signed in to change notification settings - Fork 952
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dev: Adding shell.nix for development environments
This adds a shell.nix file to easily create a somewhat reproducible development environment with nix. It does require Nix to be installed, but may be a "lighter" alternative to Docker. Accompanying documentation is also provided.
- Loading branch information
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Build the project using `nix-shell` | ||
A `shell.nix` file is included in the repository to set up the development environment on systems that have the [Nix package manager](https://nixos.org/) installed. | ||
It prevents your system from getting polluted with build dependencies while also guaranteeing a reproducible build environment. | ||
All dependencies and tools required to build InfiniTime will automatically be fetched for you. | ||
|
||
## Install Nix | ||
|
||
Nix is available for Linux, MacOS and WSL2. | ||
[Visit the official website for instructions on how to install it.](https://nixos.org/download#download-nix) | ||
|
||
## Clone the repository | ||
|
||
Before building, local repository must be fully initialized. | ||
|
||
```sh | ||
git clone https://github.com/InfiniTimeOrg/InfiniTime.git | ||
cd InfiniTime | ||
git submodule update --init | ||
``` | ||
|
||
## Enter the development shell | ||
|
||
Creating and entering the development environment is as easy as typing the following command in the project root: | ||
```sh | ||
nix-shell --run "$SHELL" | ||
``` | ||
|
||
## Build the project | ||
Two steps are required to build the project: `cmake` and `make`. | ||
The `shell.nix` file provides a custom script called `cmake_infinitime` that calls `cmake` with the proper paths for the compiler and the SDK. | ||
|
||
Inside the shell you can build a target like this: | ||
```sh | ||
cmake_infinitime | ||
make pinetime-app | ||
``` | ||
|
||
You can pass additional arguments to the `cmake` script: | ||
```sh | ||
cmake_infinitime -DBUILD_RESOURCES=1` | ||
``` | ||
|
||
To make use of all the cores your host machine has pass the `-j` argument to `make`: | ||
```sh | ||
make -j$(nproc) pinetime-app | ||
``` | ||
|
||
There are more targets and configuration options available. | ||
You can find them in [`buildAndProgram.md`](./buildAndProgram.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
{ pkgs ? import <nixpkgs> {} }: | ||
pkgs.mkShell { | ||
# build tools | ||
nativeBuildInputs = with pkgs; [ | ||
cmake | ||
lv_img_conv | ||
nodePackages.lv_font_conv | ||
python3 | ||
python3.pkgs.cbor | ||
python3.pkgs.click | ||
python3.pkgs.cryptography | ||
python3.pkgs.intelhex | ||
python3.pkgs.adafruit-nrfutil | ||
|
||
(pkgs.writeShellScriptBin "cmake_infinitime" '' | ||
cmake -DARM_NONE_EABI_TOOLCHAIN_PATH="${pkgs.gcc-arm-embedded-10}" \ | ||
-DNRF5_SDK_PATH="${pkgs.nrf5-sdk}/share/nRF5_SDK" \ | ||
"$@" | ||
'') | ||
]; | ||
|
||
# libraries/dependencies | ||
buildInputs = with pkgs; []; | ||
} |