Skip to content

Commit

Permalink
doc: Add Section in 'Getting Started' documentation about nix flake
Browse files Browse the repository at this point in the history
Signed-off-by: Sarah Renkhoff <[email protected]>
  • Loading branch information
Irockasingranite committed Feb 20, 2024
1 parent 589a743 commit 69ff431
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 5 deletions.
10 changes: 5 additions & 5 deletions doc/bridle/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
Getting started
###############

To quickly get started with |BRIDLE|, use the
:ref:`Getting Started Assistant <gs_assistant>` to set up your development
environment. Alternatively, check the :ref:`gs_installing` section for
instructions on setting up your environment manually.
To quickly get started with |BRIDLE|, use the :ref:`Getting Started Assistant
<gs_assistant>` to set up your development environment. Alternatively, check the
:ref:`gs_installing` section for instructions on setting up your environment
manually. To set up your system for using Bridle with Nix, see :ref:`gs_nix`.

We recommend using [t.b.d.] for building your applications. See
:ref:`gs_programming` for the download links and instructions. In case you
Expand All @@ -25,7 +25,7 @@ start developing!
gs_recommended_versions
gs_assistant
gs_installing
gs_nix
gs_programming
gs_testing
gs_modifying

58 changes: 58 additions & 0 deletions doc/bridle/gs_nix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.. _gs_nix:

Working with Bridle via Nix
###########################

.. contents::
:local:
:depth: 2

An alternative way to develop with Bridle is through `Nix <https://nixos.org/>`, a functional package
managing system. This way, all dependencies can be installed using a single
tool. Packages installed this way don't pollute your regular system, and can
easily be removed later.

Installing the Nix Package Manager
**********************************

To get started using Nix, you will need to install the package manager itself.
Most distributions provide packages for installing it using their regular
package manager (e.g. on Ubuntu provides a ``nix`` package that can be installed
using ``apt install nix``). If your distribution doesn't provide such a package, see the
instructions on `nixos.org <https://nixos.org/download>` to get a Nix
installation.

Enabling Flakes
***************

Flakes are an experimental feature that enables fully hermetic and reproducible
builds. To enable flakes, add

.. parsed-literal::
:class: highlight
experimental-features = nix-command flakes
to ``~/.config/nix/nix.conf`` (creating this file if it doesn't exist).

Using the Bridle Flake
**********************

The Bridle flake provides a ``devShell`` output, which is a shell environment in
which all necessary tools and dependencies are present for developing Zephyr
applications with Bridle. By running `nix develop` within the bridle repository,
you enter this environment. You can then proceed to create a west workspace
ontop of your bridle directory and work as usual.

Keeping the Bridle Flake Up-to-date
***********************************

Like all nix flakes, the Bridle flake has its inputs locked using the
``flake.lock`` file. Running ``nix flake update`` in the bridle directory will
check for upstream changes and bump any changed inputs in the lockfile.

The flake also relies on the manifest lockfile ``west2nix.toml``, which reflects
the state of a west workspace at a specific time. To update this lockfile, the
workspace you want to lock needs to be fully checked out. Within this workspace,
run ``nix run bridle#west2nix`` to generate a new ``west2nix.toml``, which can
then be placed in the bridle directory.

0 comments on commit 69ff431

Please sign in to comment.