From 8d2ef7b4634ea4c2b9f2998ad2121813dcd6859d Mon Sep 17 00:00:00 2001 From: Chris Wells Date: Wed, 22 Oct 2025 09:24:40 -0500 Subject: Fixed up the code --- pkgs/weznix.nix | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 pkgs/weznix.nix (limited to 'pkgs/weznix.nix') diff --git a/pkgs/weznix.nix b/pkgs/weznix.nix new file mode 100644 index 0000000..0996dff --- /dev/null +++ b/pkgs/weznix.nix @@ -0,0 +1,61 @@ +{ wezterm, + makeWrapper, + writeText, + nixToLua, + lib, +}: +{ + configDirectory ? "~/.config/wezterm", + wrapConfig ? "WEZDEV", + luaPath, + extraWrapperArgs ? [], + extraPATH ? [], + pass ? {}, +}: let + inherit (nixToLua) toLua; + passables = { + inherit configDirectory wrapConfig luaPath; + wezterm = builtins.toString wezterm; + } // pass; + + wezinit = writeText "wezterm.lua" # lua + '' + package.preload["weznix"] = function() + return ${toLua passables} + end + + weznix = require('weznix') + + local cfgDir = weznix.luaPath + if (weznix.wrapConfig == false) or (type(weznix.wrapConfig) == "string" and os.getenv(weznix.wrapConfig == 1) then + cfgDir = weznix.configDirectory + end + + + require('wezterm').config_dir = cfgDir + + package.path = package.path .. ';' .. cfgDir .. '/?.lua' + package.cpath = package.cpath .. ';' .. cfgDir .. '/?.so' + + + return require('init') + ''; + + wrapperArgs = [ + # "--prefix" "PATH" ":" (lib.makeBinPath extraPATH) + "--set" "WEZTERM_CONFIG_FILE" (toString wezinit) + ] ++ extraWrapperArgs; + +in wezterm.overrideAttrs ({ postInstall ? "", nativeBuildInputs ? [], buildInputs ? [], ... }: { + nativeBuildInputs = nativeBuildInputs ++ [ makeWrapper ]; + + buildInputs = buildInputs ++ extraPATH; + + postInstall = postInstall ++ #bash + '' + + for bin in $out/bin/wezterm*; do + wrapProgram "$bin" ${lib.escapeShellArgs wrapperArgs} + done + ''; + }) -- cgit v1.2.3