Skip to content

feat: a Nix build environment#14249

Open
prsteele wants to merge 2 commits intopytest-dev:mainfrom
prsteele:nix-environment
Open

feat: a Nix build environment#14249
prsteele wants to merge 2 commits intopytest-dev:mainfrom
prsteele:nix-environment

Conversation

@prsteele
Copy link

@prsteele prsteele commented Mar 3, 2026

Overview

This commit creates a flake.nix file defining a minimal build environment for Nix users. If you have Nix installed, you can run

nix develop

to enter an environment where

tox -e linting,py310,py311,py312,py313,py314

work as expected.

Details

This change does not impose any changes on existing workflows; it is intended only to make it easier for Nix users to contribute to pytest.

For those Nix users, this change does not even package pytest as a Nix derivation; instead, it provides a minimal build environment that behaves like an "ordinary" Python environment, albeit one with all pytest-supported versions of Python installed.

Testing

The commands

nix develop

followed by

tox -e linting,py310,py311,py312,py313,py314

passes.

Closes #14250.

This commit creates a flake.nix file defining a minimal build
environment for Nix users. If you have Nix, you can run

    nix develop

to enter a FHS-compliant environment with Python 3.10, 3.11, 3.12,
3.13, and 3.14 installed, along with development tools like tox and
pre-commit. From here, ordinary commands like

    tox -e linting,py310,py311,py312,py313,py314

work as expected.

Note that this environment does not provide any Python packages except
tox; all dependencies are installed via tox as if we were not using
Nix.
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Mar 3, 2026
Copy link
Member

@webknjaz webknjaz left a comment

Choose a reason for hiding this comment

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

I think this doesn't belong upstream as having it implies an unreasonable amount of maintenance burden for the maintainers. It usually makes sense to maintain what's in the CI and in the expected dev env, which is tox — allowing us to reduce said burdens by using a workflow tool that makes the CI configuration as close as possible to the dev env.

flake.nix Outdated
@@ -0,0 +1,70 @@
{
description = "Development environment for Pytest";
Copy link
Member

Choose a reason for hiding this comment

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

We should note that this is a convenience for and by nix users and not maintained by pytest core

Copy link
Author

Choose a reason for hiding this comment

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

Sure thing; updated. Happy with whatever language you'd like.

@prsteele
Copy link
Author

prsteele commented Mar 5, 2026

I think this doesn't belong upstream as having it implies an unreasonable amount of maintenance burden for the maintainers.

I certainly didn't intend for this to weigh on maintainers; my hope is that it would almost never be touched, as it really just provides a way to get tox, which is (as you said) the expected tool to use.

I'm new here so this offer isn't worth much, but I'd be happy to update this if it somehow falls out of sync down the line.

Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

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

I think it's OK to add this

With the expectation that nix users guy it if necessary

Im no longer a nix user and unless something about nix changes im not picking it up again

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

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A Nix build environment

3 participants