-
-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
dart: Use Nix instead of Pub #263345
dart: Use Nix instead of Pub #263345
Conversation
0f2abbd
to
325ff81
Compare
Result of 4 packages marked as broken and skipped:
26 packages built:
|
I have added a mechanism to customise Dart package derivations. If any packages require patches, they can now be easily added. Setup hooks have replaced the old package override mechanism, and can be used to do things like set environment variables and add to the FFI runtime dependency list. We should have probably done this from the beginning, but now it's even easier as the setup hooks can be built into the package derivations themselves. These changes allow the dependency list JSON file to be removed. |
81c7044
to
6fd1e80
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Result of 30 packages built:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! this solution is way nicer to use than a vendor hash.
comments:
-
pub2nix still requires git hashes. But currently we have to specify a separate hash for every git dependency. Maybe it'd be better to have a single fixed-output derivation to get all the git dependencies and thus use only a single hash?
-
Maybe add instructions to convert the pubspec.lock to json? Not sure when Nix would say that, though. And it's quite simple to do anyway.
|
||
mkHostedDependencySource = name: details: | ||
let | ||
archive = fetchurl { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use fetchTarBall?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added disclaimer why not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other reason is that the hash in the pubspec.lock
is for the archive itself. There's no way to determine the recursive hash of the contents in advance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see. Is this correct then?
# The hash in `pubspec.lock` is for the archive itself.
# If we use `fetchTarball` instead of `fetchurl`, we'll need to input the hash for the files after extraction, which we don't have.
# Additionally, `fetchTarball` fails with "tarball contains an unexpected number of top-level files".
# https://discourse.nixos.org/t/fetchtarball-with-multiple-top-level-directories-fails/20556
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
@FlafyDev do you want to rebase this to another branch? I can then force push it to this one. |
This still fails to build as it uses an old version of the protobuf package, though.
… in extraPackageConfigSetup
They are only needed at build time, after all.
This allows setup hooks to add runtime dependencies.
…tead of package overrides
We get a dependency list with pub2nix now. We can no longer easily distinguish between development dependency dependencies and regular dependency dependencies, but we weren't doing this anyway.
@mkg20001 I've rebased this PR on this branch
This is the nixpkgs review for 32e3ea1: Result of 2 packages failed to build:
32 packages built:
EDIT: Added a few more commits to that branch based on my suggestions. Shouldn't impact nixpkgs-review's result. |
35900eb
to
5a5db92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub2nix still requires git hashes. But currently we have to specify a separate hash for every git dependency. Maybe it'd be better to have a single fixed-output derivation to get all the git dependencies and thus use only a single hash?
I think this would be a bit complicated to do. Probably better to keep it to a future PR if necessary. Also if we make an update script for buildDartApplication and buildFlutterApplication it wouldn't really matter.
Maybe add instructions to convert the pubspec.lock to json? Not sure when Nix would say that, though. And it's quite simple to do anyway.
I still think this is necessary, but better to keep it to a different PR.
I'm not too keen in the idea of reducing granularity for just a little convenience. IIRC, running a build with blank hashes and This would also require custom fetching logic, as I don't think there's any off-the-shelf solution to make a FOD out of multiple Git repositories. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review/3032/3200 |
Result of 2 packages failed to build:
32 packages built:
|
This PR seems to break dart compile on Darwin. #279772 |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
Description of changes
This PR removes
fetchDartDeps
in favour of a newpub2nix
library. Instead of using Pub to generate a large fixed-output derivation, thepubspec.lock
file is parsed, and a derivation is made for each individual package.This improves the user experience significantly:
vendorHash
is no longer needed (though Git dependencies still do need manual hashes)This PR builds on #262789, so for review, this comparison between the branches is appropriate. This can be changed if we decide against #262789, though - nothing relies on it directly.
All existing Dart and Flutter packages build and run, with the exception of
dart-sass-embedded
, which was already broken with Dart 3. I've removed it in this PR, as it has been discontinued upstream and merged into the regulardart-sass
package.Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)@NixOS/flutter