|
1 | | -{ config, lib, wlib, pkgs, ... }: |
| 1 | +{ |
| 2 | + config, |
| 3 | + lib, |
| 4 | + wlib, |
| 5 | + pkgs, |
| 6 | + ... |
| 7 | +}: |
2 | 8 | let |
3 | 9 | cfg = config; |
4 | 10 |
|
|
27 | 33 | }; |
28 | 34 | lib = lib.mkOption { |
29 | 35 | type = with lib.types; attrsOf lines; |
30 | | - default = {}; |
| 36 | + default = { }; |
31 | 37 | }; |
32 | 38 | extraConfig = lib.mkOption { |
33 | 39 | inherit (tomlFmt) type; |
|
40 | 46 | }; |
41 | 47 | config = { |
42 | 48 | package = lib.mkDefault pkgs.direnv; |
43 | | - env = { |
| 49 | + env = { |
44 | 50 | # **IMPORTANT** DIRENV_CONFIG needs to be explicitly set in your shells environment |
45 | | - # because right now, direnv will use the `direnv` binary directly in its shell |
46 | | - # hook and not the wrapper (in which $DIRENV_CONFIG got injected). |
47 | | - # Hence the wrapped config will not be picked up unless you explicitly reference |
48 | | - # this variable and set it. |
49 | | - # |
| 51 | + # because right now, direnv will use the `direnv` binary directly in its shell |
| 52 | + # hook and not the wrapper (in which $DIRENV_CONFIG got injected). |
| 53 | + # Hence the wrapped config will not be picked up unless you explicitly reference |
| 54 | + # this variable and set it. |
| 55 | + # |
50 | 56 | # If the PR below will ever be merged, this issue can be fixed by setting: |
51 | 57 | # |
52 | 58 | # env.DIRENV_EXE_PATH = "${placeholder "out"}/bin/direnv"; |
53 | 59 | # |
54 | 60 | # This would make the direnv hook use the wrapper instead of the original binary. |
55 | | - # |
| 61 | + # |
56 | 62 | # https://github.com/direnv/direnv/pull/1564 |
57 | 63 |
|
58 | 64 | # **IMPORTANT** Using `placeholder "out"` here seems to cause issues if this wrapper issue |
|
61 | 67 | # DIRENV_CONFIG = "${placeholder "out"}/${config.configDirname}"; |
62 | 68 | }; |
63 | 69 | passthru.DIRENV_CONFIG = "${config.wrapper.${config.outputName}}/${config.configDirname}"; |
64 | | - lib."nix-direnv.sh" = lib.mkIf |
65 | | - (config.nix-direnv.enable) |
66 | | - "source ${cfg.nix-direnv.package}/share/nix-direnv/direnvrc"; |
| 70 | + lib."nix-direnv.sh" = |
| 71 | + lib.mkIf (config.nix-direnv.enable) "source ${cfg.nix-direnv.package}/share/nix-direnv/direnvrc"; |
67 | 72 | extraConfig = { |
68 | 73 | global = lib.mkIf (config.silent) { |
69 | 74 | log_format = "-"; |
|
79 | 84 | content = config.direnvrc; |
80 | 85 | relPath = "${config.configDirname}/direnvrc"; |
81 | 86 | }; |
82 | | - } // |
83 | | - # TODO: As of now, construcFiles does not accept keys like 'nix-direnv.sh'. |
84 | | - # This hack somehow avoids the issue. Find out if this needs to be fixed in |
85 | | - # `constructFiles`. |
86 | | - lib.mapAttrs' (name: value: lib.nameValuePair (builtins.replaceStrings ["." "-"] ["" ""] name) { |
87 | | - content = value; |
88 | | - relPath = "${config.configDirname}/lib/${name}"; |
89 | | - }) config.lib; |
| 87 | + } |
| 88 | + // |
| 89 | + # TODO: As of now, construcFiles does not accept keys like 'nix-direnv.sh'. |
| 90 | + # This hack somehow avoids the issue. Find out if this needs to be fixed in |
| 91 | + # `constructFiles`. |
| 92 | + lib.mapAttrs' ( |
| 93 | + name: value: |
| 94 | + lib.nameValuePair (builtins.replaceStrings [ "." "-" ] [ "" "" ] name) { |
| 95 | + content = value; |
| 96 | + relPath = "${config.configDirname}/lib/${name}"; |
| 97 | + } |
| 98 | + ) config.lib; |
90 | 99 | }; |
91 | 100 | } |
92 | | - |
|
0 commit comments