devbox icon indicating copy to clipboard operation
devbox copied to clipboard

Install Devbox Using Flakes

Open Lagoja opened this issue 2 years ago • 1 comments

Context

We currently publish Devbox as a package in the nixpkg repository, but this version is often far behind our latest released version. For example: 22.11 currently has devbox 0.1.0, while unstable has devbox 0.3.4 (we're on 0.4.2 as of this PR).

By publishing a flake, we could make it easier for developers using NixOS, Nixpkg, or Home Manager to install Devbox on their system. Developers could add our repo + release tags as an input, and then have access to the latest versions as soon as we publish them.

With this installed, developers using Nix could install devbox with something like

nix build github:jetpack-io/devbox/latest

or adding

{
  inputs = {
         devbox.url = "github:jetpack-io/devbox/latest";
   ...
  };
...
}

to their flake.

Changes / Limitations with this PR:

  1. go.mod Hashes - We need to provide Nix with a sha256 of our vendored dependencies in order to build Devbox. We can do this by either adding a vendorSHA256 to our Flake, or using gomod2nix to generate a module with the hashes of all the dependencies in our go.mod file. This PR goes with the gomod2nix approach.

  2. Version Number - The version number currently needs to be set and updated manually in the Flake. This is because Flake outputs don't have access to the repositories branches or tags. We could pull this version from a file in the repo, or by running a script that reads the tags.

  3. Branch/Refs - To make it easy to install the latest version, we'll need a ref in our git repo for latest or stable. This could be a branch or a tag, and should be updated whenever we make a new full release.

How was it tested?

  • [x] aarch64-linux
  • [x] x86_64-linux
  • [x] aarch64-darwin
  • [x] x86_64-darwin
  • [x] WSL2

With nix command and flakes enabled:

  • nix build
  • nix flake

Lagoja avatar Mar 07 '23 04:03 Lagoja

I made https://github.com/adamdicarlo/devbox-nix-flake to use until this PR is completed - in case that helps anyone else. (Currently, devbox in nixpkgs is up to date, but this flake allows me to get the very latest release before nixpkgs gets updated.)

adamdicarlo0 avatar Dec 04 '23 23:12 adamdicarlo0