From 8a6311b89654a4f0b7344a76e12e783d301a45d1 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 27 Jun 2024 19:14:42 +0200 Subject: [PATCH] rye: update & use globally --- .../terminal/coding/python/default.nix | 1 - .../terminal/coding/python/python.nix | 14 ---------- home/programs/terminal/coding/python/rye.nix | 26 ++++++++++++++++++- hosts/voyager/default.nix | 1 + 4 files changed, 26 insertions(+), 16 deletions(-) delete mode 100644 home/programs/terminal/coding/python/python.nix diff --git a/home/programs/terminal/coding/python/default.nix b/home/programs/terminal/coding/python/default.nix index 1bf124b..0241592 100644 --- a/home/programs/terminal/coding/python/default.nix +++ b/home/programs/terminal/coding/python/default.nix @@ -1,6 +1,5 @@ { imports = [ - ./python.nix ./ipython.nix ./poetry.nix ./rye.nix diff --git a/home/programs/terminal/coding/python/python.nix b/home/programs/terminal/coding/python/python.nix deleted file mode 100644 index f4628e2..0000000 --- a/home/programs/terminal/coding/python/python.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ - lib, - pkgs, - osConfig, - ... -}: let - inherit (lib) mkIf; - - cfg = osConfig.myOptions.home-manager.programs.coding.python; -in { - config = mkIf cfg.enable { - home.packages = with pkgs; [ python312 ]; - }; -} diff --git a/home/programs/terminal/coding/python/rye.nix b/home/programs/terminal/coding/python/rye.nix index 5e06e4c..3ac8e9a 100644 --- a/home/programs/terminal/coding/python/rye.nix +++ b/home/programs/terminal/coding/python/rye.nix @@ -1,14 +1,38 @@ { lib, pkgs, + config, osConfig, ... }: let inherit (lib) mkIf; cfg = osConfig.myOptions.home-manager.programs.coding.python; + + toTOML = name: (pkgs.formats.toml {}).generate "${name}"; in { config = mkIf cfg.enable { - home.packages = with pkgs; [ rye ]; + home = { + packages = with pkgs; [ rye ]; + + 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: + xdg.configFile."rye/config.toml".source = toTOML "config.toml" { + default.license = "GPL-3.0-or-later"; + behavior.global-python=true; + }; }; } diff --git a/hosts/voyager/default.nix b/hosts/voyager/default.nix index 68be7f9..65f1f3b 100644 --- a/hosts/voyager/default.nix +++ b/hosts/voyager/default.nix @@ -79,6 +79,7 @@ # Language package managers ".local/share/cargo" ".local/share/go" + ".config/rye" ]; extraFiles = [ ".config/gtk-3.0/bookmarks"