diff --git a/modules/programs/goto.nix b/modules/programs/goto.nix new file mode 100644 index 000000000..bf53f85cf --- /dev/null +++ b/modules/programs/goto.nix @@ -0,0 +1,32 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.programs.goto; +in +{ + meta.maintainers = [ lib.maintainers.bmrips ]; + + options.programs.goto = { + enable = lib.mkEnableOption "{command}`goto`."; + package = lib.mkPackageOption pkgs "goto" { }; + enableBashIntegration = lib.hm.shell.mkBashIntegrationOption { inherit config; }; + enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; }; + }; + + config = lib.mkIf cfg.enable { + home.packages = [ cfg.package ]; + programs = + let + init = "source ${cfg.package}/share/goto.sh"; + in + { + bash.initExtra = lib.mkIf cfg.enableBashIntegration init; + zsh.initContent = lib.mkIf cfg.enableZshIntegration init; + }; + }; +} diff --git a/tests/modules/programs/goto/default.nix b/tests/modules/programs/goto/default.nix new file mode 100644 index 000000000..263e316fa --- /dev/null +++ b/tests/modules/programs/goto/default.nix @@ -0,0 +1,3 @@ +{ + goto-shell-initialization = ./shell-initialization.nix; +} diff --git a/tests/modules/programs/goto/shell-initialization.nix b/tests/modules/programs/goto/shell-initialization.nix new file mode 100644 index 000000000..4989a831d --- /dev/null +++ b/tests/modules/programs/goto/shell-initialization.nix @@ -0,0 +1,12 @@ +{ + programs.bash.enable = true; + programs.goto.enable = true; + programs.zsh.enable = true; + + nmt.script = '' + assertFileExists home-files/.bashrc + assertFileRegex home-files/.bashrc '^source \S*/share/goto.sh$' + assertFileExists home-files/.zshrc + assertFileRegex home-files/.zshrc '^source \S*/share/goto.sh$' + ''; +}