home: direnv: allow specifying default flake
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Bruno BELANYI 2022-04-13 10:04:38 +02:00
parent b9361dada4
commit 6530af39d8
2 changed files with 18 additions and 3 deletions

View file

@ -3,8 +3,18 @@ let
cfg = config.my.home.direnv;
in
{
options.my.home.direnv = with lib.my; {
enable = mkDisableOption "direnv configuration";
options.my.home.direnv = with lib; {
enable = my.mkDisableOption "direnv configuration";
defaultFlake = mkOption {
type = types.str;
default = "pkgs";
example = "nixpkgs";
description = ''
Which flake from the registry should be used for
<command>use pkgs</command> by default.
'';
};
};
config = lib.mkIf cfg.enable {
@ -28,5 +38,9 @@ in
{ source = libDir + "/${name}"; };
in
lib.my.genAttrs' files linkLibFile;
home.sessionVariables = {
DIRENV_DEFAULT_FLAKE = cfg.defaultFlake;
};
};
}

View file

@ -7,7 +7,8 @@ use_pkgs() {
return 1
fi
local DEFAULT_FLAKE="pkgs"
# Use user-provided default value, or fallback to nixpkgs
local DEFAULT_FLAKE="${DIRENV_DEFAULT_FLAKE:-nixpkgs}"
# Allow changing the default flake through a command line switch
if [ "$1" = "-f" ] || [ "$1" = "--flake" ]; then