autojump: add module

This also deprecates the `programs.bash.enableAutojump` option in
favor of this module.
This commit is contained in:
Evan Stoll 2020-09-18 09:07:40 -04:00 committed by Robert Helgesson
parent 7e5fee4268
commit 8537920706
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
8 changed files with 93 additions and 12 deletions

3
.github/CODEOWNERS vendored
View file

@ -33,6 +33,9 @@
/modules/programs/aria2.nix @JustinLovinger
/modules/programs/autojump.nix @evanjs
/tests/modules/programs/autojump @evanjs
/modules/programs/autorandr.nix @uvNikita
/modules/programs/bash.nix @rycee

View file

@ -1687,6 +1687,16 @@ in
A new module is available: 'programs.mu'.
'';
}
{
time = "2020-10-08T21:28:16+00:00";
message = ''
A new module is available: 'programs.autojump'
The option `programs.bash.enableAutojump` is deprecated and this new
module should be used instead.
'';
}
];
};
}

View file

@ -49,6 +49,7 @@ let
(loadModule ./programs/alot.nix { })
(loadModule ./programs/aria2.nix { })
(loadModule ./programs/astroid.nix { })
(loadModule ./programs/autojump.nix { })
(loadModule ./programs/autorandr.nix { })
(loadModule ./programs/bash.nix { })
(loadModule ./programs/bat.nix { })

View file

@ -0,0 +1,56 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.autojump;
package = pkgs.autojump;
in {
meta.maintainers = [ maintainers.evanjs ];
options.programs.autojump = {
enable = mkEnableOption "autojump";
enableBashIntegration = mkOption {
default = true;
type = types.bool;
description = ''
Whether to enable Bash integration.
'';
};
enableZshIntegration = mkOption {
default = true;
type = types.bool;
description = ''
Whether to enable Zsh integration.
'';
};
enableFishIntegration = mkOption {
default = true;
type = types.bool;
description = ''
Whether to enable Fish integration.
'';
};
};
config = mkIf cfg.enable {
home.packages = [ package ];
programs.bash.initExtra = mkIf cfg.enableBashIntegration (mkBefore ''
. ${package}/share/autojump/autojump.bash
'');
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
. ${package}/share/autojump/autojump.zsh
'';
programs.fish.promptInit = mkIf cfg.enableFishIntegration ''
. ${package}/share/autojump/autojump.fish
'';
};
}

View file

@ -11,6 +11,14 @@ in
{
meta.maintainers = [ maintainers.rycee ];
imports = [
(mkRenamedOptionModule [ "programs" "bash" "enableAutojump" ] [
"programs"
"autojump"
"enable"
])
];
options = {
programs.bash = {
enable = mkEnableOption "GNU Bourne-Again SHell";
@ -94,12 +102,6 @@ in
'';
};
enableAutojump = mkOption {
default = false;
type = types.bool;
description = "Enable the autojump navigation tool.";
};
profileExtra = mkOption {
default = "";
type = types.lines;
@ -176,9 +178,6 @@ in
${aliasesStr}
${optionalString cfg.enableAutojump
". ${pkgs.autojump}/share/autojump/autojump.bash"}
${cfg.initExtra}
fi
'';
@ -216,9 +215,6 @@ in
${cfg.logoutExtra}
'';
};
home.packages =
optional (cfg.enableAutojump) pkgs.autojump;
}
);
}

View file

@ -41,6 +41,7 @@ import nmt {
./modules/programs/alacritty
./modules/programs/alot
./modules/programs/aria2
./modules/programs/autojump
./modules/programs/bash
./modules/programs/browserpass
./modules/programs/dircolors

View file

@ -0,0 +1,13 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.autojump.enable = true;
nmt.script = ''
assertFileExists home-path/bin/autojump
'';
};
}

View file

@ -0,0 +1 @@
{ autojump = ./default-settings.nix; }