-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nix-flake: Add Section in 'Getting Started' documentation
Signed-off-by: Sarah Renkhoff <[email protected]>
- Loading branch information
1 parent
5cd2544
commit 2ee7d5e
Showing
2 changed files
with
74 additions
and
5 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,69 @@ | ||
.. _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 several outputs that can be used in different ways. | ||
The most straight-forward way to use it is via the ``devShell`` output. By running | ||
``nix develop`` in your bridle directory, nix will build and drop you into a | ||
shell environment in which all necessary tools and dependencies are present for | ||
developing Zephyr applications with Bridle. You can then proceed to create a | ||
west workspace ontop of your bridle directory and work as usual. | ||
|
||
The Bridle flake also provides a special output ``workspace``, which provides a | ||
fully fetched west workspace according to the current west manifest, in the nix | ||
store. This output can be used in further nix derivations, e.g. to create | ||
reproducible firmware builds. The ``bridle-doc`` output is an example of a | ||
derivation using this workspace to build the Bridle documentation. | ||
|
||
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 two auto-generated nix files to satisfy dependencies | ||
specified in python-specific ``requirements.txt`` files and in the west | ||
manifest, respectively. To keep these in sync with upstream changes, the west | ||
subcommand ``west nix-update`` can be used. It will parse the relevant | ||
``requirements.txt`` files and make sure the ``devshell`` environment provides | ||
all necessary python packages. It will also parse the west manifest, and update | ||
the workspace flake accordingly. Finally, it will run ``nix flake update`` on | ||
the workspace flake (**not** the main Bridle flake!), to make sure ``west`` and | ||
``nix`` use the same upstream revisions. |