From 0d749e58f7f2c6d5190920906cd8b5b5f4a8f9f4 Mon Sep 17 00:00:00 2001 From: Bernard Fortz Date: Tue, 25 Sep 2018 16:18:42 +0200 Subject: [PATCH 1/3] autojump: creates links required by oh-my-zsh for autojump. The autojump plugin in oh-my-zsh assumes autojump.zsh resides in /run/current-system/sw/share/autojump/ but these links are not created by default. The new programs.autojump.enable option forces the creation of these links. --- nixos/modules/module-list.nix | 1 + nixos/modules/programs/autojump.nix | 33 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 nixos/modules/programs/autojump.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 1a8f522a969..0b15a49d9f1 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -78,6 +78,7 @@ ./misc/version.nix ./programs/adb.nix ./programs/atop.nix + ./programs/autojump.nix ./programs/bash/bash.nix ./programs/bcc.nix ./programs/blcr.nix diff --git a/nixos/modules/programs/autojump.nix b/nixos/modules/programs/autojump.nix new file mode 100644 index 00000000000..229ac212e40 --- /dev/null +++ b/nixos/modules/programs/autojump.nix @@ -0,0 +1,33 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.autojump; + +in + +{ + + ###### interface + + options = { + programs.autojump = { + + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to enable autojump. + ''; + }; + }; + }; + + ###### implementation + + config = mkIf cfg.enable { + environment.pathsToLink = [ "/share/autojump" ]; + }; +} From 0bca7385139771082f8c89f3f1d4a067bbda3f59 Mon Sep 17 00:00:00 2001 From: Bernard Fortz Date: Tue, 25 Sep 2018 20:16:11 +0200 Subject: [PATCH 2/3] autodump: pulling package when programs.autojump.enable is true --- nixos/modules/programs/autojump.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/modules/programs/autojump.nix b/nixos/modules/programs/autojump.nix index 229ac212e40..9fc8382a754 100644 --- a/nixos/modules/programs/autojump.nix +++ b/nixos/modules/programs/autojump.nix @@ -29,5 +29,6 @@ in config = mkIf cfg.enable { environment.pathsToLink = [ "/share/autojump" ]; + environment.systemPackages = [ pkgs.autojump ]; }; } From cd8ffef01b4629980bb77e33a20c24c236ac41be Mon Sep 17 00:00:00 2001 From: Bernard Fortz Date: Wed, 26 Sep 2018 14:58:28 +0200 Subject: [PATCH 3/3] autojump: autoload when programs.autojump.enable is set. --- nixos/modules/programs/autojump.nix | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/nixos/modules/programs/autojump.nix b/nixos/modules/programs/autojump.nix index 9fc8382a754..3a8feec4bb4 100644 --- a/nixos/modules/programs/autojump.nix +++ b/nixos/modules/programs/autojump.nix @@ -3,15 +3,10 @@ with lib; let - cfg = config.programs.autojump; - + prg = config.programs; in - { - - ###### interface - options = { programs.autojump = { @@ -30,5 +25,9 @@ in config = mkIf cfg.enable { environment.pathsToLink = [ "/share/autojump" ]; environment.systemPackages = [ pkgs.autojump ]; + + programs.bash.interactiveShellInit = "source ${pkgs.autojump}/share/autojump/autojump.bash"; + programs.zsh.interactiveShellInit = mkIf prg.zsh.enable "source ${pkgs.autojump}/share/autojump/autojump.zsh"; + programs.fish.interactiveShellInit = mkIf prg.fish.enable "source ${pkgs.autojump}/share/autojump/autojump.fish"; }; }