programs/direnv: add finalPackage readonly option
This commit is contained in:
parent
fb27326bbc
commit
daf8e22831
1 changed files with 25 additions and 16 deletions
|
|
@ -19,6 +19,12 @@ in {
|
|||
|
||||
package = lib.mkPackageOption pkgs "direnv" {};
|
||||
|
||||
finalPackage = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
readOnly = true;
|
||||
description = "The wrapped direnv package.";
|
||||
};
|
||||
|
||||
direnvrcExtra = lib.mkOption {
|
||||
type = lib.types.lines;
|
||||
default = "";
|
||||
|
|
@ -74,15 +80,26 @@ in {
|
|||
|
||||
config = lib.mkIf cfg.enable {
|
||||
programs = {
|
||||
direnv.settings = lib.mkIf cfg.silent {
|
||||
global = {
|
||||
log_format = lib.mkDefault "-";
|
||||
log_filter = lib.mkDefault "^$";
|
||||
direnv = {
|
||||
finalPackage = pkgs.symlinkJoin {
|
||||
inherit (cfg.package) name;
|
||||
paths = [cfg.package];
|
||||
# direnv has a fish library which automatically sources direnv for some reason
|
||||
postBuild = ''
|
||||
rm -rf "$out/share/fish"
|
||||
'';
|
||||
meta.mainProgram = "direnv";
|
||||
};
|
||||
settings = lib.mkIf cfg.silent {
|
||||
global = {
|
||||
log_format = lib.mkDefault "-";
|
||||
log_filter = lib.mkDefault "^$";
|
||||
};
|
||||
};
|
||||
};
|
||||
zsh.interactiveShellInit = ''
|
||||
if ${lib.boolToString cfg.loadInNixShell} || printenv PATH | grep -vqc '/nix/store'; then
|
||||
eval "$(${lib.getExe cfg.package} hook zsh)"
|
||||
eval "$(${lib.getExe cfg.finalPackage} hook zsh)"
|
||||
fi
|
||||
'';
|
||||
|
||||
|
|
@ -90,29 +107,21 @@ in {
|
|||
#$IN_NIX_SHELL for "nix-shell"
|
||||
bash.interactiveShellInit = ''
|
||||
if ${lib.boolToString cfg.loadInNixShell} || [ -z "$IN_NIX_SHELL$NIX_GCROOT$(printenv PATH | grep '/nix/store')" ] ; then
|
||||
eval "$(${lib.getExe cfg.package} hook bash)"
|
||||
eval "$(${lib.getExe cfg.finalPackage} hook bash)"
|
||||
fi
|
||||
'';
|
||||
|
||||
fish.interactiveShellInit = ''
|
||||
if ${lib.boolToString cfg.loadInNixShell};
|
||||
or printenv PATH | grep -vqc '/nix/store';
|
||||
${lib.getExe cfg.package} hook fish | source
|
||||
${lib.getExe cfg.finalPackage} hook fish | source
|
||||
end
|
||||
'';
|
||||
};
|
||||
|
||||
environment = {
|
||||
systemPackages = [
|
||||
(pkgs.symlinkJoin {
|
||||
inherit (cfg.package) name;
|
||||
paths = [cfg.package];
|
||||
# direnv has a fish library which automatically sources direnv for some reason
|
||||
# I don't see any harm removing this if we're sourcing it with fish.interactiveShellInit
|
||||
postBuild = ''
|
||||
rm -rf "$out/share/fish"
|
||||
'';
|
||||
})
|
||||
cfg.finalPackage
|
||||
];
|
||||
variables = {
|
||||
DIRENV_CONFIG = "/etc/direnv";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue