about summary refs log tree commit diff
path: root/home/python/default.nix
blob: fa5e0d81d4d0d6646fe78d2da6ff1b5d25803b3d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{ config, pkgs, lib, ... }:
let
  cfg = config.my.home.python;
  pythonEnv = pkgs.python3.withPackages (p: with p; [
    black # format
    isort # format
    pylsp-mypy # language server protocol
    requests # HTTP library
    types-requests # types for requests (for mypy)
    pip # to install dependencies
    ipython # nicer REPL
  ]);
in
{
  options.my.home.python = with lib; {
    enable = mkEnableOption "python configuration";
  };

  config = lib.mkIf cfg.enable {
    home.packages = with pkgs.python310Packages; [ pythonEnv ];

    home.sessionVariables = with config.xdg; {
      PIP_LOG = "${cacheHome}/pip/pip.log";
      PYLINTHOME = "${cacheHome}/pylint";
      PYTHON_EGG_CACHE = "${cacheHome}/python-eggs";
      PYTHON_HISTFILE = "${cacheHome}/python_history";
    };
  };
}