dotfiles/modules/programs/python.nix
Moritz Böhme 01cb099643
fix poetry not building for python3.11
Also changes python lsp to pyright.
2023-01-11 10:42:02 +01:00

47 lines
1,022 B
Nix

{ config
, lib
, pkgs
, ...
}:
with lib;
let
cfg = config.my.programs.python;
mkPython = packages: version: pkgs.${version}.withPackages (ps: map (flip getAttr ps) packages);
pythonVersions = [
"python311"
"python310"
"python39"
"python38"
];
packageLists = map (version: attrNames pkgs."${version}Packages") cfg.versions;
commonPackages = foldl' intersectLists (head packageLists) (tail packageLists);
in
{
options.my.programs.python = {
enable = mkEnableOption "python";
versions = mkOption {
default = [ "python310" ];
type = with types; nonEmptyListOf (enum pythonVersions);
example = [ "python39" ];
};
packages = mkOption {
default = [
"flake8"
"isort"
"mypy"
"pytest"
];
type = with types; listOf (enum commonPackages);
};
};
config = mkIf cfg.enable {
users.users.moritz.packages = map (mkPython cfg.packages) cfg.versions
++ [ pkgs.poetry pkgs.nodePackages.pyright ];
};
}