direnv: add module

This commit is contained in:
Robert Helgesson 2018-07-31 15:48:08 +02:00
parent 2e9e1909da
commit 93ef6aefce
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
3 changed files with 58 additions and 0 deletions

View file

@ -725,6 +725,13 @@ in
A new module is available: 'services.status-notifier-watcher'.
'';
}
{
time = "2018-07-31T13:47:06+00:00";
message = ''
A new module is available: 'programs.direnv'.
'';
}
];
};
}

View file

@ -29,6 +29,7 @@ let
./programs/beets.nix
./programs/browserpass.nix
./programs/command-not-found/command-not-found.nix
./programs/direnv.nix
./programs/eclipse.nix
./programs/emacs.nix
./programs/feh.nix

View file

@ -0,0 +1,50 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.direnv;
in
{
meta.maintainers = [ maintainers.rycee ];
options.programs.direnv = {
enable = mkEnableOption "direnv, the environment switcher";
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.
'';
};
};
config = mkIf cfg.enable {
home.packages = [ pkgs.direnv ];
programs.bash.initExtra =
mkIf cfg.enableBashIntegration (
# Using mkAfter to make it more likely to appear after other
# manipulations of the prompt.
mkAfter ''
eval "$(${pkgs.direnv}/bin/direnv hook bash)"
''
);
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
eval "$(${pkgs.direnv}/bin/direnv hook zsh)"
'';
};
}