-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/direnv: init #192667
nixos/direnv: init #192667
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ lib, config, pkgs, ... }: { | ||
|
||
options.programs.direnv.enable = lib.mkOption { | ||
type = lib.types.bool; | ||
default = false; | ||
example = true; | ||
description = '' | ||
Whether to enable direnv integration. Takes care of both installation and | ||
setting up the sourcing of the shell. Additionally enables nix-direnv | ||
integration. Note that you need to logout and login for this change to apply. | ||
''; | ||
}; | ||
|
||
config = lib.mkIf config.programs.direnv.enable { | ||
|
||
environment.systemPackages = with pkgs; [ | ||
direnv | ||
nix-direnv | ||
]; | ||
|
||
environment.pathsToLink = [ | ||
"/share/direnv" | ||
]; | ||
|
||
environment.sessionVariables.DIRENV_CONFIG = "/run/current-system/sw/share/direnv"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned: This disallows user customization entirely, I think. |
||
|
||
programs.bash.interactiveShellInit = '' | ||
eval "$(direnv hook bash)" | ||
''; | ||
|
||
programs.zsh.interactiveShellInit = '' | ||
eval "$(direnv hook zsh)" | ||
''; | ||
|
||
programs.fish.interactiveShellInit = '' | ||
direnv hook fish | source | ||
''; | ||
|
||
# nix options for derivations to persist garbage collection | ||
nix.settings.keep-outputs = true; | ||
ck3d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
nix.settings.keep-derivations = true; | ||
}; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,9 @@ stdenv.mkDerivation rec { | |
installPhase = '' | ||
runHook preInstall | ||
install -m500 -D direnvrc $out/share/nix-direnv/direnvrc | ||
|
||
# Allows NixOS to set DIRENV_CONFIG to /run/current-system/sw/share/direnv and have direnv load this | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case, the module will also have to handle user settings since DIRENV_CONFIG is also used to locate the Alternatively, it could make sense to change direnv so it also loads all the libraries in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that, given that direnv already reads There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I think so too, I quote the XDG Base Directory Specification:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created a direnv PR for this: direnv/direnv#990 |
||
install -m500 -D direnvrc $out/share/direnv/lib/nix-direnv.sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this not be a symlink? |
||
runHook postInstall | ||
''; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should mention the nix setting changes.