Skip to content
Fritz Mahnke edited this page Jul 28, 2024 · 10 revisions

Summary

Initial setup

nix package manager

Install nix package manager

Download and run the nix install script:

curl -L https://raw.githubusercontent.com/steppercontrol/scon_build/master/sh/nix_install_2.18.2 | sh -s -- --daemon

The expected output ends with:

Installation finished!  To ensure that the necessary environment
variables are set, either log in again, or type

  . /home/boss/.nix-profile/etc/profile.d/nix.sh

in your shell.

Source the environment as instructed above, or:

. $HOME/.nix-profile/etc/profile.d/nix.sh

Create nix user configuration

mkdir -p ~/.config/nix
echo "max-jobs = 4" >> ~/.config/nix/nix.conf
echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf

Enter a nix development shell

cd $planer_repository_path
git fetch
git checkout master
nix develop

Configure a build directory

Create a configuration file

Copy the contents of a configuration to a file (referred to as ~/config.toml below).

Configure the build directory

scon configure --config ~/config.toml

Initialize the development environment

scon init --shell --arduino-ide

Build and run

Enter a nix development shell

cd $planer_repository_path
git fetch
git checkout master
nix develop

Build

scon build

Upload

scon upload _build/Planer/Planer.ino.hex

Monitor

scon monitor

Explanation

nix package manager

nix serves to provide reproducible development shells with the software prerequisites for building the scon system. The flake.nix file in the planer repository describes the system's dependencies and build environment. With nix installed, the command nix develop enters a development shell with these dependencies available.

scon_build

The scon_build system provides a scon command with subcommands used to take planer-related actions. For example:

  • scon init is used to initialize the development environment, including installing the Arduino CLI and configuring the Arduino IDE.
  • scon configure is used to initialize a build directory.
  • scon build is used to build the system into a configured directory.

Build directory

Before building the system, a build directory must be initialized. The build directory is where all artifacts are placed, including Arduino programs, test programs, and debug information. After initialization, a build directory need not be reinitialized until a breaking change in the scon system or hardware or software reconfiguration.

  • The command scon configure initializes the build directory _build inside
  • the current shell directory.
  • On initialization, the file config.toml.default is used as the configuration template. It is copied to _build/config.toml with more specific information added.
  • Subsequent invocations of scon build use _build/config.toml. Any changes to this file are propagated the next time scon build is run.

Clone this wiki locally