-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
direnv.nix
46 lines (41 loc) · 1.07 KB
/
direnv.nix
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
lib,
pkgs,
config,
osConfig,
...
}:
let
inherit (lib.modules) mkIf;
inherit (lib.validators) isAcceptedDevice isModernShell;
acceptedTypes = [
"wsl"
"desktop"
"laptop"
"hybrid"
];
in
{
programs.direnv = mkIf (isAcceptedDevice osConfig acceptedTypes && isModernShell osConfig) {
enable = true;
silent = true;
# faster, persistent implementation of use_nix and use_flake
nix-direnv.enable = true;
enableBashIntegration = config.programs.bash.enable;
# enableFishIntegration = config.programs.fish.enable;
enableZshIntegration = config.programs.zsh.enable;
enableNushellIntegration = config.programs.nushell.enable;
# modified from from @i077
# store direnv in cache and not per project
stdlib = ''
: ''${XDG_CACHE_HOME:=$HOME/.cache}
declare -A direnv_layout_dirs
direnv_layout_dir() {
echo "''${direnv_layout_dirs[$PWD]:=$(
echo -n "$XDG_CACHE_HOME"/direnv/layouts/
echo -n "$PWD" | ${pkgs.perl}/bin/shasum | cut -d ' ' -f 1
)}"
}
'';
};
}