helix-unwrapped: init at 25.07.1 (#496253)

This commit is contained in:
Matthieu Coudron
2026-03-12 18:04:03 +00:00
committed by GitHub
5 changed files with 210 additions and 160 deletions
+46 -32
View File
@@ -5,44 +5,58 @@
installShellFiles,
nix-update-script,
rustPlatform,
runCommand,
makeBinaryWrapper,
}:
rustPlatform.buildRustPackage (finalAttrs: {
pname = "evil-helix";
version = "20250915";
rustPlatform.buildRustPackage (
finalAttrs:
let
defaultRuntimeDir = runCommand "evil-helix-default-runtime" { } ''
cp -r --no-preserve=mode ${finalAttrs.src}/runtime $out
rm -rf $out/grammars $out/queries
'';
in
{
pname = "evil-helix";
version = "20250915";
src = fetchFromGitHub {
owner = "usagi-flow";
repo = "evil-helix";
tag = "release-${finalAttrs.version}";
hash = "sha256-6kqKTZNS1RZwfxcFoa2uC7fUKcQ+KhT5KXusyCt59YQ=";
};
src = fetchFromGitHub {
owner = "usagi-flow";
repo = "evil-helix";
tag = "release-${finalAttrs.version}";
hash = "sha256-6kqKTZNS1RZwfxcFoa2uC7fUKcQ+KhT5KXusyCt59YQ=";
};
cargoHash = "sha256-Mf0nrgMk1MlZkSyUN6mlM5lmTcrOHn3xBNzmVGtApEU=";
cargoHash = "sha256-Mf0nrgMk1MlZkSyUN6mlM5lmTcrOHn3xBNzmVGtApEU=";
nativeBuildInputs = [ installShellFiles ];
nativeBuildInputs = [
installShellFiles
makeBinaryWrapper
];
env = {
# disable fetching and building of tree-sitter grammars in the helix-term build.rs
HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
HELIX_DEFAULT_RUNTIME = helix.runtime;
};
env = {
# disable fetching and building of tree-sitter grammars in the helix-term build.rs
HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
HELIX_DEFAULT_RUNTIME = defaultRuntimeDir;
};
postInstall = ''
mkdir -p $out/lib
installShellCompletion contrib/completion/hx.{bash,fish,zsh}
mkdir -p $out/share/{applications,icons/hicolor/256x256/apps}
cp contrib/Helix.desktop $out/share/applications
cp contrib/helix.png $out/share/icons/hicolor/256x256/apps
'';
postInstall = ''
installShellCompletion contrib/completion/hx.{bash,fish,zsh}
mkdir -p $out/share/{applications,icons/hicolor/256x256/apps}
cp contrib/Helix.desktop $out/share/applications
cp contrib/helix.png $out/share/icons/hicolor/256x256/apps
wrapProgram $out/bin/hx --set HELIX_RUNTIME ${helix.runtime}
'';
passthru.updateScript = nix-update-script { };
passthru.updateScript = nix-update-script { };
meta = {
description = "Post-modern modal text editor, with vim keybindings";
homepage = "https://github.com/usagi-flow/evil-helix";
license = lib.licenses.mpl20;
mainProgram = "hx";
maintainers = with lib.maintainers; [ thiagokokada ];
};
})
meta = {
description = "Post-modern modal text editor, with vim keybindings";
homepage = "https://github.com/usagi-flow/evil-helix";
license = lib.licenses.mpl20;
mainProgram = "hx";
maintainers = with lib.maintainers; [ thiagokokada ];
};
}
)
@@ -0,0 +1,91 @@
{
lib,
rustPlatform,
fetchFromGitHub,
runCommand,
installShellFiles,
mdbook,
versionCheckHook,
}:
rustPlatform.buildRustPackage (
finalAttrs:
let
defaultRuntimeDir = runCommand "helix-default-runtime" { } ''
cp -r --no-preserve=mode ${finalAttrs.src}/runtime $out
rm -rf $out/grammars $out/queries
'';
in
{
pname = "helix-unwrapped";
version = "25.07.1";
outputs = [
"out"
"doc"
];
src = fetchFromGitHub {
owner = "helix-editor";
repo = "helix";
tag = finalAttrs.version;
hash = "sha256-RFSzGAcB0mMg/02ykYfTWXzQjLFu2CJ4BkS5HZ/6pBo=";
};
cargoHash = "sha256-Mf0nrgMk1MlZkSyUN6mlM5lmTcrOHn3xBNzmVGtApEU=";
patches = [
# Support mdbook 0.5.x: escape HTML tags in command descriptions
./mdbook-0.5-support.patch
];
postPatch = ''
# mdbook 0.5 uses asset hashing for CSS/JS files
# Remove custom theme to use default mdbook theme with correct asset references
rm -f book/theme/index.hbs
'';
nativeBuildInputs = [
installShellFiles
mdbook
];
env = {
# disable fetching and building of tree-sitter grammars in the helix-term build.rs
HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
HELIX_DEFAULT_RUNTIME = defaultRuntimeDir;
};
postBuild = ''
mdbook build book -d ../book-html
'';
postInstall = ''
installShellCompletion contrib/completion/hx.{bash,fish,zsh}
mkdir -p $out/share/{applications,icons/hicolor/256x256/apps}
cp contrib/Helix.desktop $out/share/applications/Helix.desktop
cp contrib/helix.png $out/share/icons/hicolor/256x256/apps/helix.png
mkdir -p $doc/share/doc
cp -r ../book-html $doc/share/doc/$name
'';
nativeInstallCheckInputs = [
versionCheckHook
];
versionCheckProgram = "${placeholder "out"}/bin/hx";
doInstallCheck = true;
meta = {
description = "Post-modern modal text editor";
homepage = "https://helix-editor.com";
changelog = "https://github.com/helix-editor/helix/blob/${finalAttrs.version}/CHANGELOG.md";
license = lib.licenses.mpl20;
mainProgram = "hx";
maintainers = with lib.maintainers; [
aciceri
danth
yusdacra
];
};
}
)
+71 -126
View File
@@ -1,12 +1,9 @@
{
fetchFromGitHub,
lib,
rustPlatform,
mdbook,
gitMinimal,
installShellFiles,
versionCheckHook,
symlinkJoin,
runCommand,
makeBinaryWrapper,
helix-unwrapped,
removeReferencesTo,
pkgs,
tree-sitter,
@@ -22,133 +19,81 @@
}
),
}:
let
lockedVersionsOverlay =
final: prev:
lib.mapAttrs (
drvName: grammar:
let
lockedGrammar = lockedGrammars.${lib.removePrefix "tree-sitter-" drvName};
in
(prev.${drvName}.override {
location = lockedGrammar.subpath;
}).overrideAttrs
{
version = lib.sources.shortRev lockedGrammar.nurl.args.rev;
src = (pkgs.${lockedGrammar.nurl.fetcher} lockedGrammar.nurl.args);
}
) prev;
rustPlatform.buildRustPackage (
finalAttrs:
let
lockedVersionsOverlay =
final: prev:
lib.mapAttrs (
drvName: grammar:
let
lockedGrammar = lockedGrammars.${lib.removePrefix "tree-sitter-" drvName};
in
(prev.${drvName}.override {
location = lockedGrammar.subpath;
}).overrideAttrs
{
version = lib.sources.shortRev lockedGrammar.nurl.args.rev;
src = (pkgs.${lockedGrammar.nurl.fetcher} lockedGrammar.nurl.args);
}
) prev;
tree-sitter-grammars =
lib.filterAttrs (drvName: _: lib.hasAttr (lib.removePrefix "tree-sitter-" drvName) lockedGrammars)
(
tree-sitter.grammarsScope.overrideScope (
lib.composeExtensions lockedVersionsOverlay grammarsOverlay
)
);
tree-sitter-grammars =
lib.filterAttrs (drvName: _: lib.hasAttr (lib.removePrefix "tree-sitter-" drvName) lockedGrammars)
(
tree-sitter.grammarsScope.overrideScope (
lib.composeExtensions lockedVersionsOverlay grammarsOverlay
)
);
# Dynamic libraries for the grammars always use the `.so` extension, also on Darwin (should use `.dylib`)
# See here: https://github.com/helix-editor/helix/pull/14982
# Switch to `stdenv.hostPlatform.extensions.sharedLibrary` once the fix above reaches the next release
# Dynamic libraries for the grammars always use the `.so` extension, also on Darwin (should use `.dylib`)
# See here: https://github.com/helix-editor/helix/pull/14982
# Switch to `stdenv.hostPlatform.extensions.sharedLibrary` once the fix above reaches the next release
grammarsFarm = runCommand "helix-grammars" { } (
lib.concatMapAttrsStringSep "\n" (_: grammar: ''
install -D ${grammar}/parser $out/${grammar.language}.so
${lib.getExe removeReferencesTo} -t ${grammar} $out/${grammar.language}.so
'') (lib.filterAttrs (_: lib.isDerivation) tree-sitter-grammars)
);
grammarsFarm = runCommand "helix-grammars" { } (
lib.concatMapAttrsStringSep "\n" (_: grammar: ''
install -D ${grammar}/parser $out/${grammar.language}.so
${lib.getExe removeReferencesTo} -t ${grammar} $out/${grammar.language}.so
'') (lib.filterAttrs (_: lib.isDerivation) tree-sitter-grammars)
);
lockedGrammarsCount = lib.length (lib.attrNames lockedGrammars);
lockedGrammarsCount = lib.length (lib.attrNames lockedGrammars);
runtimeDir = runCommand "helix-runtime" { } ''
mkdir -p $out
ln -s ${grammarsFarm} $out/grammars
cp -r --no-preserve=mode ${helix-unwrapped.src}/runtime/queries $out
count=$(ls -1 "$out/grammars/" | wc -l)
if [ "$count" -ne ${toString lockedGrammarsCount} ]; then
echo "Expected ${toString lockedGrammarsCount} grammars, found $count"
exit 1
fi
'';
in
runtimeDir = runCommand "helix-runtime" { } ''
cp -r --no-preserve=mode ${finalAttrs.src}/runtime $out
rm -r $out/grammars
ln -s ${grammarsFarm} $out/grammars
count=$(ls -1 "$out/grammars/" | wc -l)
if [ "$count" -ne ${toString lockedGrammarsCount} ]; then
echo "Expected ${toString lockedGrammarsCount} grammars, found $count"
exit 1
fi
'';
in
{
pname = "helix";
version = "25.07.1";
outputs = [
"out"
"doc"
];
symlinkJoin {
pname = "helix";
inherit (helix-unwrapped) version;
src = fetchFromGitHub {
owner = "helix-editor";
repo = "helix";
tag = "${finalAttrs.version}";
hash = "sha256-RFSzGAcB0mMg/02ykYfTWXzQjLFu2CJ4BkS5HZ/6pBo=";
};
paths = [ helix-unwrapped ];
nativeBuildInputs = [ makeBinaryWrapper ];
patches = [
# Support mdbook 0.5.x: escape HTML tags in command descriptions
./mdbook-0.5-support.patch
];
postBuild = ''
wrapProgram $out/bin/hx --set HELIX_RUNTIME "${runtimeDir}"
'';
postPatch = ''
# mdbook 0.5 uses asset hashing for CSS/JS files
# Remove custom theme to use default mdbook theme with correct asset references
rm -f book/theme/index.hbs
'';
passthru = {
updateScript = ./update.sh;
runtime = runtimeDir;
inherit tree-sitter-grammars;
};
cargoHash = "sha256-Mf0nrgMk1MlZkSyUN6mlM5lmTcrOHn3xBNzmVGtApEU=";
nativeBuildInputs = [
gitMinimal
installShellFiles
mdbook
];
env = {
HELIX_DEFAULT_RUNTIME = runtimeDir;
HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
};
postBuild = ''
mdbook build book -d ../book-html
'';
postInstall = ''
mkdir -p $out/lib $doc/share/doc
installShellCompletion contrib/completion/hx.{bash,fish,zsh}
mkdir -p $out/share/{applications,icons/hicolor/256x256/apps}
cp contrib/Helix.desktop $out/share/applications/Helix.desktop
cp contrib/helix.png $out/share/icons/hicolor/256x256/apps/helix.png
cp -r ../book-html $doc/share/doc/$name
'';
nativeInstallCheckInputs = [
versionCheckHook
];
versionCheckProgram = "${placeholder "out"}/bin/hx";
doInstallCheck = true;
passthru = {
updateScript = ./update.sh;
runtime = runtimeDir;
inherit tree-sitter-grammars;
};
meta = {
description = "Post-modern modal text editor";
homepage = "https://helix-editor.com";
changelog = "https://github.com/helix-editor/helix/blob/${finalAttrs.version}/CHANGELOG.md";
license = lib.licenses.mpl20;
mainProgram = "hx";
maintainers = with lib.maintainers; [
aciceri
danth
yusdacra
];
};
}
)
meta = {
inherit (helix-unwrapped.meta)
description
homepage
changelog
license
mainProgram
maintainers
;
};
}
+2 -2
View File
@@ -6,10 +6,10 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "Updating helix source to the latest stable..."
nix-update helix
nix-update helix-unwrapped
echo "Fetching updated helixSource..."
HELIX_SRC=$(nix-instantiate --eval -A "helix.src.outPath" --raw)
HELIX_SRC=$(nix-instantiate --eval -A "helix-unwrapped.src.outPath" --raw)
echo "Generating grammars.json..."
"$SCRIPT_DIR/generate_grammars.py" \