Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package lsp-devtools in nix #128

Merged
merged 2 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

outputs = { self, nixpkgs, utils }:
{
overlays.default = import ./lib/pytest-lsp/nix/pytest-lsp-overlay.nix;
overlays.default = self: super:
nixpkgs.lib.composeManyExtensions [
(import ./lib/pytest-lsp/nix/pytest-lsp-overlay.nix)
(import ./lib/lsp-devtools/nix/lsp-devtools-overlay.nix)
] self super;
};
}
1 change: 1 addition & 0 deletions lib/lsp-devtools/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
result
61 changes: 61 additions & 0 deletions lib/lsp-devtools/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions lib/lsp-devtools/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
description = "lsp-devtools: Developer tooling for language servers";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, utils }:

let
eachPythonVersion = versions: f:
builtins.listToAttrs (builtins.map (version: {name = "py${version}"; value = f version; }) versions); in {

overlays.default = import ./nix/lsp-devtools-overlay.nix;

packages = utils.lib.eachDefaultSystemMap (system:
let
pkgs = import nixpkgs { inherit system; overlays = [ self.overlays.default ]; };
in
eachPythonVersion [ "38" "39" "310" "311"] (pyVersion:
pkgs."python${pyVersion}Packages".lsp-devtools
)
);
};
}
73 changes: 73 additions & 0 deletions lib/lsp-devtools/nix/lsp-devtools-overlay.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
final: prev:

let
# Read the package's version from file
lines = prev.lib.splitString "\n" (builtins.readFile ../lsp_devtools/__init__.py);
matches = builtins.map (builtins.match ''__version__ = "(.+)"'') lines;
versionStr = prev.lib.concatStrings (prev.lib.flatten (builtins.filter builtins.isList matches));
in {
pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [(
python-final: python-prev: {

stamina = python-prev.buildPythonPackage rec {
pname = "stamina";
version = "24.1.0";
format = "pyproject";

src = prev.fetchFromGitHub {
owner = "hynek";
repo = "stamina";
rev = "refs/tags/${version}";
hash = "sha256-bIVzE9/QsdGw/UE83q3Q/XG3jFnPy65pkDdMpYkIrrs=";
};

SETUPTOOLS_SCM_PRETEND_VERSION = version;
nativeBuildInputs = with python-final; [
hatchling
hatch-vcs
hatch-fancy-pypi-readme
];

propagatedBuildInputs = with python-final; [
tenacity
] ++ prev.lib.optional (pythonOlder "3.10") typing-extensions;

doCheck = true;
pythonImportsCheck = [ "stamina" ];
nativeCheckInputs = with python-prev; [
anyio
pytestCheckHook
];

};

lsp-devtools = python-prev.buildPythonPackage {
pname = "lsp-devtools";
version = versionStr;
format = "pyproject";

src = ./..;

nativeBuildInputs = with python-final; [
hatchling
];

propagatedBuildInputs = with python-final; [
aiosqlite
platformdirs
pygls
stamina
textual
] ++ prev.lib.optional (pythonOlder "3.9") importlib-resources
++ prev.lib.optional (pythonOlder "3.8") typing-extensions;

doCheck = true;
pythonImportsCheck = [ "lsp_devtools" ];
nativeCheckInputs = with python-prev; [
pytestCheckHook
];

};
}
)];
}