Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ian-h-chamberlain/787ae843a1b72c3e808a1c989d278b0f to your computer and use it in GitHub Desktop.

Select an option

Save ian-h-chamberlain/787ae843a1b72c3e808a1c989d278b0f to your computer and use it in GitHub Desktop.
Wezterm + yuescript nix recipe
From 9908f1bbec2c60b5c6e8a57bcaab2e25a48f8be7 Mon Sep 17 00:00:00 2001
From: Ian Chamberlain <ian.h.chamberlain@gmail.com>
Date: Fri, 10 Jul 2026 00:23:30 -0700
Subject: [PATCH] Enable `debug` and C modules with Lua::unsafe_new()
---
config/src/lua.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/src/lua.rs b/config/src/lua.rs
index 4f03194..8509f8e 100644
--- a/config/src/lua.rs
+++ b/config/src/lua.rs
@@ -207,11 +207,11 @@ fn config_builder_new_index<'lua>(
/// * `home_dir` - the path to the user's home directory
///
/// In addition to this, the lua standard library, except for
/// the `debug` module, is also available to the script.
pub fn make_lua_context(config_file: &Path) -> anyhow::Result<Lua> {
- let lua = Lua::new();
+ let lua = unsafe { Lua::unsafe_new() };
let config_dir = config_file.parent().unwrap_or_else(|| Path::new("/"));
{
let globals = lua.globals();
--
2.52.0
{
lua5_4,
wezterm,
yuescript ? lua5_4.pkgs.callPackage ./yuescript.nix { },
}:
wezterm.overrideAttrs (prev: {
patches = prev.patches or [ ] ++ [
./0001-Enable-debug-and-C-modules-with-Lua-unsafe_new.patch
];
nativeBuildInputs = prev.nativeBuildInputs ++ [ lua5_4.pkgs.wrapLua ];
buildInputs = prev.buildInputs ++ [ yuescript ];
postFixup = ''
wrapLuaProgramsIn "$out/bin" "$out ${yuescript}"
wrapLuaProgramsIn "$out/Applications/WezTerm.app" "$out ${yuescript}"
'';
})
{
buildLuarocksPackage,
cmake,
fetchFromGitHub,
lua,
luaOlder,
}:
buildLuarocksPackage {
pname = "yuescript";
version = "dev-1"; # TODO pin to tag?
src = fetchFromGitHub {
owner = "IppClub";
repo = "YueScript";
rev = "c9f3a486cfdad6e134ec88b1e43717508e066796";
hash = "sha256-/pWdafDtI4jAcJempvgyoP37fxuSEggRtHJ2bvjEfqw=";
};
disabled = luaOlder "5.3";
nativeBuildInputs = [
cmake
lua
];
meta = {
homepage = "https://github.com/IppClub/YueScript";
description = "Yuescript is a Moonscript dialect.";
license.fullName = "MIT";
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment