Skip to content

feat: add nix flake#107

Merged
bellini666 merged 2 commits intobellini666:masterfrom
barrettruth:feat/nix-flake
Mar 2, 2026
Merged

feat: add nix flake#107
bellini666 merged 2 commits intobellini666:masterfrom
barrettruth:feat/nix-flake

Conversation

@barrettruth
Copy link
Copy Markdown
Contributor

@barrettruth barrettruth commented Mar 1, 2026

Problem

No Nix packaging exists for pytest-language-server (#99), making it harder
to install and develop on NixOS or with nix.

Additionally, two tests (test_exclude_patterns_in_workspace_scan and
test_exclude_patterns_glob_matching) fail inside the Nix build sandbox
because scan_workspace_with_excludes checks every component of the
absolute path against SKIP_DIRECTORIES. In the sandbox, TMPDIR=/build,
and "build" is a skip entry, so all files are silently skipped.

Solution

Scanner fix: canonicalize root_path at the top of
scan_workspace_with_excludes and use strip_prefix before the
skip-directory check so only path components relative to the workspace
root are inspected.

Flake: add flake.nix with a buildRustPackage derivation
(doCheck = true, tests pass after the fix) and a dev shell providing
the Rust toolchain. Supports x86_64-linux, aarch64-linux,
x86_64-darwin, and aarch64-darwin.

A nixpkgs package has also been drafted at NixOS/nixpkgs#495575,
pending this fix being merged and released.

Closes #99

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class Nix support for pytest-language-server and adjusts workspace scanning to avoid Nix sandbox path components (e.g., /build) triggering skip-directory logic.

Changes:

  • Canonicalize the workspace root once and ensure skip-directory checks only inspect components relative to the workspace root.
  • Add a flake.nix providing a buildRustPackage package output and a Rust dev shell.
  • Add flake.lock pinning nixpkgs.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/fixtures/scanner.rs Adjusts workspace root handling and skip-directory checks to behave correctly in Nix sandboxes.
flake.nix Introduces Nix flake packaging and a development shell.
flake.lock Pins nixpkgs input for reproducible builds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 63.12%. Comparing base (5e424ec) to head (8dc5954).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/fixtures/scanner.rs 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #107      +/-   ##
==========================================
- Coverage   63.17%   63.12%   -0.05%     
==========================================
  Files          26       26              
  Lines        3392     3393       +1     
==========================================
- Hits         2143     2142       -1     
- Misses       1249     1251       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bellini666
Copy link
Copy Markdown
Owner

@barrettruth can you check both comments from copilot?

Also, do we need to have a flow like https://github.com/bellini666/pytest-language-server/blob/master/.github/workflows/release.yml#L157 for this? Or a single flow that does both?

Problem: scan_workspace_with_excludes checked every component of the
absolute path against SKIP_DIRECTORIES. In environments where the
workspace lives under a directory whose name matches a skip entry
(e.g. Nix sandbox uses TMPDIR=/build, and "build" is in
SKIP_DIRECTORIES), all files were silently skipped and no fixtures
were discovered.

Solution: canonicalize root_path once at the top of the function and
strip_prefix before checking path components, so only components
relative to the workspace root are inspected.
Problem: no Nix packaging existed for pytest-language-server, making
it harder to install and develop on NixOS or with nix.

Solution: add flake.nix with a buildRustPackage derivation (doCheck
enabled) and a dev shell providing the Rust toolchain. Version is
read from Cargo.toml to avoid drift.

Closes #99
@barrettruth
Copy link
Copy Markdown
Contributor Author

@bellini666 thanks for the response. Both issues fixed from the bot. As per your question, this PR is "missing" a final step - actually adding a PR up to nixOS/nixpkgs that adds pytest-language-server to the nixpkgs registry and ecosystem. I already have a draft for this.

And, helpfully, if pytest-language-server is added to the registry, it will be automatically re-built and updated - no need for any maintenance on our side.

In other words, after this PR and the upstream one gets merged, pytest-language-server will be fully usable in nix.

@bellini666
Copy link
Copy Markdown
Owner

@barrettruth nice! After CI is green I'll merge this!

Do we need a new release for this or just being on main branch is enough?

@bellini666 bellini666 merged commit fcd530a into bellini666:master Mar 2, 2026
12 checks passed
@barrettruth
Copy link
Copy Markdown
Contributor Author

No release needed / thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add flake.nix for Nix packaging

3 participants