mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-31 04:04:32 +00:00
Merge 7151a1e090
into 7170300119
This commit is contained in:
commit
d35cac5e16
13 changed files with 210 additions and 2 deletions
|
@ -284,6 +284,7 @@ let
|
||||||
./programs/wofi.nix
|
./programs/wofi.nix
|
||||||
./programs/xmobar.nix
|
./programs/xmobar.nix
|
||||||
./programs/xplr.nix
|
./programs/xplr.nix
|
||||||
|
./programs/xonsh.nix
|
||||||
./programs/yambar.nix
|
./programs/yambar.nix
|
||||||
./programs/yazi.nix
|
./programs/yazi.nix
|
||||||
./programs/yt-dlp.nix
|
./programs/yt-dlp.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 {
|
flags = mkOption {
|
||||||
default = [ ];
|
default = [ ];
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
|
@ -124,6 +134,10 @@ in {
|
||||||
${lib.getExe cfg.package} init fish ${flagsStr} | source
|
${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 {
|
programs.nushell = mkIf cfg.enableNushellIntegration {
|
||||||
extraEnv = ''
|
extraEnv = ''
|
||||||
let atuin_cache = "${config.xdg.cacheHome}/atuin"
|
let atuin_cache = "${config.xdg.cacheHome}/atuin"
|
||||||
|
|
|
@ -25,6 +25,10 @@ in {
|
||||||
enableNushellIntegration =
|
enableNushellIntegration =
|
||||||
lib.hm.shell.mkNushellIntegrationOption { inherit config; };
|
lib.hm.shell.mkNushellIntegrationOption { inherit config; };
|
||||||
|
|
||||||
|
enableXonshIntegration = mkEnableOption "Xonsh integration" // {
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
|
||||||
enableZshIntegration =
|
enableZshIntegration =
|
||||||
lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
||||||
};
|
};
|
||||||
|
@ -41,6 +45,10 @@ in {
|
||||||
source <(${bin} _carapace zsh)
|
source <(${bin} _carapace zsh)
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
xonsh.xonshrc = mkIf cfg.enableXonshIntegration ''
|
||||||
|
exec($(${bin} _carapace))
|
||||||
|
'';
|
||||||
|
|
||||||
fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
|
fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
|
||||||
${bin} _carapace fish | source
|
${bin} _carapace fish | source
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -47,7 +47,17 @@ in {
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs.bash.initExtra = shInit "command_not_found_handle";
|
programs.bash.initExtra = shInit "command_not_found_handle";
|
||||||
programs.zsh.initContent = shInit "command_not_found_handler";
|
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 ];
|
home.packages = [ commandNotFound ];
|
||||||
};
|
};
|
||||||
|
|
|
@ -57,7 +57,6 @@ in {
|
||||||
Note, enabling the direnv module will always activate its functionality
|
Note, enabling the direnv module will always activate its functionality
|
||||||
for Fish since the direnv package automatically gets loaded in Fish.
|
for Fish since the direnv package automatically gets loaded in Fish.
|
||||||
If this is not the case try adding
|
If this is not the case try adding
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
environment.pathsToLink = [ "/share/fish" ];
|
environment.pathsToLink = [ "/share/fish" ];
|
||||||
```
|
```
|
||||||
|
@ -69,6 +68,14 @@ in {
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enableXonshIntegration = mkOption {
|
||||||
|
default = true;
|
||||||
|
type = types.bool;
|
||||||
|
description = ''
|
||||||
|
Whether to enable Xonsh integration.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
enableNushellIntegration =
|
enableNushellIntegration =
|
||||||
lib.hm.shell.mkNushellIntegrationOption { inherit config; };
|
lib.hm.shell.mkNushellIntegrationOption { inherit config; };
|
||||||
|
|
||||||
|
@ -160,6 +167,11 @@ in {
|
||||||
)
|
)
|
||||||
'');
|
'');
|
||||||
|
|
||||||
|
programs.xonsh = mkIf cfg.enableXonshIntegration {
|
||||||
|
xonshrc = "xontrib load direnv";
|
||||||
|
extraPackages = ps: [ pkgs.xonsh.xontribs.xonsh-direnv ];
|
||||||
|
};
|
||||||
|
|
||||||
home.sessionVariables = lib.mkIf cfg.silent { DIRENV_LOG_FORMAT = ""; };
|
home.sessionVariables = lib.mkIf cfg.silent { DIRENV_LOG_FORMAT = ""; };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,9 @@ with lib;
|
||||||
|
|
||||||
enableZshIntegration =
|
enableZshIntegration =
|
||||||
lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
||||||
|
enableXonshIntegration = mkEnableOption "Xonsh integration" // {
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
|
||||||
extraOptions = mkOption {
|
extraOptions = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
|
@ -128,6 +131,18 @@ with lib;
|
||||||
programs.ion.shellAliases = optionsAlias
|
programs.ion.shellAliases = optionsAlias
|
||||||
// optionalAttrs cfg.enableIonIntegration aliases;
|
// 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
|
programs.nushell.shellAliases = optionsAlias
|
||||||
// optionalAttrs cfg.enableNushellIntegration aliases;
|
// optionalAttrs cfg.enableNushellIntegration aliases;
|
||||||
};
|
};
|
||||||
|
|
|
@ -68,6 +68,10 @@ in {
|
||||||
enableZshIntegration =
|
enableZshIntegration =
|
||||||
lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
||||||
|
|
||||||
|
enableXonshIntegration = mkEnableOption "Xonsh integration" // {
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
|
||||||
enableInteractive = mkOption {
|
enableInteractive = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
|
@ -125,6 +129,11 @@ in {
|
||||||
end
|
end
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
programs.xonsh.xonshrc = mkIf cfg.enableXonshIntegration ''
|
||||||
|
if $TERM != "dumb":
|
||||||
|
execx($(${starshipCmd} init xonsh))
|
||||||
|
'';
|
||||||
|
|
||||||
programs.nushell = mkIf cfg.enableNushellIntegration {
|
programs.nushell = mkIf cfg.enableNushellIntegration {
|
||||||
# Unfortunately nushell doesn't allow conditionally sourcing nor
|
# Unfortunately nushell doesn't allow conditionally sourcing nor
|
||||||
# conditionally setting (global) environment variables, which is why the
|
# conditionally setting (global) environment variables, which is why the
|
||||||
|
|
|
@ -64,5 +64,9 @@ with lib;
|
||||||
alias fuck = ${cfg.package}/bin/thefuck $"(history | last 1 | get command | get 0)"
|
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)))
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
72
modules/programs/xonsh.nix
Normal file
72
modules/programs/xonsh.nix
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
{ 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 = lib.mkOption {
|
||||||
|
default = (ps: [ ]);
|
||||||
|
type = with lib.types;
|
||||||
|
coercedTo (listOf lib.types.package) (v: (_: v))
|
||||||
|
(functionTo (listOf lib.types.package));
|
||||||
|
description = ''
|
||||||
|
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.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ let
|
||||||
|
|
||||||
cfg = config.programs.yazi;
|
cfg = config.programs.yazi;
|
||||||
tomlFormat = pkgs.formats.toml { };
|
tomlFormat = pkgs.formats.toml { };
|
||||||
|
|
||||||
in {
|
in {
|
||||||
meta.maintainers = with lib.maintainers; [ eljamm khaneliman xyenon ];
|
meta.maintainers = with lib.maintainers; [ eljamm khaneliman xyenon ];
|
||||||
|
|
||||||
|
@ -35,6 +36,8 @@ in {
|
||||||
enableZshIntegration =
|
enableZshIntegration =
|
||||||
lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
||||||
|
|
||||||
|
enableXonshIntegration = mkEnableOption "Xonsh integration";
|
||||||
|
|
||||||
keymap = mkOption {
|
keymap = mkOption {
|
||||||
type = tomlFormat.type;
|
type = tomlFormat.type;
|
||||||
default = { };
|
default = { };
|
||||||
|
@ -193,6 +196,20 @@ in {
|
||||||
rm -fp $tmp
|
rm -fp $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
|
||||||
|
'';
|
||||||
in {
|
in {
|
||||||
bash.initExtra = mkIf cfg.enableBashIntegration bashIntegration;
|
bash.initExtra = mkIf cfg.enableBashIntegration bashIntegration;
|
||||||
|
|
||||||
|
@ -203,6 +220,8 @@ in {
|
||||||
|
|
||||||
nushell.extraConfig =
|
nushell.extraConfig =
|
||||||
mkIf cfg.enableNushellIntegration nushellIntegration;
|
mkIf cfg.enableNushellIntegration nushellIntegration;
|
||||||
|
|
||||||
|
xonsh.xonshrc = lib.mkIf cfg.enableXonshIntegration xonshIntegration;
|
||||||
};
|
};
|
||||||
|
|
||||||
xdg.configFile = {
|
xdg.configFile = {
|
||||||
|
|
|
@ -31,6 +31,14 @@ in {
|
||||||
|
|
||||||
enableZshIntegration =
|
enableZshIntegration =
|
||||||
lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
||||||
|
|
||||||
|
enableXonshIntegration = lib.mkOption {
|
||||||
|
default = true;
|
||||||
|
type = lib.types.bool;
|
||||||
|
description = ''
|
||||||
|
Whether to enable Xonsh integration.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
|
@ -63,5 +71,9 @@ in {
|
||||||
source ${config.xdg.cacheHome}/zoxide/init.nu
|
source ${config.xdg.cacheHome}/zoxide/init.nu
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
programs.xonsh.xonshrc = lib.mkIf cfg.enableXonshIntegration ''
|
||||||
|
execx($(${cfg.package}/bin/zoxide init xonsh), 'exec', __xonsh__.ctx, filename='zoxide')
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,4 +5,5 @@
|
||||||
yazi-zsh-integration-enabled = ./zsh-integration-enabled.nix;
|
yazi-zsh-integration-enabled = ./zsh-integration-enabled.nix;
|
||||||
yazi-fish-integration-enabled = ./fish-integration-enabled.nix;
|
yazi-fish-integration-enabled = ./fish-integration-enabled.nix;
|
||||||
yazi-nushell-integration-enabled = ./nushell-integration-enabled.nix;
|
yazi-nushell-integration-enabled = ./nushell-integration-enabled.nix;
|
||||||
|
yazi-xonsh-integration-enabled = ./xonsh-integration-enabled.nix;
|
||||||
}
|
}
|
||||||
|
|
31
tests/modules/programs/yazi/xonsh-integration-enabled.nix
Normal file
31
tests/modules/programs/yazi/xonsh-integration-enabled.nix
Normal file
|
@ -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}'
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue