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

buildYarnPackage: init #210814

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

winterqt
Copy link
Member

@winterqt winterqt commented Jan 15, 2023

Description of changes

buildYarnPackage builds off of the work that Yureka did on fetchYarnDeps, as well as my work on buildNpmPackage, providing a common interface and set of hooks for Node-based projects. This was the main thing preventing towards the coordinated effort to migrate away from the node2nix-generated nodePackages set, as a lot of packages use Yarn.

As for why this is better than the current Yarn tooling in Nixpkgs: mkYarnPackage tries to do way too much by comparison, leading to breakages. This also allows us to get rid of a lot of the code duplication surrounding Yarn packages that don't currently use mkYarnPackage, as they all contain the same set of commands (all of which are ran in the new Yarn config hook).

The main blocker is docs -- these were kind of cobbled together. I'm not really sure how to handle the whole "only yarn install gets its own set of flags, all the others are npm..." thing, maybe I should just... explicitly state it? Is there a better way to explain it other than just saying a) what the gotcha is, and b) why it's done? Everything else should be fine, and ready to test.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • 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/)
  • 23.05 Release Notes (or backporting 22.11 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
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@pbsds
Copy link
Member

pbsds commented Feb 5, 2023

Not sure how helpful/relevant this is, but i ran into this issue while playing around with this PR:

{ lib
, stdenv
, buildYarnPackage
, fetchFromGitHub
, pkgs
}:

buildYarnPackage rec {
  pname = "hydrogen-web";
  version = "0.3.6";

  src = fetchFromGitHub {
    owner = "vector-im";
    repo = "hydrogen-web";
    rev = "refs/tags/v${version}";
    hash = "sha256-pWYIXzObuTMpSW0UsbaO9CSOu0tN96wj8XXvglxCZrI=";
  };

  yarnDepsHash = "sha256-+KcMLjM9q/RHgV3XhFAH/tGSZ3xpHJ08JHS1L09o1MY=";

  preInstall = ''
    set -x # debug
  '';
}

results in

++ npm prune --omit dev --no-save
npm WARN ERESOLVE overriding peer dependency[0m Completed in 70
npm WARN While resolving: typeson@5.18.2
npm WARN Found: core-js-bundle@undefined
npm WARN node_modules/core-js-bundle
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer core-js-bundle@"^3.6.4" from typeson@5.18.2
npm WARN node_modules/typeson
npm WARN   typeson@"^5.8.2" from realistic-structured-clone@2.0.2
npm WARN   node_modules/realistic-structured-clone
npm ERR! code EAI_AGAIN
npm ERR! syscall getaddrinfo
npm ERR! errno EAI_AGAIN
npm ERR! request to https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz failed, reason: getaddrinfo EAI_AGAIN gitlab.matrix.org

which likely came from here.

The url in question has been downloaded into yarnDeps, but node prune seems to not be aware of this. Why it even has to download stuff is beyond me.

@winterqt
Copy link
Member Author

winterqt commented Feb 5, 2023

Try npmFlags = [ "--legacy-peer-deps" ]?

@pbsds
Copy link
Member

pbsds commented Feb 5, 2023

It removes the warnings

++ npm prune --omit dev --no-save --legacy-peer-deps
npm ERR! code EAI_AGAINdealTree buildDeps1ms[0m
npm ERR! syscall getaddrinfo
npm ERR! errno EAI_AGAIN
npm ERR! request to https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz failed, reason: getaddrinfo EAI_AGAIN gitlab.matrix.org

@winterqt
Copy link
Member Author

winterqt commented Feb 6, 2023

Got it, thanks.

I'll take a look at this when I get back to this PR (have a fix in mind but need to test it) -- thank you for the information! I'll ping you once I push a fix :)

@johnbchron
Copy link
Contributor

Is there anything blocking this from being merged? Would be super helpful.

@lilyinstarlight
Copy link
Member

Is there anything blocking this from being merged? Would be super helpful.

It needs some updates, but I'm hoping to get to it soon. I'll reply later with specific details of what is needed just so it's transparent

@purepani
Copy link
Contributor

purepani commented Feb 5, 2024

Hi! Just wanted to ask if there have been any updates for this as it would be helpful.

@wegank wegank added 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 2.status: merge conflict labels Mar 19, 2024
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

6 participants