This is the source code for the NervesHub firmware update and device management server.
Important
This is the 2.0 development branch of NervesHub. If you have been using
NervesHub prior to around April, 2023 and are not following 2.0 development, see
the maint-v1.0
branch. The
maint-v1.0
branch is being used in production. 2.x development is actively in progress and while guides and documentation are still thin the 2.x code is managing a lot of devices in production right now and can be relied upon. If you use the 2.0
development branch, we don't expect breaking changes but we are also going to be tagging numbered releases.
For best compatibility with Erlang SSL versions, we use Erlang/OTP 27.0.1.
The .tool-versions
files contains the Erlang, Elixir and NodeJS versions.
Install asdf-vm and run the following for quick setup:
cd nerves_hub_web
asdf plugin-add nodejs
bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring # this requires gpg to be installed
asdf install
Modify the .tool-versions
if you want to use a later version of Erlang.
You'll also need to install fwup
and xdelta3
. See the fwup installation
instructions and the xdelta3
instructions.
On Debian/Ubuntu, you will also need to install the following packages:
sudo apt install inotify-tools
Local development uses the host nerves-hub.org
for connections and cert
validation. To properly map to your local running server, you'll need to add a
host record for it:
echo "127.0.0.1 nerves-hub.org" | sudo tee -a /etc/hosts
-
Setup database connection
NervesHub currently runs with Postgres 10.7. For development, you can use a local postgres or use the configured docker image:
Using local postgres
- Make sure your postgres is running
- If you need to edit the
DATABASE_URL
, create a.env.dev.local
and.env.test.local
to adjust to your local postgres connection
-
Fetch dependencies:
mix do deps.get, compile
-
Initialize the database:
mix ecto.reset
-
Compile web assets (this only needs to be done once and requires python2 or a symlink for python3):
mix assets.install
mix phx.server
- start the server processiex -S mix phx.server
- start the server with the interactive shell
Note: The whole app may need to be compiled the first time you run this, so please be patient
Once the server is running, by default in development you can access it at http://localhost:4000
In development you can login into a pre-generated account with the email
[email protected]
and password nerveshub
.
- Make sure you've completed your database connection setup
- Fetch and compile
test
dependencies:MIX_ENV=test mix do deps.get, compile
- Initialize the test databases:
MIX_ENV=test mix ecto.migrate.reset
- Run tests:
make test