aboutsummaryrefslogtreecommitdiff
path: root/modules/flake-module.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 /modules/flake-module.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 'modules/flake-module.nix')
-rw-r--r--modules/flake-module.nix137
1 files changed, 94 insertions, 43 deletions
diff --git a/modules/flake-module.nix b/modules/flake-module.nix
index af1e799..341e048 100644
--- a/modules/flake-module.nix
+++ b/modules/flake-module.nix
@@ -1,51 +1,102 @@
-{ lib, flake-parts-lib, inputs, ... }:
+{
+ lib,
+ flake-parts-lib,
+ inputs,
+ ...
+}:
let
inherit (lib) mkOption mkPackageOption types;
inherit (flake-parts-lib) mkPerSystemOption;
-in {
- options.perSystem = mkPerSystemOption ({ pkgs, config, ... }: {
- options = {
- weznix = {
- wezterm = mkPackageOption pkgs "wezterm" {};
- configDirectory = mkOption {
- type = types.str;
- default = "~/.config/wezterm";
- };
- luaPath = mkOption {
- type = types.path;
- description = "Path to wezterm config directory";
- };
- wrapConfig = mkOption {
- type = types.either types.bool types.str;
- default = "WEZDEV";
- };
- extraPATH = mkOption {
- type = types.listOf types.package;
- default = [];
- description = "Extra packages to add to wezterm's $PATH";
- };
- extraWrapperArgs = mkOption {
- type = types.listOf types.str;
- default = [];
- description = "Extra arguments to pass to `wrapProgram`";
- };
- pass = mkOption {
- type = types.lazyAttrsOf types.anything;
- default = {};
- description = "Anything else to pass into the lua config";
+in
+{
+ options.perSystem = mkPerSystemOption (
+ { pkgs, config, ... }:
+ {
+ options = {
+ weznix = {
+ wezterm = mkPackageOption pkgs "wezterm" { };
+ configDirectory = mkOption {
+ type = types.str;
+ default = "~/.config/wezterm";
+ description = ''
+ Location of wezterm config directory (see config.weznix.wrapConfig).
+ '';
+ };
+ luaPath = mkOption {
+ type = types.path;
+ description = ''
+ Path to wezterm config directory.
+ This path is copied into the nix store.
+ '';
+ };
+ mainFile = mkOption {
+ type = types.str;
+ default = "init";
+ apply = lib.removeSuffix ".lua";
+ description = "Name of the main *.lua file to load";
+ };
+ wrapConfig = mkOption {
+ type = types.either types.bool types.str;
+ default = "WEZDEV";
+ description = ''
+ true -> use config in nix store
+ false -> use config in ${config.weznix.configDirectory}
+ ENVVAR -> if $ENVVAR == 1
+ then use config in ${config.weznix.configDirectory}
+ else use config in nix store
+ '';
+ };
+ extraLuaInit = mkOption {
+ type = types.lines;
+ default = "";
+ description = ''
+ Extra lua code to place in the generated wezterm.lua.
+ This is likely unnecessary.
+ '';
+ };
+ extraPATH = mkOption {
+ type = types.listOf types.package;
+ default = [ ];
+ description = "Extra packages to add to wezterm's $PATH";
+ };
+ extraWrapperArgs = mkOption {
+ type = types.listOf types.str;
+ default = [ ];
+ description = "Extra arguments to pass to `wrapProgram`";
+ };
+ pass = mkOption {
+ type = types.lazyAttrsOf types.anything;
+ default = { };
+ description = ''
+ Anything else to pass into the lua config.
+ These values can then be accessed in your lua config from the table `require('weznix')`.
+ '';
+ };
};
};
- };
- config = {
- packages = {
- weznix = pkgs.callPackage ../pkgs/weznix.nix {
- inherit (config.weznix) wezterm;
- nixToLua = import inputs.nixToLua;
- } {
- inherit (config.weznix) configDirectory luaPath wrapConfig extraPATH extraWrapperArgs pass;
- };
+ config = {
+ packages = {
+ weznix =
+ pkgs.callPackage ../pkgs/weznix.nix
+ {
+ inherit (config.weznix) wezterm;
+ nixToLua = import inputs.nixToLua;
+ }
+ {
+ inherit (config.weznix)
+ configDirectory
+ luaPath
+ wrapConfig
+ mainFile
+ extraLuaInit
+ extraPATH
+ extraWrapperArgs
+ pass
+ ;
+ };
+ };
};
- };
- });
+ }
+ );
}