@@ -9,6 +9,7 @@ let
99 envs = let
1010 inherit python;
1111 pythonEnv = python.withPackages(ps: with ps; [ ]);
12+ pythonVirtualEnv = python.withPackages(ps: with ps; [ virtualenv ]);
1213 in {
1314 # Plain Python interpreter
1415 plain = rec {
@@ -16,6 +17,20 @@ let
1617 interpreter = env.interpreter;
1718 is_venv = "False";
1819 is_nixenv = "False";
20+ is_virtualenv = "False";
21+ };
22+ } // lib.optionalAttrs (python.isPy3k && !python.isPyPy) {
23+ # Use virtualenv from a Nix env.
24+ # Does not function with Python 2
25+ # ValueError: source and destination is the same /nix/store/38kz3j1a87cq5y59k5w7k9yk4cqgc5b2-python-2.7.18/lib/python2.7/os.py
26+ nixenv-virtualenv = rec {
27+ env = runCommand "${python.name}-virtualenv" {} ''
28+ ${pythonVirtualEnv.interpreter} -m virtualenv $out
29+ '';
30+ interpreter = "${env}/bin/${python.executable}";
31+ is_venv = "False";
32+ is_nixenv = "True";
33+ is_virtualenv = "True";
1934 };
2035 } // lib.optionalAttrs (python.implementation != "graal") {
2136 # Python Nix environment (python.buildEnv)
@@ -24,6 +39,7 @@ let
2439 interpreter = env.interpreter;
2540 is_venv = "False";
2641 is_nixenv = "True";
42+ is_virtualenv = "True";
2743 };
2844 } // lib.optionalAttrs (python.isPy3k && (!python.isPyPy)) rec {
2945 # Venv built using plain Python
@@ -36,6 +52,7 @@ let
3652 interpreter = "${env}/bin/${python.executable}";
3753 is_venv = "True";
3854 is_nixenv = "False";
55+ is_virtualenv = "True";
3956 };
4057
4158 } // lib.optionalAttrs (python.pythonAtLeast "3.8") {
@@ -49,6 +66,7 @@ let
4966 interpreter = "${env}/bin/${pythonEnv.executable}";
5067 is_venv = "True";
5168 is_nixenv = "True";
69+ is_virtualenv = "True";
5270 };
5371 };
5472