nixdots/home/programs/terminal/coding/python/rye.nix

39 lines
1 KiB
Nix
Raw Normal View History

2024-06-26 21:46:50 +00:00
{
lib,
pkgs,
2024-06-27 17:14:42 +00:00
config,
2024-06-26 21:46:50 +00:00
osConfig,
...
}: let
inherit (lib) mkIf;
cfg = osConfig.myOptions.home-manager.programs.coding.python;
2024-06-27 17:14:42 +00:00
toTOML = name: (pkgs.formats.toml {}).generate "${name}";
2024-06-26 21:46:50 +00:00
in {
config = mkIf cfg.enable {
2024-06-27 17:14:42 +00:00
home = {
2024-07-26 23:07:07 +00:00
packages = with pkgs; [rye];
2024-06-27 17:14:42 +00:00
sessionVariables = {
RYE_HOME = "${config.xdg.configHome}/rye";
};
# Add rye python shims to path.
# Rye provides python executables that will automatically pick up on the python
# from a virtual environment, if we're in a directory (project) with one. If not,
# rye will fall back to system python. That is, if behavior.global-python=false,
# otherwise, we can actually use a python version from rye as our global python.
sessionPath = [
"${config.xdg.configHome}/rye/shims"
];
};
# see: <https://rye.astral.sh/guide/config/#config-file>
xdg.configFile."rye/config.toml".source = toTOML "config.toml" {
default.license = "GPL-3.0-or-later";
2024-07-26 23:07:07 +00:00
behavior.global-python = true;
2024-06-27 17:14:42 +00:00
};
2024-06-26 21:46:50 +00:00
};
}