1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +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:
Josh Holland 2021-06-15 17:11:26 +01:00 committed by GitHub
parent 1375fd4a03
commit e0f2949c98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 8 deletions

View file

@ -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 ''
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 (

View file

@ -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

View file

@ -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 = ''