fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , pkgs , lib , ...} : 2 3let 4 5cfg = config . programs . pyenv ; 6 7tomlFormat = pkgs . formats . toml { }; 8 9in { 10meta . maintainers = with lib . maintainers ; [ tmarkus ]; 11 12options . programs . pyenv = { 13enable = lib . mkEnableOption "pyenv" ; 14 15package = lib . mkOption { 16type = lib . types . package ; 17default = pkgs . pyenv ; 18defaultText = lib . literalExpression "pkgs.pyenv" ; 19description = "The package to use for pyenv." ; 20}; 21 22enableBashIntegration = lib . mkOption { 23type = lib . types . bool ; 24default = true ; 25description = '' 26Whether to enable pyenv's Bash integration. 27'' ; 28}; 29 30enableZshIntegration = lib . mkOption { 31type = lib . types . bool ; 32default = true ; 33description = '' 34Whether to enable pyenv's Zsh integration. 35'' ; 36}; 37 38enableFishIntegration = lib . mkOption { 39type = lib . types . bool ; 40default = true ; 41description = '' 42Whether to enable pyenv's Fish integration. 43'' ; 44}; 45 46rootDirectory = lib . mkOption { 47type = lib . types . path ; 48apply = toString ; 49default = " ${ config . xdg . dataHome } /pyenv" ; 50defaultText = "\${config.xdg.dataHome}/pyenv" ; 51description = '' 52The pyenv root directory ({env}`PYENV_ROOT`). 53 54::: {.note} 55This deviates from upstream, which uses {file}`$HOME/.pyenv`. 56The default path in Home Manager is set according to the XDG 57base directory specification. 58::: 59'' ; 60}; 61}; 62 63config = lib . mkIf cfg . enable { 64# Always add the configured `pyenv` package. 65home . packages = [ cfg . package ]; 66 67programs . bash . initExtra = lib . mkIf cfg . enableBashIntegration '' 68export PYENV_ROOT=" ${ cfg . rootDirectory } " 69eval "$( ${ lib . getExe cfg . package } init - bash)" 70'' ; 71 72programs . zsh . initExtra = lib . mkIf cfg . enableZshIntegration '' 73export PYENV_ROOT=" ${ cfg . rootDirectory } " 74eval "$( ${ lib . getExe cfg . package } init - zsh)" 75'' ; 76 77programs . fish . interactiveShellInit = lib . mkIf cfg . enableFishIntegration '' 78set -Ux PYENV_ROOT " ${ cfg . rootDirectory } " 79${ lib . getExe cfg . package } init - fish | source 80'' ; 81}; 82}