From 22f2be0e870526d87a20b8c405edd90080332554 Mon Sep 17 00:00:00 2001 From: Arthur Wambst Date: Tue, 6 May 2025 17:15:20 +0200 Subject: [PATCH] trying stuff --- flake.nix | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/flake.nix b/flake.nix index cfbca45..76135d9 100644 --- a/flake.nix +++ b/flake.nix @@ -20,7 +20,7 @@ # Select Python version based on the parameter python = pkgs.${pythonVersion}; - + # Determine if Python version is 3.11 or higher isPython311OrHigher = let @@ -29,8 +29,18 @@ in versionNum >= 3.11; + # Define package overrides for specific Python versions + packageOverrides = self: super: { + # Remove sphinx for Python versions under 3.11 + sphinx = if !isPython311OrHigher then null else super.sphinx; + + # Add more package overrides as needed + }; + # Create Python with package overrides - pythonWithOverrides = python; + pythonWithOverrides = python.override { + packageOverrides = packageOverrides; + }; # Base Python packages that are always included basePackages = ps: with ps; [ @@ -44,14 +54,11 @@ 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 and filter out nulls - allPackages = ps: builtins.filter (pkg: pkg != null) ((basePackages ps) ++ (extraPackages ps)); + # Combine base packages with extra packages + allPackages = ps: (basePackages ps) ++ (extraPackages ps); # Create the Python environment using the Python with overrides pythonEnv = pythonWithOverrides.withPackages allPackages; @@ -105,7 +112,7 @@ pythonVersion = mkOption { type = types.str; - default = "python313"; + default = "python311"; description = "Python version to use (e.g., python39, python310, python311)"; };