Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esbuild: finding a solution that works for all versions #112

Closed
happysalada opened this issue Apr 6, 2022 · 10 comments
Closed

esbuild: finding a solution that works for all versions #112

happysalada opened this issue Apr 6, 2022 · 10 comments

Comments

@happysalada
Copy link
Contributor

I was having some problem with a package failing on esbuild (missing the binary of course)
I was thinking we should potentially have a json file with all the versions and hashes for a couple of packages.
We could potentially make a script to populate that binary.lock file. (we could call it anything you want).

@DavHau
Copy link
Member

DavHau commented Apr 15, 2022

Yes I think something like that might be a good idea. I mean, the cleaner solution would probably be to build these binaries from source if the source is vendored.

@happysalada
Copy link
Contributor Author

Here is what I think we should do.
have an override for minor versions that all patch versions will use.
Something like

 "add-binary-0.12" = {
        _condition = pkg: (lib.versionAtLeast pkg.version "0.12") && (lib.versionOlder pkg.version "0.13");
        ESBUILD_BINARY_PATH = let
          esbuild = pkgs.buildGoModule rec {
            pname = "esbuild";
            # using 0.12 latest version
            version = "0.12.17";

            src = pkgs.fetchFromGitHub {
              owner = "evanw";
              repo = "esbuild";
              rev = "v${version}";
              sha256 = "sha256-wZOBjNOgGmwIQNCrhzwGPmI/fW/yZiDqq8l4oSDTvZs=";
            };

            vendorSha256 = "sha256-2ABWPqhK2Cf4ipQH7XvRrd+ZscJhYPc3SV2cGT0apdg=";
          };
        in "${esbuild}/bin/esbuild";
      };

then we have one override for each "major" version. The api supposedly is compatible. So we should have only 3-4 versions that we need to write by hand that would be valid for everything.

If that sounds good to you, happy to give it a go in a PR.

@DavHau
Copy link
Member

DavHau commented Apr 17, 2022

Wonderful, I think this is a good approach.
You could shorten the condition by using satisfiesSemver "~0.12"

@happysalada
Copy link
Contributor Author

how do I get access from the satisfiesSemver function from outside of dream2nix. I wanted to test on a flake directly before submitting a merge request.
I tried checking into dlib, but didn't find a path after that. And nix repl . complains that there is no default.nix in the repo
dlib = inputs.dream2nix.lib.dlib.
I'm going to make an MR and work off the branch for now, but would be nice to have an example in the readme of how to access the satisfiesSemver function from an outside flake.

@DavHau
Copy link
Member

DavHau commented Apr 23, 2022

satisfiesSemver is currently not in dlib. I will put it there soon.
For now it can be used like this:

nix-repl> :lf ./.
Added 17 variables.

nix-repl> lib.x86_64-linux.utils.satisfiesSemver
«lambda @ /nix/store/jrsj7h4ibxlfiv99i5sxmiid3ixmjc8c-source/semver.nix:81:21»

@happysalada
Copy link
Contributor Author

nix repl complains for me that there is no default.nix probably my nix is too old.
oh, no, you just have to nix repl flake.nix, okay my brain is not working.
found the repl and learned about :lf
I've just submitted a PR for esbuild 0.14, I'll be doing more as I encounter them.
I think this can be closed for now.
Thanks for the help!

@happysalada
Copy link
Contributor Author

It's probably not the end for this one
Cannot start service: Host version "0.14.23" does not match binary version "0.14.38"
I'm looking for a way to de-activate the version check.

@happysalada
Copy link
Contributor Author

I've got a PR ready

@happysalada
Copy link
Contributor Author

also, last question, in the flake overrides, how will I access the pkgs representing nixpkgs. Do you re-export it or is my best alternative to do
pkgs = import inputs.dream2nix.inputs.nixpkgs { system = "x86_64-darwin"; };

was also thinking it would be good to include in the example flakes comment a more involved override just to give a good sense of how to do it.

@DavHau
Copy link
Member

DavHau commented Apr 24, 2022

No need to re-import nixpkgs if you don't use overlays (see: https://zimbatm.com/notes/1000-instances-of-nixpkgs). You can access it via:
inputs.dream2nix.inputs.nixpkgs.legacyPackages.x86_64-darwin.

Yes, I think it would be an amazing idea to add an example flake to the readme that uses all possible features and is commented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants