dart-sass: add passthru.updateScript

This commit is contained in:
lelgenio 2024-01-20 18:31:05 -03:00
parent 4a83b65029
commit 5d3f444f49
2 changed files with 77 additions and 26 deletions

View File

@ -10,10 +10,12 @@
}:
let
sass-language = fetchFromGitHub {
embedded-protocol-version = "2.3.0";
embedded-protocol = fetchFromGitHub {
owner = "sass";
repo = "sass";
rev = "refs/tags/embedded-protocol-2.3.0";
rev = "refs/tags/embedded-protocol-${embedded-protocol-version}";
hash = "sha256-J2heASfIwj4lxjsRs/0zRHSaF2tij9bO7IgXp0u/eiI=";
};
in
@ -37,7 +39,7 @@ buildDartApplication rec {
preConfigure = ''
mkdir -p build
ln -s ${sass-language} build/language
ln -s ${embedded-protocol} build/language
HOME="$TMPDIR" buf generate
'';
@ -51,31 +53,35 @@ buildDartApplication rec {
maintainers = with maintainers; [ lelgenio ];
};
passthru.tests = {
version = testers.testVersion {
package = dart-sass;
command = "dart-sass --version";
};
passthru = {
inherit embedded-protocol-version embedded-protocol;
updateScript = ./update.sh;
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;
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
'';
'';
} ''
dart-sass --style=compressed $base > $out
'';
};
};
};
}

View File

@ -0,0 +1,45 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p yq ripgrep common-updater-scripts dart
set -xeu -o pipefail
PACKAGE_DIR="$(realpath "$(dirname "$0")")"
cd "$PACKAGE_DIR/.."
while ! test -f default.nix; do cd .. ; done
NIXPKGS_DIR="$PWD"
dart_sass_version="$(
list-git-tags --url=https://github.com/sass/dart-sass \
| rg '^\d' \
| sort --version-sort \
| tail -n1
)"
embedded_protocol_version="$(
list-git-tags --url=https://github.com/sass/sass \
| rg '^embedded-protocol-(.*)' -r '$1' \
| sort --version-sort \
| tail -n1
)"
cd "$NIXPKGS_DIR"
update-source-version dart-sass "$dart_sass_version"
update-source-version dart-sass "$embedded_protocol_version" \
--version-key=embedded-protocol-version \
--source-key=embedded-protocol
TMPDIR="$(mktemp -d)"
cd "$TMPDIR"
src="$(nix-build --no-link "$NIXPKGS_DIR" -A dart-sass.src)"
cp $src/pubspec.* .
# Maybe one day upstream will ship a pubspec.lock,
# until then we must generate a fresh one
if ! test -f pubspec.lock; then
dart pub update
fi
yq . pubspec.lock > "$PACKAGE_DIR/pubspec.lock.json"
rm -rf "$TMPDIR"