diff --git a/modules/users/modules/language/python.nix b/modules/users/modules/language/python.nix new file mode 100644 index 0000000..42ffa44 --- /dev/null +++ b/modules/users/modules/language/python.nix @@ -0,0 +1,56 @@ +{ + lib, + config, + pkgs, + ... +}: + +with lib; +let + cfg = config.modules.python; + package = pkgs.python3.withPackages cfg.extraPythonPackages; +in +{ + options.modules.python = { + enable = mkEnableOption "python"; + extraPythonPackages = mkOption { + type = types.functionTo (types.listOf types.package) // { + merge = + loc: defs: p: + lib.concatMap (def: (def.value p)) defs; + }; + default = p: [ ]; + description = "Extra Python packages to install"; + }; + }; + + config = mkIf cfg.enable { + # Development packages + home.packages = [ + package + ]; + + # Allow unfree + modules.unfree.allowedPackages = [ + "vscode-extension-MS-python-vscode-pylance" + ]; + + # VSCode configuration + programs.vscode = { + extensions = with pkgs.vscode-extensions; [ + ms-python.python + ms-python.debugpy + ms-python.vscode-pylance + ]; + + userSettings = { + "[python]" = { + "editor.defaultFormatter" = "ms-python.vscode-pylance"; + }; + }; + }; + + # Neovim configuration + programs.nixvim = { }; + }; +}