grimm-nixos-laptop/common/tooling/python.nix

75 lines
1.7 KiB
Nix
Raw Permalink Normal View History

2024-05-07 23:31:41 +02:00
{
pkgs,
config,
lib,
...
}:
let
2024-05-18 16:41:17 +02:00
lang_support_id = "python";
2024-05-11 22:55:59 +02:00
inherit (config.grimmShared) enable tooling graphical;
pyLibs =
python-pkgs: with python-pkgs; [
requests
matplotlib
numpy
scipy
pygobject3
2024-05-25 23:14:08 +02:00
pandas
2024-05-11 22:55:59 +02:00
];
2024-05-18 16:41:17 +02:00
inherit (lib)
mkIf
types
mkOption
mapAttrsToList
concatLines
2024-05-25 23:14:08 +02:00
getExe
2024-05-18 16:41:17 +02:00
elem
;
in
{
2024-05-18 16:41:17 +02:00
config = mkIf (enable && tooling.enable && (elem lang_support_id tooling.supportedLangs)) {
2024-05-11 22:55:59 +02:00
environment.systemPackages = [
(pkgs.python3.withPackages pyLibs)
] ++ lib.optionals graphical (with pkgs; [ jetbrains.pycharm-community ]);
2024-05-11 22:55:59 +02:00
programs.xonsh = {
enable = true;
2024-05-29 09:47:17 +02:00
config =
2024-05-30 22:12:15 +02:00
(
let
cfg = config.programs.starship;
settingsFormat = pkgs.formats.toml { };
settingsFile = settingsFormat.generate "starship.toml" cfg.settings;
in
''
$STARSHIP_CONFIG="${settingsFile}"
$SHELL="${getExe config.programs.xonsh.package}"
execx($(${getExe pkgs.starship} init xonsh))
''
)
2024-05-29 09:47:17 +02:00
+ concatLines (
mapAttrsToList (
name: value: "aliases[\"${name}\"] = '''${value}'''"
) config.environment.shellAliases
);
2024-09-08 14:57:15 +02:00
package = pkgs.xonsh.override { extraPackages = pyLibs; };
};
2024-05-15 23:24:35 +02:00
grimmShared.tooling.lang_servers = [
{
2024-05-30 22:12:15 +02:00
lsp.package = pkgs.python311Packages.python-lsp-server;
2024-05-15 23:24:35 +02:00
fmt = {
package = pkgs.yapf;
includes = [ "*.py" ];
options = [ "-i" ];
};
}
];
2024-05-11 22:55:59 +02:00
};
2024-05-18 16:41:17 +02:00
options.grimmShared.tooling.supportedLangs = mkOption {
type = types.listOf (types.enum [ lang_support_id ]);
};
}