bonfire-app icon indicating copy to clipboard operation
bonfire-app copied to clipboard

Update the nix builds to support the current development workflow

Open abaez opened this issue 3 years ago • 5 comments

As part of discussion^1 on #403, the following issue is to update the current nix build set up. In doing so, supporting and using, where possible, the current build workflows for Bonfire.

abaez avatar Jul 01 '22 04:07 abaez

I just realised a side effect of cleaning this up will be better support for using Gitpod as a dev environment, I was just looking at it (see https://github.com/bonfire-networks/bonfire-app/commit/aef66626ef091723aa39a94e522a83fa2ccd9786) but it seems the current outdated nix config is being read by Gitpod and causing unexpected results...

mayel avatar Jul 29 '22 07:07 mayel

@mayel I already have something for development, but not for building a nix package.

The development right now works by treating as if it was without docker setup. So doing just setup would provide the same results.

I do still want to make the package route as well. That would eliminate rebuild steps considerably and make it even easier to test.

With the package route, along with cd into the root directory, you'll need to run the following command if you want a built package version to test:

# run dev version 
nix run ".#dev" 

abaez avatar Jul 29 '22 11:07 abaez

@mayel going with the changes done on #435, focused only on doing the portion on getting a development environment working with the just tooling you have.

I did notice there are multiple ways the build and deploy can be cleaned up. Especially with the use of the .env file. But for now, wanted to mirror as close as possible what you all have working outside of nix. So that the maintainability is as low as it can get.

Later on, after #403, I'll go ahead and do the section on build and deploy. Planning to use the same structures I use for my own personal nix deployments of elixir. Still thinking of ways to make it use what you already have setup with just. It may be the deployment/packages through nix won't use them directly. But still thinking of ways on how to incorporate.

Maybe introduce a new command for a environment flag of WITH_NIX when using direnv. So when you run just config|setup|dev, it follows to use nix build, nix run, and it does what's expected along with bootstrap the db if WITH_DOCKER=no.

abaez avatar Jul 31 '22 01:07 abaez

Sounds good!

mayel avatar Jul 31 '22 02:07 mayel

I managed to have a working gitpod environment by running just secrets (and pasted the results on .envfile) and I had to run also just js-deps-get

ivanminutillo avatar Aug 01 '22 18:08 ivanminutillo

Just a heads-up that I'm very interested in trying out Bonfire with nix. Is this being worked on?

jtrees avatar Jun 27 '23 15:06 jtrees

@jtrees sadly no. 😔 I did an initial migration to handle running as a nix flake. And it does work! But, I wanted to make this more unified so that the nix flake would be up to date.

However, you can use nix flake path on the project. You'll have to be aware of updating the hex2nix derivatives, but it should work still.

abaez avatar Jun 27 '23 17:06 abaez

@abaez Are there up-to-date instructions on how to set it up somewhere? I tried the ones from here and got stuck.

v0.9.0-beta.9 tag

# props.nix
{
  app_name = "bonfire";
  app_version = "0.9.0-beta.9";
  elixir_release = "1.13";
  erlang_release = "24";
  PGUSERNAME = "bonfire";
  PGDATABASE = "bonfire_db";
  PGPASS = "password";
}
  1. just nix-db-init
    • just isn't in the list of included packages.
    • No problem, I added it.
  2. "Modify the .env file"
    • I don't see a .env file. Ok, I'll just ignore this step.
  3. just setup
    • Does a bunch of stuff, produces some warnings like this: "warning: the dependency bonfire_me is not present in the build directory" and ultimately fails like so:

      * Updating linkify (https://github.com/bonfire-networks/linkify - origin/master)
      fatal: reference is not a tree: e15ff9c5f885c65177c42a5b99669423370d8967
      ** (Mix) Command "git --git-dir=.git checkout --quiet e15ff9c5f885c65177c42a5b99669423370d8967" failed
      error: Recipe `cmd` failed on line 634 with exit code 1
      error: Recipe `mix` failed on line 653 with exit code 1
      error: Recipe `deps-get` failed on line 256 with exit code 1
      error: Recipe `flavour` failed on line 90 with exit code 1
      error: Recipe `setup` failed on line 111 with exit code 1
      

Not sure what's going on here. The commit seems to still exist in some form but GitHub says:

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Doesn't even really look like a nix-related issue actually.

main branch

❯ just setup
error: Justfile does not contain recipe `setup`.

Additional Comments

I also tried the same with elixir 1.15 and otp 26 but ran into the same road blocks. Updating the flake with flake update also didn't help.

Let me know if this is the wrong place to ask for detailed support and we can move to a different channel.

jtrees avatar Jun 30 '23 12:06 jtrees