mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
direnv: add enableFlakes option for enableNixDirenvIntegration (#2089)
NixOS/nixpkgs@03310df843 disabled flake support by default, so we now need to build a custom package and use it if the user wants to `use flake` successfully. This should fix #2087.
This commit is contained in:
parent
1375fd4a03
commit
e0f2949c98
3 changed files with 22 additions and 8 deletions
|
@ -9,6 +9,14 @@ let
|
|||
tomlFormat = pkgs.formats.toml { };
|
||||
|
||||
in {
|
||||
imports = [
|
||||
(mkRenamedOptionModule [
|
||||
"programs"
|
||||
"direnv"
|
||||
"enableNixDirenvIntegration"
|
||||
] [ "programs" "direnv" "nix-direnv" "enable" ])
|
||||
];
|
||||
|
||||
meta.maintainers = [ maintainers.rycee ];
|
||||
|
||||
options.programs.direnv = {
|
||||
|
@ -63,10 +71,14 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
enableNixDirenvIntegration = mkEnableOption ''
|
||||
<link
|
||||
xlink:href="https://github.com/nix-community/nix-direnv">nix-direnv</link>,
|
||||
a fast, persistent use_nix implementation for direnv'';
|
||||
nix-direnv = {
|
||||
enable = mkEnableOption ''
|
||||
<link
|
||||
xlink:href="https://github.com/nix-community/nix-direnv">nix-direnv</link>,
|
||||
a fast, persistent use_nix implementation for direnv'';
|
||||
enableFlakes = mkEnableOption "Flake support in nix-direnv";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
@ -77,9 +89,11 @@ in {
|
|||
};
|
||||
|
||||
xdg.configFile."direnv/direnvrc" = let
|
||||
package =
|
||||
pkgs.nix-direnv.override { inherit (cfg.nix-direnv) enableFlakes; };
|
||||
text = concatStringsSep "\n" (optional (cfg.stdlib != "") cfg.stdlib
|
||||
++ optional cfg.enableNixDirenvIntegration
|
||||
"source ${pkgs.nix-direnv}/share/nix-direnv/direnvrc");
|
||||
++ optional cfg.nix-direnv.enable
|
||||
"source ${package}/share/nix-direnv/direnvrc");
|
||||
in mkIf (text != "") { inherit text; };
|
||||
|
||||
programs.bash.initExtra = mkIf cfg.enableBashIntegration (
|
||||
|
|
|
@ -6,7 +6,7 @@ with lib;
|
|||
config = {
|
||||
programs.bash.enable = true;
|
||||
programs.direnv.enable = true;
|
||||
programs.direnv.enableNixDirenvIntegration = true;
|
||||
programs.direnv.nix-direnv.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.bashrc
|
||||
|
|
|
@ -7,7 +7,7 @@ in {
|
|||
config = {
|
||||
programs.bash.enable = true;
|
||||
programs.direnv.enable = true;
|
||||
programs.direnv.enableNixDirenvIntegration = true;
|
||||
programs.direnv.nix-direnv.enable = true;
|
||||
programs.direnv.stdlib = expectedContent;
|
||||
|
||||
nmt.script = ''
|
||||
|
|
Loading…
Reference in a new issue