diff options
| author | Chris Wells <chris@mathematicaster.org> | 2025-10-22 09:24:40 -0500 |
|---|---|---|
| committer | Chris Wells <chris@mathematicaster.org> | 2025-10-22 09:24:40 -0500 |
| commit | 8d2ef7b4634ea4c2b9f2998ad2121813dcd6859d (patch) | |
| tree | c7e290745646f2e6d7b80c797106c4817314aa35 /pkgs/weznix.nix | |
| download | weznix-8d2ef7b4634ea4c2b9f2998ad2121813dcd6859d.tar weznix-8d2ef7b4634ea4c2b9f2998ad2121813dcd6859d.tar.gz weznix-8d2ef7b4634ea4c2b9f2998ad2121813dcd6859d.tar.bz2 weznix-8d2ef7b4634ea4c2b9f2998ad2121813dcd6859d.tar.lz weznix-8d2ef7b4634ea4c2b9f2998ad2121813dcd6859d.tar.xz weznix-8d2ef7b4634ea4c2b9f2998ad2121813dcd6859d.tar.zst weznix-8d2ef7b4634ea4c2b9f2998ad2121813dcd6859d.zip | |
Fixed up the code
Diffstat (limited to 'pkgs/weznix.nix')
| -rw-r--r-- | pkgs/weznix.nix | 61 |
1 files changed, 61 insertions, 0 deletions
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 + ''; + }) |
