Merge pull request #268293 from drupol/bump/typst-preview

Bump Typst tools and VSCode extension
This commit is contained in:
Pol Dellaiera 2023-11-19 19:16:36 +01:00 committed by GitHub
commit 2cc73b2b7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 116 additions and 104 deletions

View File

@ -20,6 +20,7 @@
, millet
, shfmt
, typst-lsp
, typst-preview
, autoPatchelfHook
, zlib
, stdenv
@ -2297,37 +2298,26 @@ let
};
};
# Keep pkgs/tools/typesetting/typst-preview/default.nix in sync with this
# extension
mgt19937.typst-preview = buildVscodeMarketplaceExtension {
mktplcRef =
let
sources = {
"x86_64-linux" = {
arch = "linux-x64";
sha256 = "sha256-O8sFv23tlhJS6N8LRKkHcTJTupZejCLDRdVVCdDlWbA=";
};
"x86_64-darwin" = {
arch = "darwin-x64";
sha256 = "1npzjch67agswh3nm14dbbsx777daq2rdw1yny10jf3858z2qynr";
};
"aarch64-linux" = {
arch = "linux-arm64";
sha256 = "1vv1jfgnyjbmshh4w6rf496d9dpdsk3f0049ii4d9vi23igk4xpk";
};
"aarch64-darwin" = {
arch = "darwin-arm64";
sha256 = "0dfchzqm61kddq20zvp1pcpk1625b9wgj32ymc08piq06pbadk29";
};
};
in
{
mktplcRef = {
name = "typst-preview";
publisher = "mgt19937";
version = "0.6.1";
} // sources.${stdenv.system};
version = "0.9.1";
sha256 = "sha256-GHD/i+QOnItGEYG0bl/pVl+a4Dvn7SHhICJ14VfqMjE=";
};
nativeBuildInputs = lib.optionals stdenv.isLinux [ autoPatchelfHook ];
buildInputs = [
typst-preview
];
buildInputs = lib.optionals stdenv.isLinux [ stdenv.cc.cc.lib ];
nativeBuildInputs = [ jq moreutils ];
postInstall = ''
cd "$out/$installPrefix"
jq '.contributes.configuration.properties."typst-preview.executable".default = "${lib.getExe typst-preview}"' package.json | sponge package.json
'';
meta = {
description = "Typst Preview is an extension for previewing your Typst files in vscode instantly";
@ -2745,7 +2735,6 @@ let
};
};
nvarner.typst-lsp = buildVscodeMarketplaceExtension {
mktplcRef = {
name = "typst-lsp";
@ -2758,9 +2747,13 @@ let
nativeBuildInputs = [ jq moreutils ];
buildInputs = [
typst-lsp
];
postInstall = ''
cd "$out/$installPrefix"
jq '.contributes.configuration.properties."typst-lsp.serverPath".default = "${typst-lsp}/bin/typst-lsp"' package.json | sponge package.json
jq '.contributes.configuration.properties."typst-lsp.serverPath".default = "${lib.getExe typst-lsp}"' package.json | sponge package.json
'';
meta = {

View File

@ -3390,7 +3390,7 @@ dependencies = [
[[package]]
name = "typst-preview"
version = "0.9.0"
version = "0.9.1"
dependencies = [
"anyhow",
"chrono",

View File

@ -0,0 +1,94 @@
{ lib
, rustPlatform
, fetchFromGitHub
, mkYarnPackage
, fetchYarnDeps
, pkg-config
, libgit2
, openssl
, zlib
, stdenv
, darwin
}:
let
# Keep the vscode "mgt19937.typst-preview" extension in sync when updating
# this package at pkgs/applications/editors/vscode/extensions/default.nix
version = "0.9.1";
src = fetchFromGitHub {
owner = "Enter-tainer";
repo = "typst-preview";
rev = "v${version}";
hash = "sha256-VmUcnmTe5Ngcje0SSpOY13HUIfdxBMg8KwvZ1wupCqc=";
};
frontendSrc = "${src}/addons/frontend";
frontend = mkYarnPackage {
inherit version;
pname = "typst-preview-frontend";
src = frontendSrc;
packageJSON = ./package.json;
offlineCache = fetchYarnDeps {
yarnLock = "${frontendSrc}/yarn.lock";
hash = "sha256-7a7/UOfau84nLIAKj6Tn9rTUmeBJ7rYDFAdr55ZDLgA=";
};
buildPhase = ''
runHook preBuild
yarn --offline build
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp -R deps/typst-preview-frontend/dist $out
runHook postInstall
'';
doDist = false;
};
in
rustPlatform.buildRustPackage {
pname = "typst-preview";
inherit version src;
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"hayagriva-0.4.0" = "sha256-377lXL3+TO8U91OopMYEI0NrWWwzy6+O7B65bLhP+X4=";
"typst-0.9.0" = "sha256-+rnsUSGi3QZlbC4i8racsM4U6+l8oA9YjjUOtQAIWOk=";
"typst-ts-compiler-0.4.0-rc9" = "sha256-NVmbAodDRJBJlGGDRjaEcTHGoCeN4hNjIynIDKqvNbM=";
};
};
nativeBuildInputs = [
pkg-config
];
buildInputs = [
libgit2
openssl
zlib
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.CoreServices
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
];
prePatch = ''
mkdir -p addons/vscode/out/frontend
cp -R ${frontend}/* addons/vscode/out/frontend/
'';
meta = {
description = "Typst preview extension for VSCode";
homepage = "https://github.com/Enter-tainer/typst-preview/";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ berberman ];
mainProgram = "typst-preview";
};
}

View File

@ -1,73 +0,0 @@
{ lib, fetchFromGitHub, rustPlatform, fetchYarnDeps, mkYarnPackage, darwin
, stdenv }:
let
name = "typst-preview";
version = "0.9.0";
src = fetchFromGitHub {
owner = "Enter-tainer";
repo = name;
rev = "v${version}";
hash = "sha256-r/zDvfMvfvZqa3Xkzk70tIEyhc5LDwqc2A5MUuK2xC0=";
};
frontendSrc = "${src}/addons/frontend";
frontend = mkYarnPackage rec {
inherit version;
pname = "${name}-frontend";
src = frontendSrc;
packageJSON = ./package.json;
offlineCache = fetchYarnDeps {
yarnLock = "${frontendSrc}/yarn.lock";
hash = "sha256-7a7/UOfau84nLIAKj6Tn9rTUmeBJ7rYDFAdr55ZDLgA=";
};
buildPhase = ''
runHook preBuild
yarn --offline build
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp -R deps/${pname}/dist $out
runHook postInstall
'';
doDist = false;
};
in rustPlatform.buildRustPackage rec {
pname = name;
inherit version src;
buildInputs = lib.optionals stdenv.isDarwin
(with darwin.apple_sdk.frameworks; [
Security
SystemConfiguration
CoreServices
]);
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"hayagriva-0.4.0" = "sha256-377lXL3+TO8U91OopMYEI0NrWWwzy6+O7B65bLhP+X4=";
"typst-0.9.0" = "sha256-+rnsUSGi3QZlbC4i8racsM4U6+l8oA9YjjUOtQAIWOk=";
"typst-ts-compiler-0.4.0-rc9" =
"sha256-NVmbAodDRJBJlGGDRjaEcTHGoCeN4hNjIynIDKqvNbM=";
};
};
prePatch = ''
mkdir -p addons/vscode/out/frontend
cp -R ${frontend}/* addons/vscode/out/frontend/
'';
meta = with lib; {
description = "Preview your Typst files in vscode";
homepage = "https://github.com/Enter-tainer/typse-preview";
license = licenses.mit;
maintainers = with maintainers; [ berberman ];
mainProgram = "typst-preview";
};
}

View File

@ -14238,8 +14238,6 @@ with pkgs;
typst-live = callPackage ../tools/typesetting/typst-live { };
typst-preview = callPackage ../tools/typesetting/typst-preview { };
tz = callPackage ../tools/misc/tz { };
u9fs = callPackage ../servers/u9fs { };