mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
parent
575cd4b8ba
commit
b33802ca7f
4 changed files with 53 additions and 2 deletions
|
@ -70,6 +70,11 @@ in {
|
|||
Whether to enable Fish integration.
|
||||
'';
|
||||
};
|
||||
|
||||
enableNixDirenvIntegration = mkEnableOption ''
|
||||
<link
|
||||
xlink:href="https://github.com/nix-community/nix-direnv">nix-direnv</link>,
|
||||
a fast, persistent use_nix implementation for direnv'';
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
@ -78,8 +83,11 @@ in {
|
|||
xdg.configFile."direnv/config.toml" =
|
||||
mkIf (cfg.config != { }) { source = configFile cfg.config; };
|
||||
|
||||
xdg.configFile."direnv/direnvrc" =
|
||||
mkIf (cfg.stdlib != "") { text = cfg.stdlib; };
|
||||
xdg.configFile."direnv/direnvrc" = let
|
||||
text = concatStringsSep "\n" (optional (cfg.stdlib != "") cfg.stdlib
|
||||
++ optional cfg.enableNixDirenvIntegration
|
||||
"source ${pkgs.nix-direnv}/share/nix-direnv/direnvrc");
|
||||
in mkIf (text != "") { inherit text; };
|
||||
|
||||
programs.bash.initExtra = mkIf cfg.enableBashIntegration (
|
||||
# Using mkAfter to make it more likely to appear after other
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
direnv-bash = ./bash.nix;
|
||||
direnv-nix-direnv = ./nix-direnv.nix;
|
||||
direnv-stdlib = ./stdlib.nix;
|
||||
direnv-stdlib-and-nix-direnv = ./stdlib-and-nix-direnv.nix;
|
||||
}
|
||||
|
|
18
tests/modules/programs/direnv/nix-direnv.nix
Normal file
18
tests/modules/programs/direnv/nix-direnv.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
config = {
|
||||
programs.bash.enable = true;
|
||||
programs.direnv.enable = true;
|
||||
programs.direnv.enableNixDirenvIntegration = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.bashrc
|
||||
assertFileRegex \
|
||||
home-files/.config/direnv/direnvrc \
|
||||
'source /nix/store/.*nix-direnv.*/share/nix-direnv/direnvrc'
|
||||
'';
|
||||
};
|
||||
}
|
23
tests/modules/programs/direnv/stdlib-and-nix-direnv.nix
Normal file
23
tests/modules/programs/direnv/stdlib-and-nix-direnv.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let expectedContent = "something important";
|
||||
in {
|
||||
config = {
|
||||
programs.bash.enable = true;
|
||||
programs.direnv.enable = true;
|
||||
programs.direnv.enableNixDirenvIntegration = true;
|
||||
programs.direnv.stdlib = expectedContent;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.bashrc
|
||||
assertFileRegex \
|
||||
home-files/.config/direnv/direnvrc \
|
||||
'source /nix/store/.*nix-direnv.*/share/nix-direnv/direnvrc'
|
||||
assertFileRegex \
|
||||
home-files/.config/direnv/direnvrc \
|
||||
'${expectedContent}'
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue