From b3a6e6393c38d9fe8a505f61c459c15d4072a16a Mon Sep 17 00:00:00 2001 From: Alexander Tomokhov Date: Wed, 22 Nov 2023 09:37:49 +0400 Subject: [PATCH] devShell: add python environment explicitly (for VS Code) --- default.nix | 4 ---- flake.nix | 26 +++++++++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/default.nix b/default.nix index 98f37b3..b1c3e0b 100644 --- a/default.nix +++ b/default.nix @@ -27,8 +27,4 @@ pythonPackages.buildPythonApplication rec { SelfPrivacy Server Management API ''; }; - passthru = { - # TODO explain what's the purpose of this? - pythonPath = pythonPackages.makePythonPath propagatedBuildInputs; - }; } diff --git a/flake.nix b/flake.nix index 6d480c7..75391ba 100644 --- a/flake.nix +++ b/flake.nix @@ -20,15 +20,23 @@ ]; }; devShells.${system}.default = pkgs.mkShell { - inputsFrom = [ selfprivacy-graphql-api ]; - packages = with pkgs; [ - black - rclone - redis - restic - ]; - # FIXME is it still needed inside shellHook? - # PYTHONPATH=${sp-python}/${sp-python.sitePackages} + packages = + let + # TODO is there a better way to get environment for VS Code? + python3 = + nixpkgs.lib.findFirst (p: p.pname == "python3") (abort "wtf") + self.packages.${system}.default.propagatedBuildInputs; + python-env = + python3.withPackages + (_: self.packages.${system}.default.propagatedBuildInputs); + in + with pkgs; [ + python-env + black + rclone + redis + restic + ]; shellHook = '' # envs set with export and as attributes are treated differently. # for example. printenv will not fetch the value of an attribute.