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

buildDartPackage: init, dart-sass: init at 1.26.10 #92814

Closed
wants to merge 3 commits into from

Conversation

tadfisher
Copy link
Contributor

@tadfisher tadfisher commented Jul 9, 2020

Motivation for this change

The sass tool is outdated, and is no longer the reference SASS implementation. The reference implementation is now dart-sass, which is written in Dart and runs under the Dart VM. However, nixpkgs lacks a convenience builder for Dart applications.

This adds a buildDartPackage function, which builds Dart applications using the standard pub package manager and dart VM from the Dart SDK. The resulting compiled snapshots will run on any architecture supported by the Dart VM. A wrapper script is generated for launching snapshots using the Dart VM built by nixpkgs.

See doc/languages-frameworks/dart.section.md (rendered) for documentation.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@nixos-discourse
Copy link

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/227

Copy link
Contributor

@jonringer jonringer left a comment

Choose a reason for hiding this comment

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

I think the docs deserve their own commit

doc/languages-frameworks/dart.section.md Outdated Show resolved Hide resolved
pkgs/build-support/dart/default.nix Outdated Show resolved Hide resolved
pkgs/build-support/dart/default.nix Show resolved Hide resolved
pkgs/development/tools/dart-sass/default.nix Show resolved Hide resolved
pkgs/top-level/all-packages.nix Outdated Show resolved Hide resolved
@tadfisher
Copy link
Contributor Author

@jonringer Split documentation change into its own commit, and addressed your other feedback. Thank you!

@jtacoma
Copy link
Contributor

jtacoma commented Dec 29, 2020

Hey, this would be nice to have! It might later extended or forked to support building Flutter packages too!

I tried verifying on OSX, but my OSX environment is slightly broken right now.

I was unable to verify on Linux due to hash mismatch in fixed-output derivation '/nix/store/vkb6pj840jggj84fy75kaglxpzk7jksp-dart-sass-deps-1.26.10'. In fact, this is the same error that ofborg found here. Do we need a different approach to this problem? (Random thought: would a fromYAML directive be helpful?)

@nixos-discourse
Copy link

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/506

@roberth
Copy link
Member

roberth commented Apr 22, 2021

Is it feasible to fetch and hash the packages individually?

Right now if a package changes, there's no way to know what happened, let alone recover. Large (fragile) fixed-output derivations do make builds unreproducible.

sass = "sass";
};

meta = with stdenv.lib; {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
meta = with stdenv.lib; {
meta = with lib; {

@@ -0,0 +1,28 @@
{ stdenv, fetchFromGitHub, buildDartPackage }:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{ stdenv, fetchFromGitHub, buildDartPackage }:
{ lib, stdenv, fetchFromGitHub, buildDartPackage }:

Comment on lines +144 to +147
set -x
export PUB_CACHE="${pubCache}"
pub get --offline --no-precompile
${buildSnapshots}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
set -x
export PUB_CACHE="${pubCache}"
pub get --offline --no-precompile
${buildSnapshots}
set -x
export PUB_CACHE="${pubCache}"
pub get --offline --no-precompile
${buildSnapshots}

Comment on lines +81 to +83
inherit (stdenv.lib) concatStringsSep mapAttrsToList;
buildSnapshot = name: path:
with stdenv.lib; ''
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
inherit (stdenv.lib) concatStringsSep mapAttrsToList;
buildSnapshot = name: path:
with stdenv.lib; ''
inherit (lib) concatStringsSep mapAttrsToList;
buildSnapshot = name: path:
with lib; ''


diff = "${diffutils.nativeDrv or diffutils}/bin/diff";

dartOpts = with stdenv.lib;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
dartOpts = with stdenv.lib;
dartOpts = with lib;

@@ -0,0 +1,165 @@
{ stdenv, diffutils, dart, makeWrapper }:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{ stdenv, diffutils, dart, makeWrapper }:
{ lib, stdenv, diffutils, dart, makeWrapper }:

@@ -11,6 +11,7 @@
<xi:include href="bower.xml" />
<xi:include href="coq.xml" />
<xi:include href="crystal.section.xml" />
<xi:include href="dart.section.xml" />
Copy link
Member

Choose a reason for hiding this comment

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

Please convert this to markdown.

the value from the error output. The following output shows the value of
`pubSha256` for the `dart-sass` expression:

```
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
```
```ShellSession

sass = "sass";
};

meta = with stdenv.lib; {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
meta = with stdenv.lib; {
meta = with lib; {

expression for building `dart-sass`:

```nix
{ stdenv, fetchFromGitHub, buildDartPackage }:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{ stdenv, fetchFromGitHub, buildDartPackage }:
{ lib, stdenv, fetchFromGitHub, buildDartPackage }:

@tadfisher
Copy link
Contributor Author

@roberth Agreed; I am now using a different approach in https://github.com/tadfisher/nix-dart, although that repository requires flakes for now. I think I'll close this and look at porting that mechanism instead.

@tadfisher tadfisher closed this May 16, 2021
@roberth
Copy link
Member

roberth commented May 16, 2021

@tadfisher I'm glad you've found an even better approach. When porting those expressions to Nixpkgs, keep in mind that Hydra won't let you import from derivation (e.g. import "${nix-dart}/something.nix", but same for builtins.readFile etc).
If the derivation is static, you can copy the necessary files into nixpkgs and import those instead. If changes are necessary, hopefully upstream can be refactored to make maintenance easier.
If the derivation is a function of "user input" such as the package source they're trying to build, we'll need to work around that for packages that are packaged in Nixpkgs itself. For packages outside Nixpkgs, using a function that uses import from derivation is acceptable.

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.

None yet

6 participants