mirror of
https://github.com/nix-community/home-manager
synced 2024-12-25 03:09:47 +01:00
direnv: add nix-direnv to lib instead of sourcing
Also removes use of `with lib`.
This commit is contained in:
parent
c002bc08c8
commit
9fe79591c1
4 changed files with 13 additions and 15 deletions
|
@ -1,8 +1,8 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
inherit (lib)
|
||||||
|
mkOption mkRenamedOptionModule mkRemovedOptionModule mkEnableOption types
|
||||||
|
mkPackageOption mkIf mkAfter getExe;
|
||||||
|
|
||||||
cfg = config.programs.direnv;
|
cfg = config.programs.direnv;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ in {
|
||||||
"Flake support is now always enabled.")
|
"Flake support is now always enabled.")
|
||||||
];
|
];
|
||||||
|
|
||||||
meta.maintainers = [ maintainers.rycee ];
|
meta.maintainers = [ lib.maintainers.rycee ];
|
||||||
|
|
||||||
options.programs.direnv = {
|
options.programs.direnv = {
|
||||||
enable = mkEnableOption "direnv, the environment switcher";
|
enable = mkEnableOption "direnv, the environment switcher";
|
||||||
|
@ -104,11 +104,12 @@ in {
|
||||||
source = tomlFormat.generate "direnv-config" cfg.config;
|
source = tomlFormat.generate "direnv-config" cfg.config;
|
||||||
};
|
};
|
||||||
|
|
||||||
xdg.configFile."direnv/direnvrc" = let
|
xdg.configFile."direnv/lib/hm-nix-direnv.sh" = mkIf cfg.nix-direnv.enable {
|
||||||
text = concatStringsSep "\n" (optional (cfg.stdlib != "") cfg.stdlib
|
source = "${cfg.nix-direnv.package}/share/nix-direnv/direnvrc";
|
||||||
++ optional cfg.nix-direnv.enable
|
};
|
||||||
"source ${cfg.nix-direnv.package}/share/nix-direnv/direnvrc");
|
|
||||||
in mkIf (text != "") { inherit text; };
|
xdg.configFile."direnv/direnvrc" =
|
||||||
|
lib.mkIf (cfg.stdlib != "") { text = cfg.stdlib; };
|
||||||
|
|
||||||
programs.bash.initExtra = mkIf cfg.enableBashIntegration (
|
programs.bash.initExtra = mkIf cfg.enableBashIntegration (
|
||||||
# Using mkAfter to make it more likely to appear after other
|
# Using mkAfter to make it more likely to appear after other
|
||||||
|
|
|
@ -10,9 +10,7 @@ with lib;
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-files/.bashrc
|
assertFileExists home-files/.bashrc
|
||||||
assertFileRegex \
|
assertFileExists home-files/.config/direnv/lib/hm-nix-direnv.sh
|
||||||
home-files/.config/direnv/direnvrc \
|
|
||||||
'source /nix/store/.*nix-direnv.*/share/nix-direnv/direnvrc'
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,7 @@ in {
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-files/.bashrc
|
assertFileExists home-files/.bashrc
|
||||||
assertFileRegex \
|
assertFileExists home-files/.config/direnv/lib/hm-nix-direnv.sh
|
||||||
home-files/.config/direnv/direnvrc \
|
|
||||||
'source /nix/store/.*nix-direnv.*/share/nix-direnv/direnvrc'
|
|
||||||
assertFileRegex \
|
assertFileRegex \
|
||||||
home-files/.config/direnv/direnvrc \
|
home-files/.config/direnv/direnvrc \
|
||||||
'${expectedContent}'
|
'${expectedContent}'
|
||||||
|
|
|
@ -10,6 +10,7 @@ in {
|
||||||
programs.direnv.stdlib = expectedContent;
|
programs.direnv.stdlib = expectedContent;
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
|
assertPathNotExists home-files/.config/direnv/lib/hm-nix-direnv.sh
|
||||||
assertFileExists home-files/.bashrc
|
assertFileExists home-files/.bashrc
|
||||||
assertFileRegex \
|
assertFileRegex \
|
||||||
home-files/.config/direnv/direnvrc \
|
home-files/.config/direnv/direnvrc \
|
||||||
|
|
Loading…
Reference in a new issue