Install Devbox Using Flakes
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:
-
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
vendorSHA256to our Flake, or usinggomod2nixto generate a module with the hashes of all the dependencies in ourgo.modfile. This PR goes with thegomod2nixapproach. -
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.
-
Branch/Refs - To make it easy to install the latest version, we'll need a ref in our git repo for
latestorstable. 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 buildnix flake
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.)