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