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

bun: add baseline release #313760

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

bun: add baseline release #313760

wants to merge 2 commits into from

Conversation

x3lfyn
Copy link

@x3lfyn x3lfyn commented May 22, 2024

Description of changes

regular bun release works only on CPUs that support AVX instructions. bun has separate baseline releases that don't require AVX instructions

added bunBaseline package which uses baseline release(fixes #298612)

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

Copy link
Contributor

@cdmistman cdmistman left a comment

Choose a reason for hiding this comment

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

nice, though tbh i'm not a fan of polluting the packages namespace like this. mind if we make this passthru.baseline instead?

@x3lfyn
Copy link
Author

x3lfyn commented May 23, 2024

nice, though tbh i'm not a fan of polluting the packages namespace like this. mind if we make this passthru.baseline instead?

what do you mean? combine two sources into one file and make some flag to switch between them?

sorry, i am pretty new to nix, i don't know all best practices)

Copy link
Contributor

@cdmistman cdmistman left a comment

Choose a reason for hiding this comment

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

no worries at all! these 2 changes and any other changes needed to get it working :)

ideally we select src before calling buildBun, and depending on system also add the result of a buildBun <baseline source>

, common-updater-scripts
}:

{ sources, version }:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{ sources, version }:
{ src, version, baseline ? null }:

'';

passthru = {
inherit sources;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
inherit sources;
inherit baseline;

Comment on lines 15206 to 15213
inherit
({
bun = callPackage ../development/web/bun { };
bunBaseline = callPackage ../development/web/bun/baseline.nix { };
})
bun
bunBaseline
;
Copy link
Contributor

Choose a reason for hiding this comment

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

oh and in addition to ^ revert this as well

Copy link
Contributor

Choose a reason for hiding this comment

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

for future reference, the diff you wrote here is also equivalent to:

Suggested change
inherit
({
bun = callPackage ../development/web/bun { };
bunBaseline = callPackage ../development/web/bun/baseline.nix { };
})
bun
bunBaseline
;
bun = callPackage ../development/web/bun { };
bunBaseline = callPackage ../development/web/bun/baseline.nix { };

Copy link
Member

Choose a reason for hiding this comment

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

Yeah if this change could be applied that'd be great thanks

Copy link
Author

Choose a reason for hiding this comment

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

i've done it to bypass this check. without this, workflow just failes. or this error can be ignored?

Copy link
Contributor

@cdmistman cdmistman Jun 2, 2024

Choose a reason for hiding this comment

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

ah yeah, in that case, you should either:

  1. move bun/baseline.nix to by-name/bu/bunBaseline/package.nix as suggested by the error message
    • you can leave bun/default.nix where it's at if you'd like
  2. OR implement the passthru option as i suggested above
    • i'm realizing this would also probably mean setting bunBaseline = pkgs.bun.passthru.baseline in aliases.nix instead of modifying all-packages.nix

@06kellyjac seems to prefer option 1, i personally prefer option 2, i don't think either of us will care which gets implemented so the decision is up to you :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I was just about to say to fix this issue do a passthru.

Copy link
Member

@06kellyjac 06kellyjac left a comment

Choose a reason for hiding this comment

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

Generally looks good with 1 change.

I probably would lean towards separate attributes in all-pacakges rather than the passthru option as it's more visible in the search.

Comment on lines 15206 to 15213
inherit
({
bun = callPackage ../development/web/bun { };
bunBaseline = callPackage ../development/web/bun/baseline.nix { };
})
bun
bunBaseline
;
Copy link
Member

Choose a reason for hiding this comment

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

Yeah if this change could be applied that'd be great thanks

@cdmistman
Copy link
Contributor

also if you rebase off of master, you'll see the hashes are for 1.1.10

@x3lfyn
Copy link
Author

x3lfyn commented Jun 2, 2024

so i moved bun package to pkgs/by-name/bu/bun/package.nix. baseline is now passtru of bun with bunBaseline = pkgs.bun.passthru.baseline in all-packages.nix. all that satifsfies check-by-name. if just move bunBaseline to pkgs/by-name/bu/bunBaseline/package.nix, check-by-name fails with message:

pkgs/by-name/bu/bunBaseline: File package.nix at line 4 contains the path expression "../../../development/web/bun/bun.nix" which may point outside the directory of that package.
This PR introduces the problems listed above. Please fix them before merging, otherwise the base branch would break.

Copy link
Contributor

@cdmistman cdmistman left a comment

Choose a reason for hiding this comment

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

looks great, thank you!

Copy link
Contributor

@cdmistman cdmistman left a comment

Choose a reason for hiding this comment

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

reapproving

@x3lfyn
Copy link
Author

x3lfyn commented Jul 5, 2024

sorry to bother you, i understand correctly that we are waiting for the second contributor to complete review?

@nagy
Copy link
Member

nagy commented Jul 5, 2024

Before merging though, the two youngest commits should probably be removed. If you rebase this PR, those commits should no longer be necessary.

@diogomdp
Copy link
Member

diogomdp commented Jul 5, 2024

Result of nixpkgs-review pr 313760 run on x86_64-linux 1

1 package built:
  • bunBaseline

@x3lfyn
Copy link
Author

x3lfyn commented Aug 22, 2024

hi. regarding this commit - what decision would be more reasonable?

  1. use default version for x86_64-darwin system in bun package and baseline version in bunBaseline package (current state of this PR)
  2. use baseline version in bun package and exclude x86_64-darwin system from bunBaseline package

@ofborg ofborg bot requested a review from diogomdp August 22, 2024 22:31
@Eveeifyeve
Copy link
Contributor

hi. regarding this commit - what decision would be more reasonable?

  1. use default version for x86_64-darwin system in bun package and baseline version in bunBaseline package (current state of this PR)
  2. use baseline version in bun package and exclude x86_64-darwin system from bunBaseline package

I would say first one as support as a pr will most likely be made for this version some time in the future.
but I would say for the baseline use passthru as to creating another package will be a lot of maintaining plus it makes it harder to browse in the Nixpkgs repo.

@x3lfyn
Copy link
Author

x3lfyn commented Aug 24, 2024

but I would say for the baseline use passthru as to creating another package will be a lot of maintaining plus it makes it harder to browse in the Nixpkgs repo.

there are 2 problems:

  • new packages can't be created in top-level/all-packages.nix, only in by-name folders
  • expressions that point outside of package's folder are prohibited in by-name folders

so i can't just create separate baseline package that shares logic with default package due to this limitations

correct me if i'm wrong and there is some better way to share logic between two packages

@Eveeifyeve
Copy link
Contributor

Ops wrong reference.

@forsureitsme
Copy link

Until this is merged, is there another way to install bun for non AVX machines?

@x3lfyn
Copy link
Author

x3lfyn commented Sep 21, 2024

Until this is merged, is there another way to install bun for non AVX machines?

you can override source archive

bunBaseline = pkgs.bun.overrideAttrs rec {
  passthru.sources."x86_64-linux" = pkgs.fetchurl {
    url = "https://github.com/oven-sh/bun/releases/download/bun-v1.1.27/bun-linux-x64-baseline.zip";
    hash = "sha256-FwkVP5lb2V9E8YGPkTAqVMsZmaZXMq8x5AR+99cuIX0=";
  };
  src = passthru.sources."x86_64-linux";
};

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

Successfully merging this pull request may close these issues.

Packaging request: Bun on non-AVX/AVX2 architectures
9 participants