diff --git a/system/home/emacs/templates b/system/home/emacs/templates index 8f0caf85..a243638f 100644 --- a/system/home/emacs/templates +++ b/system/home/emacs/templates @@ -9,18 +9,6 @@ nix-mode > "};" n "in" n > "fhs.env") -(pyshell "let" n - > "pkgs = import " (p "") " { };" n - > "fix-python = (builtins.getFlake \"github:GuillaumeDesforges/fix-python\").packages.${pkgs.system}.default;" n - > "python3 = pkgs." (p "python3") ";" n - "in" n - "pkgs.mkShellNoCC {" n - > "packages = [python3 fix-python pkgs.uv];" n - > "shellHook = ''" n - > "export PYTHONPATH=$(readlink -f " (p "./.") "):$PYTHONPATH" n - > "export MPLBACKEND=" (p "TkAgg") n - > "'';"n - "}") ;; Local Variables: ;; mode: lisp-data diff --git a/system/home/programming/python/default.nix b/system/home/programming/python/default.nix index 7808eee4..3b5739a4 100644 --- a/system/home/programming/python/default.nix +++ b/system/home/programming/python/default.nix @@ -1,23 +1,24 @@ { pkgs, ... }: -# MPLBACKEND -{ - home.packages = with pkgs; [ - (python3.withPackages ( +let + pythonEnv = ( + pkgs.python312.withPackages ( ps: with ps; [ python-lsp-server - pylsp-rope - rope isort flake8 mypy - pyyaml numpy xarray netcdf4 matplotlib ] - )) - ruff + ) + ); +in +{ + home.packages = [ + pkgs.ruff + pythonEnv ]; xdg.configFile."ruff/pyproject.toml".source = ./ruff.toml; } diff --git a/system/home/programming/python/pyshell.nix b/system/home/programming/python/pyshell.nix new file mode 100644 index 00000000..5777e876 --- /dev/null +++ b/system/home/programming/python/pyshell.nix @@ -0,0 +1,31 @@ +{ + pkgs ? import { }, + python3 ? pkgs.python3, + extraPackages ? with pkgs; [ uv ], +}: +let + inherit (pkgs) lib; + ldlibs = lib.makeLibraryPath ( + with pkgs; + [ + stdenv.cc.cc + glibc + zlib + zstd + ] + ); + pythonWrapped = pkgs.symlinkJoin { + name = "python"; + paths = [ python3 ]; + buildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + for file in $out/bin/*; do wrapProgram "$file" --prefix LD_LIBRARY_PATH : "${ldlibs}"; done + ''; + }; +in +pkgs.mkShellNoCC { + packages = [ pythonWrapped ] ++ extraPackages; + shellHook = '' + [ -f .venv/bin/activate ] && source .venv/bin/activate + ''; +}