mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-31 04:04:32 +00:00
Merge b8da5337cc
into 1efd250317
This commit is contained in:
commit
5c77bc0494
3 changed files with 56 additions and 0 deletions
|
@ -238,6 +238,15 @@ let
|
||||||
echo "end"
|
echo "end"
|
||||||
echo "setup_hm_session_vars") > $out
|
echo "setup_hm_session_vars") > $out
|
||||||
'';
|
'';
|
||||||
|
sourceHandlersStr = let
|
||||||
|
handlerAttrs =
|
||||||
|
[ "onJobExit" "onProcessExit" "onVariable" "onSignal" "onEvent" ];
|
||||||
|
isHandler = name: def:
|
||||||
|
isAttrs def && any (attr: hasAttr attr def) handlerAttrs;
|
||||||
|
handlerFunctions = filterAttrs isHandler cfg.functions;
|
||||||
|
sourceFunction = name: def:
|
||||||
|
"source ${config.xdg.configHome}/fish/functions/${name}.fish";
|
||||||
|
in concatStringsSep "\n" (mapAttrsToList sourceFunction handlerFunctions);
|
||||||
|
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
|
@ -485,6 +494,9 @@ in {
|
||||||
|
|
||||||
source ${translatedSessionVariables}
|
source ${translatedSessionVariables}
|
||||||
|
|
||||||
|
# Source handler functions
|
||||||
|
${sourceHandlersStr}
|
||||||
|
|
||||||
${cfg.shellInit}
|
${cfg.shellInit}
|
||||||
|
|
||||||
status is-login; and begin
|
status is-login; and begin
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
fish-format-scripts = ./format-scripts.nix;
|
fish-format-scripts = ./format-scripts.nix;
|
||||||
fish-functions = ./functions.nix;
|
fish-functions = ./functions.nix;
|
||||||
fish-no-functions = ./no-functions.nix;
|
fish-no-functions = ./no-functions.nix;
|
||||||
|
fish-source-handlers = ./source-handlers.nix;
|
||||||
fish-plugins = ./plugins.nix;
|
fish-plugins = ./plugins.nix;
|
||||||
fish-manpage = ./manpage.nix;
|
fish-manpage = ./manpage.nix;
|
||||||
}
|
}
|
||||||
|
|
43
tests/modules/programs/fish/source-handlers.nix
Normal file
43
tests/modules/programs/fish/source-handlers.nix
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with builtins; {
|
||||||
|
config = {
|
||||||
|
programs.fish = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
functions = {
|
||||||
|
normal-function = "";
|
||||||
|
event-handler = {
|
||||||
|
body = "";
|
||||||
|
onEvent = "test";
|
||||||
|
};
|
||||||
|
variable-handler = {
|
||||||
|
body = "";
|
||||||
|
onVariable = "test";
|
||||||
|
};
|
||||||
|
job-handler = {
|
||||||
|
body = "";
|
||||||
|
onJobExit = "10";
|
||||||
|
};
|
||||||
|
signal-handler = {
|
||||||
|
body = "";
|
||||||
|
onSignal = "10";
|
||||||
|
};
|
||||||
|
process-handler = {
|
||||||
|
body = "";
|
||||||
|
onProcessExit = "10";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/fish/config.fish
|
||||||
|
assertFileContains home-files/.config/fish/config.fish "source /home/hm-user/.config/fish/functions/event-handler.fish"
|
||||||
|
assertFileContains home-files/.config/fish/config.fish "source /home/hm-user/.config/fish/functions/variable-handler.fish"
|
||||||
|
assertFileContains home-files/.config/fish/config.fish "source /home/hm-user/.config/fish/functions/job-handler.fish"
|
||||||
|
assertFileContains home-files/.config/fish/config.fish "source /home/hm-user/.config/fish/functions/signal-handler.fish"
|
||||||
|
assertFileContains home-files/.config/fish/config.fish "source /home/hm-user/.config/fish/functions/process-handler.fish"
|
||||||
|
assertFileNotRegex home-files/.config/fish/config.fish "source /home/hm-user/.config/fish/functions/normal-function.fish"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue