Skip to content

Add experimental nix support#76

Closed
ajkachnic wants to merge 1 commit intooven-sh:mainfrom
ajkachnic:main
Closed

Add experimental nix support#76
ajkachnic wants to merge 1 commit intooven-sh:mainfrom
ajkachnic:main

Conversation

@ajkachnic
Copy link

As discussed in the discord, this PR adds experimental Nix support via a default.nix file and a small note in the README. While this is great and all, it still leaves many unanswered questions:

  • Should we be building from source instead? (Currently unfeasible for multiple reasons, but good long term)
  • How should we handle updating versions?
    • Should we just use the latest version at all times?
    • Should use/update check-sums?
      As mentioned in the discord by @Jarred-Sumner

      There have been a couple cases where I had to re-upload the version after some build issue
      so it might make sense to forgo the checksum for now

    • Should we dynamically update the default.zig file upon each new release with the Makefile?
  • Should we provide more detailed instructions on how to install with Nix?
  • When is the right time to submit to nixpkgs?
  • How should we handle configuring Bun's cache directory?

and the list goes on.

There are definitely a few things that should be fixed here, this is a decent starting point to build upon.

let
version = "0.0.52";
checksum = "88k0RW6/X/CudqExRwnbfzpKcxHJ3BvtvX2dIudqU+A=";
bun_install = "/home/<whatever>/.bun"; # Set this to where you want bun's cache
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to fill this in with the current user's home directory instead of manually editing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be $HOME/.bun, I just forget if that will evaluate to the root's home directory or the user's (since the package might be built with superuser permissions). I'm pretty sure it's the user's though

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getEnv can be used for this, I believe:

Suggested change
bun_install = "/home/<whatever>/.bun"; # Set this to where you want bun's cache
bun_install = "{builtins.getEnv "HOME"}/.bun";

https://nixos.org/manual/nix/stable/expressions/builtins.html#builtins-getEnv

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wrap with escaped $ so it evaluates when ran rather than in the build


### Nix

There is a `default.nix` file bundled with Bun's source. This could eventually be brought to Nixpkgs, but for now, you can run and install it like any other nix package.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to pass a url to nix? If so, I could get the default.nix package up on bun.sh

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can build a remote expressions to an extent yeah

https://nixos.org/manual/nix/stable/command-ref/nix-build.html

With nix 3.0 & flakes you can easily do something like

nix build github:Jarred-Summer/bun
There's probably a way to set up a domain name but not played with it

Copy link

@Suya1671 Suya1671 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a flake.nix for flake users?

@lucasew
Copy link
Contributor

lucasew commented Jul 9, 2022

Related: NixOS/nixpkgs#180299

@06kellyjac
Copy link

I think the main benefit of nix in this repo would be pulling in any missing dependencies in a nix dev shell

--

If we also want a package, copying the PR would be good. A source build is an option for the future.

As a note nixpkgs could never fetch nix files from this repo to add the package (that would be IFD (Import From Derivation))

For a reference of another project that offers a package/overlay neovim has some nix stuff in the contrib folder

@evanwashere evanwashere marked this pull request as draft July 13, 2022 10:33
@svelterust
Copy link

I have created a flake for getting the Bun binary here: bun-flake. Feel free to steal it 😄

@lucasew
Copy link
Contributor

lucasew commented Nov 19, 2022

I have created a flake for getting the Bun binary here: bun-flake. Feel free to steal it smile

Ty, just stole your code and added a bump script in our overlay

Every day at 6am it will verify automagically for new versions and bump

https://github.com/nixosbrasil/nixpkgs-brasil/tree/master/pacotes/utilitarios/bun

@koalazub
Copy link

Hey! Just wanting to bump this and to see if there's been any headway in being able to openly support nix builds using flakes? I would attempt it myself, but I'm not experienced enough with nixos as yet

I can see that the package is available on search.nixos.org. But only from version 0.6.2 and not as a flake

@lucasew
Copy link
Contributor

lucasew commented Jul 16, 2023

Hey! Just wanting to bump this and to see if there's been any headway in being able to openly support nix builds using flakes? I would attempt it myself, but I'm not experienced enough with nixos as yet

I can see that the package is available on search.nixos.org. But only from version 0.6.2 and not as a flake

We have bun packaged in binary form in our community overlay

It's updated every night

https://github.com/nixosbrasil/nixpkgs-brasil

@koalazub
Copy link

Hey! Just wanting to bump this and to see if there's been any headway in being able to openly support nix builds using flakes? I would attempt it myself, but I'm not experienced enough with nixos as yet

I can see that the package is available on search.nixos.org. But only from version 0.6.2 and not as a flake

We have bun packaged in binary form in our community overlay

It's updated every night

https://github.com/nixosbrasil/nixpkgs-brasil

I was kind of confused about the whole discussion as it's not a release that stems from the oven-sh organisation. So I wasn't sure if that was an official package. On top of that, I'm very new to nix and so I was trying to figure out how to install the latest version of it.

I forgot to document on here, but I was able to install the latest version of bun using unstable-nix.pkg and not just nixpkg.

An example of my configuration.nix in case anyone else is still getting their bearings

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

Successfully merging this pull request may close these issues.

8 participants