about summary refs log tree commit diff
path: root/home/direnv/default.nix
blob: ce4982c6264c46ec0c8e2586cc498b9d8fa686ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{ config, lib, pkgs, ... }:
let
  cfg = config.my.home.direnv;
  fishEnabled = config.my.home.shell.name == "fish";
in
{
  options.my.home.direnv = with lib; {
    enable = mkEnableOption "direnv configuration";
  };

  config = lib.mkIf cfg.enable {
    programs.direnv = {
      enable = true;
      nix-direnv = { enable = true; };
      config = {
        global.disable_stdin = true;
        global.strict_env = true;
      };
    };

    programs.fish.interactiveShellInit = lib.mkIf fishEnabled (
      # Using mkAfter to make it more likely to appear after other
      # manipulations of the prompt.
      lib.mkAfter ''
        ${pkgs.direnv}/bin/direnv hook fish | source
      '');

    home.sessionVariables = { DIRENV_DEFAULT_FLAKE = "nixpkgs"; };
  };
}