InfiniTimeOrg / InfiniTime

Firmware for Pinetime smartwatch written in C++ and based on FreeRTOS
GNU General Public License v3.0
2.64k stars 903 forks source link

dev: Adding shell.nix for development environments #1850

Open jzbor opened 10 months ago

jzbor commented 10 months ago

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.

github-actions[bot] commented 10 months ago

Build checks have not completed. Possible reasons for this are:

  1. The checks need to be approved by a maintainer
  2. The branch has conflicts
  3. The firmware build has failed
blm768 commented 10 months ago

The errors seem to be non-deterministic. I'll try this without the package cache.

Whoops; posted this on the wrong issue thread.

blm768 commented 10 months ago

This is downright delightful, at least for us Nix users! I can think of a couple of minor potential downsides, but I'm not sure they're huge ones:

On the upside, Nix evaluations can be quite cacheable (especially using flakes); we could build on this to cache dependency installations between CI runs if we used Nix instead of Docker for CI.

This would also pair nicely with a .envrc:

#!/usr/bin/env bash
watch_file shell.nix
use nix
FintasticMan commented 10 months ago

I wouldn't worry much about the compiler version; InfiniTime works with most versions. What I do worry about is the nRF SDK version. I can't see that this specifies a version to use, and InfiniTime definitely requires the specific version we mention in the docs. Is there a way to specify that?

jzbor commented 10 months ago

Yes that should be possible. What Version does InfiniTime require?

FintasticMan commented 10 months ago

InfiniTime requires 15.3.0.

jzbor commented 10 months ago

I have now pinned the nrf-sdk version to 15.3.0.

It should also be mentioned that it is possible to pin nixpkgs altogether, making the environment completely reproducible. However this requires the use of Flakes, which are not officially stable yet (although widely used). It also comes with the maintenance burden of keeping the Flake up-to-date, so I think a simple shell.nix is still the best fit here.

jzbor commented 9 months ago

Are there any updates? Is there still an interest in merging this?

blm768 commented 9 months ago

I'm certainly interested in using this as a NixOS user. With the errors I'm getting from the Docker container, this is currently my only way to build the project on NixOS.

icewind1991 commented 5 months ago

I've created a flake for building infinitime to make it easy to create patched builds on nixos: https://github.com/icewind1991/infinitime-builder