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

firebase-tools: enable building on node 22 #370752

Merged
merged 1 commit into from
Jan 4, 2025

Conversation

sarahec
Copy link
Contributor

@sarahec sarahec commented Jan 3, 2025

  1. Pulls in an upstream patch to replace the four-year old ajv JSON validator with a modern version. It was triggering compilation problems when built in the sandbox.
  2. Adds a local patch to override nan -- the node native interfaces -- to a version supporting node 22 (and earlier).

Fixes #369813

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/)
  • 25.05 Release Notes (or backporting 24.11 and 25.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.

@TomaSajt
Copy link
Contributor

TomaSajt commented Jan 3, 2025

Btw, why is that override used? I just copied the diff after running npm update nan and it didn't add the override part, but still seemed to work.

@sarahec
Copy link
Contributor Author

sarahec commented Jan 4, 2025

Btw, why is that override used? I just copied the diff after running npm update nan

You mentioned earlier that updating nan affected this in the lockfile and you were able to build using that. But firebase-tools doesn't supply a lockfile, just the shrinkwrap file. buildNodePackage runs checks before and after loading the package.json to make sure the packages file and shrinkwrap match with the source version. So I can't call npm update nan in the build step as it will break these checks.

Also, nix builds need to be deterministic -- by specifying the override in package.json, we get a repeatable build (as opposed to an update which will change over time).

@TomaSajt
Copy link
Contributor

TomaSajt commented Jan 4, 2025

Yes, of course, and also npm update nan would need network anyways.
I'm just wondering how you generated your patch file: I generated mine by doing npm update nan in the repo and then running git diff.

Also, is shrinkwrap not the same as package-lock?

Copy link
Contributor

@TomaSajt TomaSajt left a comment

Choose a reason for hiding this comment

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

LGTM
these will go away anyways once upstream gets a new version

@sarahec
Copy link
Contributor Author

sarahec commented Jan 4, 2025

Yes, of course, and also npm update nan would need network anyways. I'm just wondering how you generated your patch file: I generated mine by doing npm update nan in the repo and then running git diff.

I added the override in a fork of firebase-tools then ran npm run build. That emitted package.lock and a revised npm-shrinkwrap

Also, is shrinkwrap not the same as package-lock?

shrinkwrap is a superset of package.lock and can be copied/renamed to form a package lock. I had to apply the override in the package.json to get the correct values in the output lockfiles.

EDIT: See later comments. My reasoning wasn't quite correct.

@sarahec sarahec force-pushed the push-nztwxotnvrqy branch from e61722e to 7fbd32c Compare January 4, 2025 00:56
@sarahec sarahec force-pushed the push-nztwxotnvrqy branch from 7fbd32c to a88130c Compare January 4, 2025 01:11
@sarahec
Copy link
Contributor Author

sarahec commented Jan 4, 2025

Mirroring the override vs npm update question at firebase/firebase-tools#8097

@sarahec
Copy link
Contributor Author

sarahec commented Jan 4, 2025

I ran an experiment: what would happen if I tried to regenerate the shrinkwrap file? It turns out that doens't work -- there are multiple compilation errors. So a npm update nan against the shrinkwrap would work.

Would you prefer that I remove the override from the patch? (We'll see which direction the upstream wants to do also.)

Copy link
Contributor

@TomaSajt TomaSajt left a comment

Choose a reason for hiding this comment

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

LGTM
we can decide on the upstream PR whether it should be an override or not

@TomaSajt
Copy link
Contributor

TomaSajt commented Jan 4, 2025

I'll merge in 15 minutes. I don't think we should wait for too long, since fixing a broken build is always a net positive.

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Jan 4, 2025
@sarahec
Copy link
Contributor Author

sarahec commented Jan 4, 2025

@TomaSajt thank you for being patient with me

@TomaSajt
Copy link
Contributor

TomaSajt commented Jan 4, 2025

@TomaSajt thank you for being patient with me

I was also discovering and experimenting with stuff in real time while discussing this, so we all gained some useful experience.

Sidenote, I still have #369163 where I first encountered the nodejs_22 incompatibility

@TomaSajt TomaSajt merged commit adfbeee into NixOS:master Jan 4, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10 12.approvals: 1 This PR was reviewed and approved by one reputable person
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build failure: firebase-tools
3 participants