1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 11:39:46 +01:00

pyenv: add module

Adds a module for pyenv (https://github.com/pyenv/pyenv).
This commit is contained in:
Tobias Markus 2023-07-07 14:40:34 +02:00 committed by Robert Helgesson
parent 050d01a62c
commit 069d450b6d
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
8 changed files with 144 additions and 0 deletions

View file

@ -1150,6 +1150,13 @@ in
A new modules is available: 'programs.darcs'
'';
}
{
time = "2023-07-08T09:21:06+00:00";
message = ''
A new module is available: 'programs.pyenv'.
'';
}
];
};
}

View file

@ -169,6 +169,7 @@ let
./programs/pls.nix
./programs/powerline-go.nix
./programs/pubs.nix
./programs/pyenv.nix
./programs/pylint.nix
./programs/qutebrowser.nix
./programs/rbw.nix

View file

@ -0,0 +1,79 @@
{ 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.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to enable pyenv's Bash integration.
'';
};
enableZshIntegration = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to enable pyenv's Zsh integration.
'';
};
enableFishIntegration = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to enable pyenv's Fish integration.
'';
};
rootDirectory = lib.mkOption {
type = lib.types.path;
apply = toString;
default = "${config.xdg.dataHome}/pyenv";
defaultText = "\${config.xdg.dataHome}/pyenv";
description = ''
The pyenv root directory (PYENV_ROOT).
</para><para>
Note: Deviating from upstream which uses `$HOME/.pyenv`,
the default path 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
'';
};
}

View file

@ -117,6 +117,7 @@ import nmt {
./modules/programs/pls
./modules/programs/powerline-go
./modules/programs/pubs
./modules/programs/pyenv
./modules/programs/qutebrowser
./modules/programs/readline
./modules/programs/ripgrep

View file

@ -0,0 +1,17 @@
{ ... }:
{
programs = {
bash.enable = true;
pyenv.enable = true;
};
test.stubs.pyenv = { name = "pyenv"; };
nmt.script = ''
assertFileExists home-files/.bashrc
assertFileContains \
home-files/.bashrc \
'eval "$(@pyenv@/bin/pyenv init - bash)"'
'';
}

View file

@ -0,0 +1,5 @@
{
pyenv-bash = ./bash.nix;
pyenv-zsh = ./zsh.nix;
pyenv-fish = ./fish.nix;
}

View file

@ -0,0 +1,17 @@
{ ... }:
{
programs = {
fish.enable = true;
pyenv.enable = true;
};
test.stubs.pyenv = { name = "pyenv"; };
nmt.script = ''
assertFileExists home-files/.config/fish/config.fish
assertFileContains \
home-files/.config/fish/config.fish \
'@pyenv@/bin/pyenv init - fish | source'
'';
}

View file

@ -0,0 +1,17 @@
{ ... }:
{
programs = {
zsh.enable = true;
pyenv.enable = true;
};
test.stubs.pyenv = { name = "pyenv"; };
nmt.script = ''
assertFileExists home-files/.zshrc
assertFileContains \
home-files/.zshrc \
'eval "$(@pyenv@/bin/pyenv init - zsh)"'
'';
}