From e25cde731004008e0add2a232b68c1d950f42875 Mon Sep 17 00:00:00 2001 From: Arthur Wambst Date: Tue, 6 May 2025 17:09:26 +0200 Subject: [PATCH] trying stuff --- flake.nix | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/flake.nix b/flake.nix index 36a7b8b..cfbca45 100644 --- a/flake.nix +++ b/flake.nix @@ -21,23 +21,16 @@ # Select Python version based on the parameter python = pkgs.${pythonVersion}; - # Define package overrides for specific Python versions - packageOverrides = self: super: { - # Fix Sphinx for Python 3.10 - sphinx = if pythonVersion == "python310" then - super.sphinx.overridePythonAttrs (old: { - version = "latest"; # Use a version known to work with Python 3.10 - }) - else - super.sphinx; - - # Add more package overrides as needed - }; - + # Determine if Python version is 3.11 or higher + isPython311OrHigher = + let + versionStr = builtins.substring 6 10 pythonVersion; + versionNum = builtins.fromJSON (builtins.substring 0 1 versionStr + "." + builtins.substring 1 2 versionStr); + in + versionNum >= 3.11; + # Create Python with package overrides - pythonWithOverrides = python.override { - packageOverrides = packageOverrides; - }; + pythonWithOverrides = python; # Base Python packages that are always included basePackages = ps: with ps; [ @@ -51,11 +44,14 @@ pytest ipython + # Conditionally include sphinx for Python 3.11+ + (if isPython311OrHigher then sphinx else null) + # Add more default packages as needed ]; - # Combine base packages with extra packages - allPackages = ps: (basePackages ps) ++ (extraPackages ps); + # Combine base packages with extra packages and filter out nulls + allPackages = ps: builtins.filter (pkg: pkg != null) ((basePackages ps) ++ (extraPackages ps)); # Create the Python environment using the Python with overrides pythonEnv = pythonWithOverrides.withPackages allPackages; @@ -109,7 +105,7 @@ pythonVersion = mkOption { type = types.str; - default = "python311"; + default = "python313"; description = "Python version to use (e.g., python39, python310, python311)"; };