From 58742242b60d3313013bd7414fa4ab826ae13178 Mon Sep 17 00:00:00 2001 From: paki23 Date: Thu, 30 May 2024 23:36:22 +0200 Subject: [PATCH 01/22] xonsh:init --- modules/modules.nix | 1 + modules/programs/xonsh.nix | 64 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 modules/programs/xonsh.nix diff --git a/modules/modules.nix b/modules/modules.nix index 156094c85..28fb3450a 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -271,6 +271,7 @@ let ./programs/wpaperd.nix ./programs/xmobar.nix ./programs/xplr.nix + ./programs/xonsh.nix ./programs/yambar.nix ./programs/yazi.nix ./programs/yt-dlp.nix diff --git a/modules/programs/xonsh.nix b/modules/programs/xonsh.nix new file mode 100644 index 000000000..58e4eb27b --- /dev/null +++ b/modules/programs/xonsh.nix @@ -0,0 +1,64 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.programs.xonsh; + inherit (lib) types mkOption; +in { + options.programs.xonsh = { + enable = lib.mkEnableOption "xonsh"; + + package = lib.mkPackageOption pkgs "xonsh" { }; + finalPackage = lib.mkOption { + type = types.package; + internal = true; + description = "Package that will actually get installed"; + }; + xonshrc = mkOption { + type = types.lines; + default = ""; + description = '' + The contents of .xonshrc + ''; + }; + pythonPackages = mkOption { + type = types.raw; + default = pkgs.pythonPackages; + defaultText = "pkgs.pythonPackages"; + description = '' + The pythonPackages set extraPackages are taken from + ''; + }; + shellAliases = mkOption { + type = with types; attrsOf (listOf str); + default = { }; + example = { ll = [ "ls" "-l" ]; }; + description = '' + An attribute set that maps aliases (the top level attribute names in + this option) to commands + ''; + }; + extraPackages = mkOption { + type = with types; functionTo (listOf package); + default = _: [ ]; + defaultText = "_: []"; + description = '' + List of python packages and xontrib to make avaiable + ''; + }; + }; + config = lib.mkIf cfg.enable { + home.packages = [ cfg.finalPackage ]; + programs.xonsh = { + xonshrc = lib.mkMerge + (lib.mapAttrsToList (n: v: "aliases['${n}']=${builtins.toJSON v}") + cfg.shellAliases); + shellAliases = lib.mapAttrs (n: v: lib.mkDefault (lib.splitString " " v)) + config.home.shellAliases; + finalPackage = + (cfg.package.override (old: { inherit (cfg) extraPackages; })); + }; + xdg.configFile."xonsh/rc.xsh" = { + enable = cfg.xonshrc != ""; + text = cfg.xonshrc; + }; + }; +} From eca4f4eec887dcfd1dc9e873e23514ad5290f00a Mon Sep 17 00:00:00 2001 From: paki23 Date: Thu, 30 May 2024 23:36:42 +0200 Subject: [PATCH 02/22] thefuck: add xonsh integration --- modules/programs/thefuck.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/programs/thefuck.nix b/modules/programs/thefuck.nix index 79b1f9462..1a5574921 100644 --- a/modules/programs/thefuck.nix +++ b/modules/programs/thefuck.nix @@ -64,5 +64,9 @@ with lib; alias fuck = ${cfg.package}/bin/thefuck $"(history | last 1 | get command | get 0)" ''; }; + + programs.xonsh.xonshrc = '' + aliases["fuck"] = lambda args, stdin=None: execx($(${cfg.package}/bin/thefuck @(__xonsh__.history[-1].cmd))) + ''; }; } From be05908a13723fff0162fb0b3137425cf3723387 Mon Sep 17 00:00:00 2001 From: paki23 Date: Thu, 30 May 2024 23:55:48 +0200 Subject: [PATCH 03/22] zoxide: add xonsh integratiion --- modules/programs/zoxide.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/programs/zoxide.nix b/modules/programs/zoxide.nix index 23a18a357..b884af084 100644 --- a/modules/programs/zoxide.nix +++ b/modules/programs/zoxide.nix @@ -43,6 +43,14 @@ in { enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; }; + + enableXonshIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Xonsh integration. + ''; + }; }; config = mkIf cfg.enable { @@ -73,5 +81,9 @@ in { source ${config.xdg.cacheHome}/zoxide/init.nu ''; }; + + programs.xonsh.xonshrc = mkIf cfg.enableXonshIntegration '' + execx($(${cfg.package}/bin/zoxide init xonsh), 'exec', __xonsh__.ctx, filename='zoxide') + ''; }; } From 3df8492ee6ea65f59f7a77f7d40b3c561eb38afe Mon Sep 17 00:00:00 2001 From: paki23 Date: Fri, 31 May 2024 00:07:18 +0200 Subject: [PATCH 04/22] eza: add xonsh integration --- modules/programs/eza.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/programs/eza.nix b/modules/programs/eza.nix index 55a4a1001..0d18e1dc6 100644 --- a/modules/programs/eza.nix +++ b/modules/programs/eza.nix @@ -35,6 +35,9 @@ with lib; enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; }; + enableXonshIntegration = mkEnableOption "Xonsh integration" // { + default = true; + }; extraOptions = mkOption { type = types.listOf types.str; @@ -128,6 +131,18 @@ with lib; programs.ion.shellAliases = optionsAlias // optionalAttrs cfg.enableIonIntegration aliases; + programs.xonsh.shellAliases = { + eza = [ "eza" ] ++ optional cfg.icons "--icons" + ++ optional cfg.git "--git" ++ cfg.extraOptions; + } // optionalAttrs cfg.enableXonshIntegration + (builtins.mapAttrs (_name: value: lib.mkDefault value) { + ls = [ "eza" ]; + ll = [ "eza" "-l" ]; + la = [ "eza" "-a" ]; + lt = [ "eza" "--tree" ]; + lla = [ "eza" "-la" ]; + }); + programs.nushell.shellAliases = optionsAlias // optionalAttrs cfg.enableNushellIntegration aliases; }; From 306caf5739aaa9721f8785ad2d1ac405b19fa2e5 Mon Sep 17 00:00:00 2001 From: paki23 Date: Fri, 31 May 2024 00:17:13 +0200 Subject: [PATCH 05/22] starship: add xonsh integration --- modules/programs/starship.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/programs/starship.nix b/modules/programs/starship.nix index bb1c87b9c..fb0b97d69 100644 --- a/modules/programs/starship.nix +++ b/modules/programs/starship.nix @@ -68,6 +68,10 @@ in { enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; }; + enableXonshIntegration = mkEnableOption "Xonsh integration" // { + default = true; + }; + enableInteractive = mkOption { type = types.bool; default = true; @@ -125,6 +129,11 @@ in { end ''; + programs.xonsh.xonshrc = mkIf cfg.enableXonshIntegration '' + if $TERM != "dumb": + execx($(${starshipCmd} init xonsh)) + ''; + programs.nushell = mkIf cfg.enableNushellIntegration { # Unfortunately nushell doesn't allow conditionally sourcing nor # conditionally setting (global) environment variables, which is why the From b8fa66e4bdd0d153c33255c83a8a4f8cc4a3fffc Mon Sep 17 00:00:00 2001 From: paki23 Date: Fri, 31 May 2024 00:24:43 +0200 Subject: [PATCH 06/22] atuin: add xonsh integration --- modules/programs/atuin.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/programs/atuin.nix b/modules/programs/atuin.nix index 50e088b12..f708aed94 100644 --- a/modules/programs/atuin.nix +++ b/modules/programs/atuin.nix @@ -46,6 +46,16 @@ in { ''; }; + enableXonshIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Atuin's Xonsh integration. + + If enabled, this will bind the up-arrow key to open the Atuin history. + ''; + }; + flags = mkOption { default = [ ]; type = types.listOf types.str; @@ -124,6 +134,10 @@ in { ${lib.getExe cfg.package} init fish ${flagsStr} | source ''; + programs.xonsh.xonshrc = mkIf cfg.enableXonshIntegration '' + execx($(${cfg.package}/bin/atuin init xonsh)) + ''; + programs.nushell = mkIf cfg.enableNushellIntegration { extraEnv = '' let atuin_cache = "${config.xdg.cacheHome}/atuin" From e80277823fc1634fc62005f79136efdc5fad8dbf Mon Sep 17 00:00:00 2001 From: paki23 Date: Sat, 1 Jun 2024 19:54:56 +0200 Subject: [PATCH 07/22] carapace: add xonsh integration --- modules/programs/carapace.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/programs/carapace.nix b/modules/programs/carapace.nix index 09cc55635..5dcefc522 100644 --- a/modules/programs/carapace.nix +++ b/modules/programs/carapace.nix @@ -25,6 +25,10 @@ in { enableNushellIntegration = lib.hm.shell.mkNushellIntegrationOption { inherit config; }; + enableXonshIntegration = mkEnableOption "Xonsh integration" // { + default = true; + }; + enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; }; }; @@ -41,6 +45,10 @@ in { source <(${bin} _carapace zsh) ''; + xonsh.xonshrc = mkIf cfg.enableXonshIntegration '' + exec($(${bin} _carapace)) + ''; + fish.interactiveShellInit = mkIf cfg.enableFishIntegration '' ${bin} _carapace fish | source ''; From 3013370f7ccfeaff0b0201be982b76e903300278 Mon Sep 17 00:00:00 2001 From: paki23 Date: Mon, 3 Jun 2024 22:21:33 +0200 Subject: [PATCH 08/22] direnv: add xonsh support --- modules/programs/direnv.nix | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/modules/programs/direnv.nix b/modules/programs/direnv.nix index a387a4bc7..bdcad006a 100644 --- a/modules/programs/direnv.nix +++ b/modules/programs/direnv.nix @@ -57,7 +57,6 @@ in { Note, enabling the direnv module will always active its functionality for Fish since the direnv package automatically gets loaded in Fish. If this is not the case try adding - ```nix environment.pathsToLink = [ "/share/fish" ]; ``` @@ -69,6 +68,15 @@ in { readOnly = true; }; + enableXonshIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Xonsh integration. + ''; + }; + + enableNushellIntegration = lib.hm.shell.mkNushellIntegrationOption { inherit config; }; @@ -160,6 +168,27 @@ in { ) ''); + programs.xonsh = mkIf cfg.enableXonshIntegration { + xonshrc = "xontrib load direnv"; + extraPackages = ps: + [ + (ps.buildPythonPackage { + name = "xonsh-direnv"; + src = pkgs.fetchFromGitHub { + owner = "74th"; + repo = "xonsh-direnv"; + rev = "fd086e737a2d54495619a40d2a0f9e96475626e7"; + hash = "sha256-6/V7ZYMOB3E7TO7y8emC5lfdgeYxmfc/yLnEhjrWQ54="; + }; + postPatch = '' + substituteInPlace xontrib/direnv.xsh --replace '$(direnv' '$(${ + getExe cfg.package + }' + ''; + }) + ]; + }; + home.sessionVariables = lib.mkIf cfg.silent { DIRENV_LOG_FORMAT = ""; }; }; } From dd3ce8fed802a084f7e883ae3df6b4111189e6d6 Mon Sep 17 00:00:00 2001 From: paki23 Date: Tue, 18 Jun 2024 22:31:22 +0200 Subject: [PATCH 09/22] command-not-found: add xonsh integration --- .../programs/command-not-found/command-not-found.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/programs/command-not-found/command-not-found.nix b/modules/programs/command-not-found/command-not-found.nix index f1a790235..a0f78a4f5 100644 --- a/modules/programs/command-not-found/command-not-found.nix +++ b/modules/programs/command-not-found/command-not-found.nix @@ -48,6 +48,16 @@ in { config = mkIf cfg.enable { programs.bash.initExtra = shInit "command_not_found_handle"; programs.zsh.initExtra = shInit "command_not_found_handler"; + programs.xonsh.xonshrc = '' + @events.on_command_not_found + def _command_not_found_nix(cmd): + import os.path + if os.path.isfile(${builtins.toJSON cfg.dbPath}): + ${commandNotFound}/bin/command-not-found @(cmd) + else: + echo "$1: command not found" >&2 + return 127 + ''; home.packages = [ commandNotFound ]; }; From 35a843c2fa214ebb2610ef7643d63ff8f2c1b25e Mon Sep 17 00:00:00 2001 From: In'Maldrerah Eyllisitryanmitore Date: Tue, 19 Mar 2024 13:34:58 +0000 Subject: [PATCH 10/22] yazi: add xonsh integration --- modules/programs/yazi.nix | 21 +++++++++++++ tests/modules/programs/yazi/default.nix | 1 + .../yazi/xonsh-integration-enabled.nix | 31 +++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 tests/modules/programs/yazi/xonsh-integration-enabled.nix diff --git a/modules/programs/yazi.nix b/modules/programs/yazi.nix index 67fa6d291..3141020d5 100644 --- a/modules/programs/yazi.nix +++ b/modules/programs/yazi.nix @@ -6,6 +6,8 @@ let cfg = config.programs.yazi; tomlFormat = pkgs.formats.toml { }; + + in { meta.maintainers = with lib.maintainers; [ eljamm khaneliman xyenon ]; @@ -35,6 +37,8 @@ in { enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; }; + enableXonshIntegration = mkEnableOption "Xonsh integration"; + keymap = mkOption { type = tomlFormat.type; default = { }; @@ -193,6 +197,21 @@ in { rm -fp $tmp } ''; + + xonshIntegration = '' + def __yazi_init(): + def yy(args): + tmp = $(mktemp -t "yazi-cwd.XXXXX").strip() + $[yazi @(args) @(f"--cwd-file={tmp}")] + cwd = fp"{tmp}".read_text() + if cwd != "" and cwd != $PWD: + xonsh.dirstack.cd((cwd,)) + $[rm -f -- @(tmp)] + + aliases['yy'] = yy + __yazi_init() + del __yazi_init + ''; in { bash.initExtra = mkIf cfg.enableBashIntegration bashIntegration; @@ -205,6 +224,8 @@ in { mkIf cfg.enableNushellIntegration nushellIntegration; }; + programs.xonsh.xonshrc = mkIf cfg.enableXonshIntegration xonshIntegration; + xdg.configFile = { "yazi/keymap.toml" = mkIf (cfg.keymap != { }) { source = tomlFormat.generate "yazi-keymap" cfg.keymap; diff --git a/tests/modules/programs/yazi/default.nix b/tests/modules/programs/yazi/default.nix index ec543c84d..1e01e7f80 100644 --- a/tests/modules/programs/yazi/default.nix +++ b/tests/modules/programs/yazi/default.nix @@ -5,4 +5,5 @@ yazi-zsh-integration-enabled = ./zsh-integration-enabled.nix; yazi-fish-integration-enabled = ./fish-integration-enabled.nix; yazi-nushell-integration-enabled = ./nushell-integration-enabled.nix; + yazi-xonsh-integration-enabled = ./xonsh-integration-enabled.nix; } diff --git a/tests/modules/programs/yazi/xonsh-integration-enabled.nix b/tests/modules/programs/yazi/xonsh-integration-enabled.nix new file mode 100644 index 000000000..313198140 --- /dev/null +++ b/tests/modules/programs/yazi/xonsh-integration-enabled.nix @@ -0,0 +1,31 @@ +{ ... }: + +let + shellIntegration = '' + def __yazi_init(): + def ya(args): + tmp = $(mktemp -t "yazi-cwd.XXXXX") + $[yazi @(args) @(f"--cwd-file={tmp}")] + cwd = fp"{tmp}".read_text() + if cwd != "" and cwd != $PWD: + xonsh.dirstack.cd(cwd) + $[rm -f -- @(tmp)] + + aliases['ya'] = ya + __yazi_init() + del __yazi_init + ''; +in { + programs.xonsh.enable = true; + + programs.yazi = { + enable = true; + enableXonshIntegration = true; + }; + + test.stubs.yazi = { }; + + nmt.script = '' + assertFileContains home-files/.config/xonsh/rc.xsh '${shellIntegration}' + ''; +} From 619429a0a9bde08c285a898a4413e93e8808cc2d Mon Sep 17 00:00:00 2001 From: paki23 Date: Sun, 16 Feb 2025 14:55:13 +0100 Subject: [PATCH 11/22] direnv: use xonsh-direnv --- modules/programs/direnv.nix | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/modules/programs/direnv.nix b/modules/programs/direnv.nix index bdcad006a..c4811afe4 100644 --- a/modules/programs/direnv.nix +++ b/modules/programs/direnv.nix @@ -170,23 +170,7 @@ in { programs.xonsh = mkIf cfg.enableXonshIntegration { xonshrc = "xontrib load direnv"; - extraPackages = ps: - [ - (ps.buildPythonPackage { - name = "xonsh-direnv"; - src = pkgs.fetchFromGitHub { - owner = "74th"; - repo = "xonsh-direnv"; - rev = "fd086e737a2d54495619a40d2a0f9e96475626e7"; - hash = "sha256-6/V7ZYMOB3E7TO7y8emC5lfdgeYxmfc/yLnEhjrWQ54="; - }; - postPatch = '' - substituteInPlace xontrib/direnv.xsh --replace '$(direnv' '$(${ - getExe cfg.package - }' - ''; - }) - ]; + extraPackages = ps: [ pkgs.xonsh.xontrib.xonsh-direnv ]; }; home.sessionVariables = lib.mkIf cfg.silent { DIRENV_LOG_FORMAT = ""; }; From 793197a3cc8c9962546226cf3f9363a755e8ea33 Mon Sep 17 00:00:00 2001 From: paki23 Date: Sun, 16 Feb 2025 14:55:39 +0100 Subject: [PATCH 12/22] yazi: use official snippet --- modules/programs/yazi.nix | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/modules/programs/yazi.nix b/modules/programs/yazi.nix index 3141020d5..b5def4bbe 100644 --- a/modules/programs/yazi.nix +++ b/modules/programs/yazi.nix @@ -7,7 +7,6 @@ let cfg = config.programs.yazi; tomlFormat = pkgs.formats.toml { }; - in { meta.maintainers = with lib.maintainers; [ eljamm khaneliman xyenon ]; @@ -198,19 +197,19 @@ in { } ''; - xonshIntegration = '' - def __yazi_init(): - def yy(args): - tmp = $(mktemp -t "yazi-cwd.XXXXX").strip() - $[yazi @(args) @(f"--cwd-file={tmp}")] - cwd = fp"{tmp}".read_text() - if cwd != "" and cwd != $PWD: - xonsh.dirstack.cd((cwd,)) - $[rm -f -- @(tmp)] - aliases['yy'] = yy - __yazi_init() - del __yazi_init + xonshIntegration = '' + def _y(args): + tmp = $(mktemp -t "yazi-cwd.XXXXXX") + args.append(f"--cwd-file={tmp}") + $[yazi @(args)] + with open(tmp) as f: + cwd = f.read().strip() + if cwd != $PWD: + cd @(cwd) + rm -f -- @(tmp) + + aliases["${cfg.shellWrapperName}"] = _y ''; in { bash.initExtra = mkIf cfg.enableBashIntegration bashIntegration; From df0f6ca35e592e1234d94825f9a57ab1cabd01c1 Mon Sep 17 00:00:00 2001 From: paki23 Date: Sun, 16 Feb 2025 14:56:31 +0100 Subject: [PATCH 13/22] xonsh: better documentation for the extraPackages option --- modules/programs/xonsh.nix | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/programs/xonsh.nix b/modules/programs/xonsh.nix index 58e4eb27b..e7fe9a6a2 100644 --- a/modules/programs/xonsh.nix +++ b/modules/programs/xonsh.nix @@ -36,12 +36,20 @@ in { this option) to commands ''; }; - extraPackages = mkOption { - type = with types; functionTo (listOf package); - default = _: [ ]; - defaultText = "_: []"; + extraPackages = lib.mkOption { + default = (ps: [ ]); + type = with lib.types; + coercedTo (listOf lib.types.package) (v: (_: v)) + (functionTo (listOf lib.types.package)); description = '' - List of python packages and xontrib to make avaiable + Add the specified extra packages to the xonsh package. + Preferred over using `programs.xonsh.package` as it composes with `pkgs.xonsh.xontribs`. + Take care in using this option along with manually defining the package + option above, as the two can result in conflicting sets of build dependencies. + This option assumes that the package option has an overridable argument + called `extraPackages`, so if you override the package option but also + intend to use this option as in the case of many enableXonshIntegration options, + be sure that your resulting package still honors the necessary option. ''; }; }; From 7ad74bffb435d234738ec3019c2afff1d6e4c57b Mon Sep 17 00:00:00 2001 From: paki23 Date: Mon, 17 Feb 2025 21:34:32 +0100 Subject: [PATCH 14/22] direnv: typo --- modules/programs/direnv.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/direnv.nix b/modules/programs/direnv.nix index c4811afe4..db55d7339 100644 --- a/modules/programs/direnv.nix +++ b/modules/programs/direnv.nix @@ -170,7 +170,7 @@ in { programs.xonsh = mkIf cfg.enableXonshIntegration { xonshrc = "xontrib load direnv"; - extraPackages = ps: [ pkgs.xonsh.xontrib.xonsh-direnv ]; + extraPackages = ps: [ pkgs.xonsh.xontribs.xonsh-direnv ]; }; home.sessionVariables = lib.mkIf cfg.silent { DIRENV_LOG_FORMAT = ""; }; From faed3bdfcfc54ca213bd5b6dfeccd52940264bfd Mon Sep 17 00:00:00 2001 From: paki23 Date: Wed, 19 Feb 2025 21:43:04 +0100 Subject: [PATCH 15/22] yazi: dedup declaration --- modules/programs/yazi.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/programs/yazi.nix b/modules/programs/yazi.nix index b5def4bbe..3dfdd9a75 100644 --- a/modules/programs/yazi.nix +++ b/modules/programs/yazi.nix @@ -223,8 +223,6 @@ in { mkIf cfg.enableNushellIntegration nushellIntegration; }; - programs.xonsh.xonshrc = mkIf cfg.enableXonshIntegration xonshIntegration; - xdg.configFile = { "yazi/keymap.toml" = mkIf (cfg.keymap != { }) { source = tomlFormat.generate "yazi-keymap" cfg.keymap; From e757c135d2c67ce1b6b3e1cf5affae267bb701be Mon Sep 17 00:00:00 2001 From: paki23 Date: Wed, 19 Mar 2025 21:36:18 +0100 Subject: [PATCH 16/22] xonsh: formatting --- modules/programs/direnv.nix | 1 - modules/programs/yazi.nix | 25 ++++++++++++------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/modules/programs/direnv.nix b/modules/programs/direnv.nix index db55d7339..7ec95cd97 100644 --- a/modules/programs/direnv.nix +++ b/modules/programs/direnv.nix @@ -76,7 +76,6 @@ in { ''; }; - enableNushellIntegration = lib.hm.shell.mkNushellIntegrationOption { inherit config; }; diff --git a/modules/programs/yazi.nix b/modules/programs/yazi.nix index 3dfdd9a75..267465e27 100644 --- a/modules/programs/yazi.nix +++ b/modules/programs/yazi.nix @@ -197,20 +197,19 @@ in { } ''; + xonshIntegration = '' + def _y(args): + tmp = $(mktemp -t "yazi-cwd.XXXXXX") + args.append(f"--cwd-file={tmp}") + $[yazi @(args)] + with open(tmp) as f: + cwd = f.read().strip() + if cwd != $PWD: + cd @(cwd) + rm -f -- @(tmp) - xonshIntegration = '' - def _y(args): - tmp = $(mktemp -t "yazi-cwd.XXXXXX") - args.append(f"--cwd-file={tmp}") - $[yazi @(args)] - with open(tmp) as f: - cwd = f.read().strip() - if cwd != $PWD: - cd @(cwd) - rm -f -- @(tmp) - - aliases["${cfg.shellWrapperName}"] = _y - ''; + aliases["${cfg.shellWrapperName}"] = _y + ''; in { bash.initExtra = mkIf cfg.enableBashIntegration bashIntegration; From e0adf308bf9b5848039f6534c445b783f7da8613 Mon Sep 17 00:00:00 2001 From: paki23 Date: Wed, 19 Mar 2025 21:48:19 +0100 Subject: [PATCH 17/22] zoxide: replace mkOption with lib.mkOption --- modules/programs/zoxide.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/programs/zoxide.nix b/modules/programs/zoxide.nix index b884af084..b011f0006 100644 --- a/modules/programs/zoxide.nix +++ b/modules/programs/zoxide.nix @@ -14,7 +14,7 @@ in { options.programs.zoxide = { enable = mkEnableOption "zoxide"; - package = mkOption { + package = lib.mkOption { type = types.package; default = pkgs.zoxide; defaultText = literalExpression "pkgs.zoxide"; @@ -23,7 +23,7 @@ in { ''; }; - options = mkOption { + options = lib.mkOption { type = types.listOf types.str; default = [ ]; example = [ "--no-cmd" ]; @@ -44,7 +44,7 @@ in { enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; }; - enableXonshIntegration = mkOption { + enableXonshIntegration = lib.mkOption { default = true; type = types.bool; description = '' From 698d7865d5641a13eeb03f40e7b21d8a3b4d6a1f Mon Sep 17 00:00:00 2001 From: paki23 Date: Tue, 25 Mar 2025 21:28:36 +0100 Subject: [PATCH 18/22] yazi: readd xonsh --- modules/programs/yazi.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/programs/yazi.nix b/modules/programs/yazi.nix index 267465e27..9c0400ba4 100644 --- a/modules/programs/yazi.nix +++ b/modules/programs/yazi.nix @@ -220,6 +220,9 @@ in { nushell.extraConfig = mkIf cfg.enableNushellIntegration nushellIntegration; + + xonsh.xonshrc = + lib.mkif cfg.enableXonshIntegration xonshIntegration; }; xdg.configFile = { From 139f8ec7caba2d9638ba539e538bb7147b258941 Mon Sep 17 00:00:00 2001 From: paki23 Date: Tue, 25 Mar 2025 21:32:42 +0100 Subject: [PATCH 19/22] zoxide: fix test failure --- modules/programs/zoxide.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/zoxide.nix b/modules/programs/zoxide.nix index b011f0006..e736d45ab 100644 --- a/modules/programs/zoxide.nix +++ b/modules/programs/zoxide.nix @@ -82,7 +82,7 @@ in { ''; }; - programs.xonsh.xonshrc = mkIf cfg.enableXonshIntegration '' + programs.xonsh.xonshrc = lib.mkIf cfg.enableXonshIntegration '' execx($(${cfg.package}/bin/zoxide init xonsh), 'exec', __xonsh__.ctx, filename='zoxide') ''; }; From 963c2c90a4a6cba0ab0363405270280f6f6f8524 Mon Sep 17 00:00:00 2001 From: paki23 Date: Tue, 25 Mar 2025 21:36:21 +0100 Subject: [PATCH 20/22] yazi: fix xonsH --- modules/programs/yazi.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/programs/yazi.nix b/modules/programs/yazi.nix index 9c0400ba4..1985d2d3a 100644 --- a/modules/programs/yazi.nix +++ b/modules/programs/yazi.nix @@ -1,3 +1,4 @@ + { config, lib, pkgs, ... }: let inherit (lib) @@ -222,7 +223,7 @@ in { mkIf cfg.enableNushellIntegration nushellIntegration; xonsh.xonshrc = - lib.mkif cfg.enableXonshIntegration xonshIntegration; + lib.mkIf cfg.enableXonshIntegration xonshIntegration; }; xdg.configFile = { From c2e26b331f118f85053fd267f710ddc9951a3f40 Mon Sep 17 00:00:00 2001 From: Pasquale Di Maria Date: Sat, 29 Mar 2025 16:47:19 +0100 Subject: [PATCH 21/22] zoxide: fix build --- modules/programs/zoxide.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/zoxide.nix b/modules/programs/zoxide.nix index 27544cb5d..a18fa4f51 100644 --- a/modules/programs/zoxide.nix +++ b/modules/programs/zoxide.nix @@ -41,7 +41,7 @@ in { enableXonshIntegration = lib.mkOption { default = true; - type = types.bool; + type = lib.types.bool; description = '' Whether to enable Xonsh integration. ''; From 7151a1e09058b0081a297a2de6d6a4f150dcba98 Mon Sep 17 00:00:00 2001 From: Pasquale Di Maria Date: Sat, 29 Mar 2025 17:28:23 +0100 Subject: [PATCH 22/22] yazi: formatting --- modules/programs/yazi.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/programs/yazi.nix b/modules/programs/yazi.nix index 4ed6fc981..b8259597f 100644 --- a/modules/programs/yazi.nix +++ b/modules/programs/yazi.nix @@ -1,4 +1,3 @@ - { config, lib, pkgs, ... }: let inherit (lib) @@ -222,8 +221,7 @@ in { nushell.extraConfig = mkIf cfg.enableNushellIntegration nushellIntegration; - xonsh.xonshrc = - lib.mkIf cfg.enableXonshIntegration xonshIntegration; + xonsh.xonshrc = lib.mkIf cfg.enableXonshIntegration xonshIntegration; }; xdg.configFile = {