depot/third_party/nixpkgs/pkgs/development/tools/misc/dart-sass/default.nix

82 lines
1.7 KiB
Nix
Raw Normal View History

{ lib
, fetchFromGitHub
, buildDartApplication
, buf
, protoc-gen-dart
, testers
, dart-sass
, runCommand
, writeText
}:
let
sass-language = fetchFromGitHub {
owner = "sass";
repo = "sass";
rev = "refs/tags/embedded-protocol-2.2.0";
hash = "sha256-rSjhQZnLL4UXhp8rBIcaEtQyE81utTfljJTkyhQW5wA=";
};
in
buildDartApplication rec {
pname = "dart-sass";
version = "1.68.0";
src = fetchFromGitHub {
owner = "sass";
repo = pname;
rev = version;
hash = "sha256-Q7pXYcEOqROxVMw5irB23i44PwhFz7YWBVJcftzu998=";
};
pubspecLockFile = ./pubspec.lock;
vendorHash = "sha256-ypKiiLW4Zr0rhTLTXzOoRqZsFC3nGzqUhPFdKKIWDmk=";
nativeBuildInputs = [
buf
protoc-gen-dart
];
preConfigure = ''
mkdir -p build
ln -s ${sass-language} build/language
HOME="$TMPDIR" buf generate
'';
dartCompileFlags = [ "--define=version=${version}" ];
meta = with lib; {
homepage = "https://github.com/sass/dart-sass";
description = "The reference implementation of Sass, written in Dart";
mainProgram = "sass";
license = licenses.mit;
maintainers = with maintainers; [ lelgenio ];
};
passthru.tests = {
version = testers.testVersion {
package = dart-sass;
command = "dart-sass --version";
};
simple = testers.testEqualContents {
assertion = "dart-sass compiles a basic scss file";
expected = writeText "expected" ''
body h1{color:#123}
'';
actual = runCommand "actual" {
nativeBuildInputs = [ dart-sass ];
base = writeText "base" ''
body {
$color: #123;
h1 {
color: $color;
}
}
'';
} ''
dart-sass --style=compressed $base > $out
'';
};
};
}