Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pkgs/by-name/ne/neovim-unwrapped/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
nodejs ? null,
fish ? null,
python3 ? null,
wasmtime_29,
}:
stdenv.mkDerivation (
finalAttrs:
Expand Down Expand Up @@ -159,6 +160,7 @@ stdenv.mkDerivation (
cmake
gettext
pkg-config
wasmtime_29
];

# extra programs test via `make functionaltest`
Expand All @@ -177,8 +179,12 @@ stdenv.mkDerivation (
pyEnv # for src/clint.py
];

# loosen the version requirement for wasmtime to use the nixpkgs version
postPatch = ''
sed -i -E 's/find_package\(Wasmtime [0-9.]+ EXACT REQUIRED\)/find_package\(Wasmtime REQUIRED\)/' ./src/nvim/CMakeLists.txt
''
# nvim --version output retains compilation flags and references to build tools
postPatch = lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
+ lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
sed -i runtime/CMakeLists.txt \
-e "s|\".*/bin/nvim|\${stdenv.hostPlatform.emulator buildPackages} &|g"
sed -i src/nvim/po/CMakeLists.txt \
Expand All @@ -194,6 +200,7 @@ stdenv.mkDerivation (
# third-party/CMakeLists.txt is not read at all.
(lib.cmakeBool "USE_BUNDLED" false)
(lib.cmakeBool "ENABLE_TRANSLATIONS" true)
(lib.cmakeBool "ENABLE_WASMTIME" true)
]
++ (
if lua.pkgs.isLuaJIT then
Expand Down
34 changes: 31 additions & 3 deletions pkgs/by-name/wa/wasmtime/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,58 @@
stdenv,
rustPlatform,
fetchFromGitHub,
fetchpatch,
buildPackages,
cmake,
installShellFiles,
versionCheckHook,
nix-update-script,
enableShared ? !stdenv.hostPlatform.isStatic,
enableStatic ? stdenv.hostPlatform.isStatic,
majorVersion ? "38",
}:
rustPlatform.buildRustPackage (finalAttrs: {
pname = "wasmtime";
version = "38.0.3";
version =
{
"29" = "29.0.1";
"38" = "38.0.3";
}
.${majorVersion};

src = fetchFromGitHub {
owner = "bytecodealliance";
repo = "wasmtime";
tag = "v${finalAttrs.version}";
hash = "sha256-eszpPYtueCuAMIVrWKagS1qFCWGd0rVFTsCqRYaSGu4=";
hash =
{
"29" = "sha256-BYTPBerWCDGqcN3TpMLhtL92f413IjCgGDQqQUu5D7Y=";
"38" = "sha256-eszpPYtueCuAMIVrWKagS1qFCWGd0rVFTsCqRYaSGu4=";
}
.${majorVersion};
fetchSubmodules = true;
};

cargoPatches = lib.optionals (lib.versionOlder finalAttrs.version "30") [
(fetchpatch {
url = "https://github.com/bytecodealliance/wasmtime/commit/73ff15fb7f758c5f88952b1a0dc36a47f2665c4e.patch";
hash = "sha256-S8mroaw8nSTH1sExHajeYZRF0SeEUz2w+xpOxTqRMas=";
})
];

cargoHash =
{
"29" = "sha256-oRkZHAovgS5i8ScXpvkLYkC3x0qxwAfmBd5EPjwgyEI=";
"38" = "sha256-agTF0GszX1f6oqo9oIPMD/GSmwbL8Ovg52TmtPq/z78=";
}
.${majorVersion};

# release predates the lint, causes a build failure
RUSTFLAGS = lib.optionalString (lib.versionOlder finalAttrs.version "30") "-Amismatched_lifetime_syntaxes";

# Disable cargo-auditable until https://github.com/rust-secure-code/cargo-auditable/issues/124 is solved.
auditable = false;

cargoHash = "sha256-agTF0GszX1f6oqo9oIPMD/GSmwbL8Ovg52TmtPq/z78=";
cargoBuildFlags = [
"--package"
"wasmtime-cli"
Expand Down
31 changes: 30 additions & 1 deletion pkgs/development/tools/parsing/tree-sitter/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
substitute,
installShellFiles,
buildPackages,
cmake,
wasmtime_29,
enableShared ? !stdenv.hostPlatform.isStatic,
enableStatic ? stdenv.hostPlatform.isStatic,
wasmSupport ? true,
webUISupport ? false,
extraGrammars ? { },

Expand Down Expand Up @@ -165,23 +168,30 @@ let
);

allGrammars = builtins.attrValues builtGrammars;

in
rustPlatform.buildRustPackage {
pname = "tree-sitter";
inherit src version;

cargoHash = "sha256-4R5Y9yancbg/w3PhACtsWq0+gieUd2j8YnmEj/5eqkg=";

cargoBuildFeatures = lib.optionals wasmSupport [ "wasm" ];

buildInputs = [
installShellFiles
]
++ lib.optionals wasmSupport [
wasmtime_29
]
++ lib.optionals webUISupport [
openssl
];
nativeBuildInputs = [
which
]
++ lib.optionals wasmSupport [
cmake
]
++ lib.optionals webUISupport [
emscripten
pkg-config
Expand All @@ -198,6 +208,20 @@ rustPlatform.buildRustPackage {
--replace-fail 'let emcc_name = if cfg!(windows) { "emcc.bat" } else { "emcc" };' 'let emcc_name = "${lib.getExe' emscripten "emcc"}";'
'';

cmakeDir = lib.optionalString wasmSupport "../lib";
cmakeFlags = lib.optionals wasmSupport [
(lib.cmakeBool "TREE_SITTER_FEATURE_WASM" true)
# these are needed so we don't need to patch https://github.com/tree-sitter/tree-sitter/blob/v0.25.3/lib/tree-sitter.pc.in#L1-L3
(lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include")
(lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib")
];

# cmakeConfigurePhase already runs preConfigure & postConfigure
configurePhase = lib.optionalString wasmSupport ''
runHook cmakeConfigurePhase
cd ..
'';

# Compile web assembly with emscripten. The --debug flag prevents us from
# minifying the JavaScript; passing it allows us to side-step more Node
# JS dependencies for installation.
Expand All @@ -207,8 +231,13 @@ rustPlatform.buildRustPackage {
cargo run --package xtask -- build-wasm --debug
'';

postBuild = lib.optionalString wasmSupport ''
cmake --build $cmakeBuildDir
'';

postInstall = ''
PREFIX=$out make install
${lib.optionalString wasmSupport "cmake --install $cmakeBuildDir"}
${lib.optionalString (!enableShared) "rm $out/lib/*.so{,.*}"}
${lib.optionalString (!enableStatic) "rm $out/lib/*.a"}
''
Expand Down
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4188,6 +4188,8 @@ with pkgs;
stdenv = clangStdenv;
};

wasmtime_29 = pkgs.wasmtime.override { majorVersion = "29"; };

woodpecker-agent = callPackage ../development/tools/continuous-integration/woodpecker/agent.nix { };

woodpecker-cli = callPackage ../development/tools/continuous-integration/woodpecker/cli.nix { };
Expand Down
Loading