mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-07 01:07:00 +00:00
Standardize all 'programs.<PROGRAM>.enable<SHELL>Integration' options with the following new functions: - lib.hm.shell.mkBashIntegrationOption - lib.hm.shell.mkFishIntegrationOption - lib.hm.shell.mkIonIntegrationOption - lib.hm.shell.mkNushellIntegrationOption - lib.hm.shell.mkZshIntegrationOption These functions should default to their corresponding global option: - home.shell.enableBashIntegration - home.shell.enableFishIntegration - home.shell.enableIonIntegration - home.shell.enableNushellIntegration - home.shell.enableZshIntegration All these global options default to the 'home.shell.enableShellIntegration' value. This hierarchy standardizes the shell integration and increases end-user flexibility. BREAKING CHANGE: The following inconsistent default values change from 'false' to 'true': - programs.zellij.enableBashIntegration - programs.zellij.enableFishIntegration - programs.zellij.enableZshIntegration Link: https://github.com/nix-community/home-manager/pull/6358 Co-authored-by: Robert Helgesson <robert@rycee.net>
67 lines
1.8 KiB
Nix
67 lines
1.8 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.programs.pyenv;
|
|
|
|
tomlFormat = pkgs.formats.toml { };
|
|
|
|
in {
|
|
meta.maintainers = with lib.maintainers; [ tmarkus ];
|
|
|
|
options.programs.pyenv = {
|
|
enable = lib.mkEnableOption "pyenv";
|
|
|
|
package = lib.mkOption {
|
|
type = lib.types.package;
|
|
default = pkgs.pyenv;
|
|
defaultText = lib.literalExpression "pkgs.pyenv";
|
|
description = "The package to use for pyenv.";
|
|
};
|
|
|
|
enableBashIntegration =
|
|
lib.hm.shell.mkBashIntegrationOption { inherit config; };
|
|
|
|
enableFishIntegration =
|
|
lib.hm.shell.mkFishIntegrationOption { inherit config; };
|
|
|
|
enableZshIntegration =
|
|
lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
|
|
|
rootDirectory = lib.mkOption {
|
|
type = lib.types.path;
|
|
apply = toString;
|
|
default = "${config.xdg.dataHome}/pyenv";
|
|
defaultText = "\${config.xdg.dataHome}/pyenv";
|
|
description = ''
|
|
The pyenv root directory ({env}`PYENV_ROOT`).
|
|
|
|
::: {.note}
|
|
This deviates from upstream, which uses {file}`$HOME/.pyenv`.
|
|
The default path in Home Manager is set according to the XDG
|
|
base directory specification.
|
|
:::
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
# Always add the configured `pyenv` package.
|
|
home.packages = [ cfg.package ];
|
|
|
|
programs.bash.initExtra = lib.mkIf cfg.enableBashIntegration ''
|
|
export PYENV_ROOT="${cfg.rootDirectory}"
|
|
eval "$(${lib.getExe cfg.package} init - bash)"
|
|
'';
|
|
|
|
programs.zsh.initExtra = lib.mkIf cfg.enableZshIntegration ''
|
|
export PYENV_ROOT="${cfg.rootDirectory}"
|
|
eval "$(${lib.getExe cfg.package} init - zsh)"
|
|
'';
|
|
|
|
programs.fish.interactiveShellInit = lib.mkIf cfg.enableFishIntegration ''
|
|
set -Ux PYENV_ROOT "${cfg.rootDirectory}"
|
|
${lib.getExe cfg.package} init - fish | source
|
|
'';
|
|
};
|
|
}
|