diff options
| author | Chris Wells <chris@mathematicaster.org> | 2025-10-23 11:11:51 -0500 |
|---|---|---|
| committer | Chris Wells <chris@mathematicaster.org> | 2025-10-23 11:11:51 -0500 |
| commit | ca50606b98774565ba5f31caa6ec33601471480e (patch) | |
| tree | fda19026396c9d797bc43b9cc1d02caacd08c64a | |
| parent | c5f9420f4d111cccf4dc1bcc3ec35e75f68926e1 (diff) | |
| download | weznix-ca50606b98774565ba5f31caa6ec33601471480e.tar weznix-ca50606b98774565ba5f31caa6ec33601471480e.tar.gz weznix-ca50606b98774565ba5f31caa6ec33601471480e.tar.bz2 weznix-ca50606b98774565ba5f31caa6ec33601471480e.tar.lz weznix-ca50606b98774565ba5f31caa6ec33601471480e.tar.xz weznix-ca50606b98774565ba5f31caa6ec33601471480e.tar.zst weznix-ca50606b98774565ba5f31caa6ec33601471480e.zip | |
Debugging
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | flake.nix | 57 | ||||
| -rw-r--r-- | modules/flake-module.nix | 12 | ||||
| -rw-r--r-- | pkgs/weznix.nix | 45 | ||||
| -rw-r--r-- | test/init.lua | 9 |
5 files changed, 82 insertions, 43 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..726d2d6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +result +.direnv @@ -15,35 +15,44 @@ }; }; - outputs = inputs@{ self, flake-parts, ... }: flake-parts.lib.mkFlake { inherit inputs self; } { - systems = import inputs.systems; + outputs = inputs@{ self, flake-parts, ... }: let + weznix = import ./modules/flake-module.nix; + in flake-parts.lib.mkFlake { inherit inputs self; } { + systems = import inputs.systems; - imports = [ - inputs.treefmt-nix.flakeModule - ]; + imports = [ + inputs.treefmt-nix.flakeModule + weznix + ]; - flake = { - overlays.default = import ./overlays { nixToLua = import inputs.nixToLua; }; - flakeModules.default = import ./modules/flake-module.nix; - }; + flake = { + overlays.default = import ./overlays { nixToLua = import inputs.nixToLua; }; + flakeModules.default = weznix; + }; - perSystem = { system, pkgs, config, ... }: { - treefmt = { - programs.nixfmt = { - enable = true; - strict = true; + perSystem = { system, pkgs, config, ... }: { + treefmt = { + programs.nixfmt = { + enable = true; + strict = true; + }; + }; + + devShells.default = pkgs.mkShellNoCC { + inputsFrom = [ config.treefmt.devShell ]; + nativeBuildInputs = with pkgs; [ + nixd + statix + deadnix + ]; + }; + + weznix = { + wrapConfig = true; + luaPath = ./test; }; - }; - devShells.default = pkgs.mkShellNoCC { - inputsFrom = [ config.treefmt.devShell ]; - nativeBuildInputs = with pkgs; [ - nixd - statix - deadnix - ]; }; - }; - }; + }; } diff --git a/modules/flake-module.nix b/modules/flake-module.nix index c43be76..af1e799 100644 --- a/modules/flake-module.nix +++ b/modules/flake-module.nix @@ -1,9 +1,9 @@ { lib, flake-parts-lib, inputs, ... }: let inherit (lib) mkOption mkPackageOption types; - inherit (flake-parts-lib) mkPerSystemOptions; + inherit (flake-parts-lib) mkPerSystemOption; in { - perSystem = mkPerSystemOptions ({ pkgs, config, ... }: { + options.perSystem = mkPerSystemOption ({ pkgs, config, ... }: { options = { weznix = { wezterm = mkPackageOption pkgs "wezterm" {}; @@ -39,11 +39,11 @@ in { config = { packages = { - weznix = pkgs.callPackage ./pkgs/weznix.nix { - inherit (config.weznix) wezterm; + weznix = pkgs.callPackage ../pkgs/weznix.nix { + inherit (config.weznix) wezterm; nixToLua = import inputs.nixToLua; - } { - inherit (config.weznix) configDirectory luaPath wrapConfig extraPATH extraWrapperArgs pass; + } { + inherit (config.weznix) configDirectory luaPath wrapConfig extraPATH extraWrapperArgs pass; }; }; }; diff --git a/pkgs/weznix.nix b/pkgs/weznix.nix index 338ddf3..bd1bd3a 100644 --- a/pkgs/weznix.nix +++ b/pkgs/weznix.nix @@ -1,5 +1,6 @@ { wezterm, makeWrapper, + symlinkJoin, writeText, nixToLua, lib, @@ -27,14 +28,17 @@ weznix = require('weznix') local cfgDir = weznix.luaPath - if (weznix.wrapConfig == false) or (type(weznix.wrapConfig) == "string" and os.getenv(weznix.wrapConfig == 1) then + 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 + -- require('wezterm').config_dir = cfgDir + wezterm = require('wezterm') + wezterm.config_dir = cfgDir - package.path = package.path .. ';' .. cfgDir .. '/?.lua' + -- package.path = package.path .. ';' .. cfgDir .. '/?.lua' + package.path = cfgDir .. '/?.lua' package.cpath = package.cpath .. ';' .. cfgDir .. '/?.so' @@ -42,21 +46,36 @@ ''; wrapperArgs = [ - # "--prefix" "PATH" ":" (lib.makeBinPath extraPATH) "--set" "WEZTERM_CONFIG_FILE" (toString wezinit) + ] ++ lib.optionals (extraPATH != []) [ + "--prefix" "PATH" ":" (lib.makeBinPath extraPATH) ] ++ extraWrapperArgs; -in wezterm.overrideAttrs ({ postInstall ? "", nativeBuildInputs ? [], buildInputs ? [], ... }: { - nativeBuildInputs = nativeBuildInputs ++ [ makeWrapper ]; - - buildInputs = buildInputs ++ extraPATH; - - postInstall = # bash +in (symlinkJoin { + name = "wezterm"; + nativeBuildInputs = [ makeWrapper ]; + paths = [ wezterm ]; + postBuild = # bash '' - ${postInstall} - for bin in $out/bin/wezterm*; do wrapProgram "$bin" ${lib.escapeShellArgs wrapperArgs} done ''; - }) + }) // { + inherit (wezterm) version name passthru meta; +} + +# in wezterm.overrideAttrs ({ postInstall ? "", nativeBuildInputs ? [], buildInputs ? [], ... }: { +# nativeBuildInputs = nativeBuildInputs ++ [ makeWrapper ]; +# +# buildInputs = buildInputs ++ extraPATH; +# +# postInstall = # bash +# '' +# ${postInstall} +# +# for bin in $out/bin/wezterm*; do +# wrapProgram "$bin" ${lib.escapeShellArgs wrapperArgs} +# done +# ''; +# }) diff --git a/test/init.lua b/test/init.lua new file mode 100644 index 0000000..3d19de8 --- /dev/null +++ b/test/init.lua @@ -0,0 +1,9 @@ +local wezterm = require('wezterm') +local weznix = require('weznix') +local config = wezterm.config_builder() + +config.default_prog = { os.getenv("SHELL") } + +config.check_for_updates = false + +return config |
