Skip to content

Commit 7db658b

Browse files
committed
feat: a Nix build environment
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.
1 parent 1faee72 commit 7db658b

File tree

3 files changed

+130
-0
lines changed

3 files changed

+130
-0
lines changed

changelog/14520.contrib.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Flake-based Nix build environments are now supported via ``nix develop``.

flake.lock

Lines changed: 59 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
description = "Development environment for Pytest";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
6+
nixpkgs-unstable.url = "github:NixOS/nixpkgs";
7+
systems.url = "github:nix-systems/default";
8+
};
9+
10+
outputs = { self, nixpkgs, nixpkgs-unstable, systems }:
11+
let
12+
forAllSystems = nixpkgs.lib.genAttrs (import systems);
13+
mkPkgs = system: import nixpkgs {
14+
inherit system;
15+
overlays = [ self.overlays.newer-pre-commit ];
16+
};
17+
in
18+
{
19+
packages = forAllSystems (system:
20+
let
21+
pkgs = mkPkgs system;
22+
in
23+
{
24+
fhs-test-env = pkgs.buildFHSEnv {
25+
name = "fhs-test-env";
26+
targetPkgs = fhspkgs:
27+
let
28+
python313-with-tox = pkgs.python313.withPackages (ps: with ps; [
29+
tox
30+
]);
31+
in
32+
[
33+
python313-with-tox
34+
35+
# other Pythons
36+
fhspkgs.python310
37+
fhspkgs.python311
38+
fhspkgs.python312
39+
fhspkgs.python314
40+
41+
fhspkgs.bashInteractive
42+
fhspkgs.pre-commit
43+
44+
];
45+
runScript = "bash";
46+
};
47+
});
48+
49+
devShells = forAllSystems (system:
50+
let
51+
pkgs = mkPkgs system;
52+
in
53+
{
54+
default = pkgs.mkShell {
55+
packages = [ self.packages.${system}.fhs-test-env ];
56+
shellHook = "exec fhs-test-env";
57+
};
58+
});
59+
60+
overlays = {
61+
newer-pre-commit = final: prev: {
62+
pre-commit =
63+
let
64+
pkgs = import nixpkgs-unstable { inherit (final.stdenv.hostPlatform) system; };
65+
in
66+
pkgs.pre-commit;
67+
};
68+
};
69+
};
70+
}

0 commit comments

Comments
 (0)