aboutsummaryrefslogtreecommitdiff
path: root/pkgs/weznix.nix
diff options
context:
space:
mode:
authorChris Wells <chris@mathematicaster.org>2025-11-14 09:22:43 -0600
committerChris Wells <chris@mathematicaster.org>2025-11-14 09:22:43 -0600
commitc274a47faa397ccd80add222263482f263919814 (patch)
treed59fed5dd67499c8d759b5e9a376963215a2f506 /pkgs/weznix.nix
parent7f1c5fa4afe6c6c5c3316da0f622698f1b2ab368 (diff)
downloadweznix-c274a47faa397ccd80add222263482f263919814.tar
weznix-c274a47faa397ccd80add222263482f263919814.tar.gz
weznix-c274a47faa397ccd80add222263482f263919814.tar.bz2
weznix-c274a47faa397ccd80add222263482f263919814.tar.lz
weznix-c274a47faa397ccd80add222263482f263919814.tar.xz
weznix-c274a47faa397ccd80add222263482f263919814.tar.zst
weznix-c274a47faa397ccd80add222263482f263919814.zip
Fixed lua init script + added option to declaire mainFile
Diffstat (limited to 'pkgs/weznix.nix')
-rw-r--r--pkgs/weznix.nix86
1 files changed, 56 insertions, 30 deletions
diff --git a/pkgs/weznix.nix b/pkgs/weznix.nix
index 333488e..5339e32 100644
--- a/pkgs/weznix.nix
+++ b/pkgs/weznix.nix
@@ -1,4 +1,5 @@
-{ wezterm,
+{
+ wezterm,
makeWrapper,
writeText,
nixToLua,
@@ -8,46 +9,70 @@
configDirectory ? "~/.config/wezterm",
wrapConfig ? "WEZDEV",
luaPath,
- extraWrapperArgs ? [],
- extraPATH ? [],
- pass ? {},
-}: let
+ mainFile ? "init",
+ extraLuaInit ? "",
+ extraWrapperArgs ? [ ],
+ extraPATH ? [ ],
+ pass ? { },
+}:
+let
inherit (nixToLua) toLua;
passables = {
inherit configDirectory wrapConfig luaPath;
wezterm = builtins.toString wezterm;
- } // pass;
+ mainFile =
+ if (mainFile == "wezterm" || mainFile == "weznix") then
+ throw "mainFile cannot be named 'wezterm' or 'weznix'"
+ else
+ mainFile;
+ }
+ // pass;
- wezinit = writeText "wezterm.lua" # lua
- ''
- package.preload["weznix"] = function()
- return ${toLua passables}
- end
+ wezinit =
+ writeText "wezterm.lua" # lua
+ ''
+ package.preload["weznix"] = function()
+ return ${toLua passables}
+ end
- weznix = require('weznix')
+ local 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
+ local cfgDir = weznix.luaPath
+ if (weznix.wrapConfig == false) or (type(weznix.wrapConfig) == "string" and os.getenv(weznix.wrapConfig) == "1") then
+ cfgDir = weznix.configDirectory
+ end
- wezterm = require('wezterm')
- wezterm.config_dir = cfgDir
+ local wezterm = require('wezterm')
+ wezterm.config_dir = cfgDir
- package.path = cfgDir .. '/?.lua'
- package.cpath = package.cpath .. ';' .. cfgDir .. '/?.so'
+ package.path = cfgDir .. '/?.lua'
+ package.cpath = package.cpath .. ';' .. cfgDir .. '/?.so'
+ ${extraLuaInit}
- return require('init')
- '';
+ return require(weznix.mainFile)
+ '';
wrapperArgs = [
- "--set" "WEZTERM_CONFIG_FILE" (toString wezinit)
- ] ++ lib.optionals (extraPATH != []) [
- "--prefix" "PATH" ":" (lib.makeBinPath extraPATH)
- ] ++ extraWrapperArgs;
-
-in wezterm.overrideAttrs ({ nativeBuildInputs ? [], ... }: {
+ "--set"
+ "WEZTERM_CONFIG_FILE"
+ (builtins.toString wezinit)
+ ]
+ ++ lib.optionals (extraPATH != [ ]) [
+ "--prefix"
+ "PATH"
+ ":"
+ (lib.makeBinPath extraPATH)
+ ]
+ ++ extraWrapperArgs;
+
+in
+wezterm.overrideAttrs (
+ {
+ nativeBuildInputs ? [ ],
+ ...
+ }:
+ {
nativeBuildInputs = nativeBuildInputs ++ [ makeWrapper ];
separateDebugInfo = false;
@@ -78,7 +103,8 @@ in wezterm.overrideAttrs ({ nativeBuildInputs ? [], ... }: {
sed "s|${wezterm.out}|$out|g" "$src" > "$dsk"
done
- shopt -u nullglob # Revert nullglob back to its normal default state
+ shopt -u nullglob
'';
- })
+ }
+)