Skip to content

Commit 2671307

Browse files
authored
Add Nix Dev Environment Support
Resolves #20
1 parent 52ec578 commit 2671307

13 files changed

+135
-32
lines changed

.envrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
layout pyenv $(cat runtimes.txt)
1+
if command -v pyenv >/dev/null 2>&1; then
2+
layout pyenv $(cat runtimes.txt)
3+
elif command -v nix >/dev/null 2>&1; then
4+
use flake
5+
layout python python3.12
6+
fi

.github/workflows/pre-commit.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v2
13-
- uses: actions/setup-python@v2
14-
- uses: pre-commit/action@v2.0.0
13+
- uses: DeterminateSystems/nix-installer-action@v3
14+
- uses: DeterminateSystems/magic-nix-cache-action@main
15+
- uses: HatsuneMiku3939/direnv-action@v1
16+
- run: |
17+
pip install -r requirements/pre-commit.txt
18+
pre-commit run -a

.github/workflows/test.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,11 @@ on:
88
jobs:
99
test:
1010
runs-on: ubuntu-latest
11-
strategy:
12-
matrix:
13-
python-version: ["3.9", "3.10", "3.11", "3.12"]
14-
name: ${{ matrix.python-version }}
1511
steps:
1612
- uses: actions/checkout@v2
17-
- uses: actions/setup-python@v2
18-
with:
19-
python-version: ${{ matrix.python-version }}
13+
- uses: DeterminateSystems/nix-installer-action@v3
14+
- uses: DeterminateSystems/magic-nix-cache-action@main
15+
- uses: HatsuneMiku3939/direnv-action@v1
2016
- run: |
2117
pip install -r requirements/test.txt
22-
pip install -e .
23-
pytest
18+
tox

.pre-commit-config.yaml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,28 @@ repos:
2828
- id: sort-simple-yaml # Sorts simple YAML files which consist only of top-level keys, preserving comments and blocks.
2929
- id: trailing-whitespace # This hook trims trailing whitespace.
3030

31-
- repo: https://github.com/psf/black
32-
rev: 22.10.0
31+
- repo: local
3332
hooks:
3433
- id: black
34+
name: black
35+
language: system
36+
entry: black --check
37+
types: [python]
3538

36-
- repo: https://github.com/timothycrosley/isort
37-
rev: 5.12.0
38-
hooks:
3939
- id: isort
40+
name: isort
41+
language: system
42+
entry: isort --check
43+
types: [python]
4044

41-
- repo: https://github.com/pycqa/flake8
42-
rev: 6.0.0
43-
hooks:
4445
- id: flake8
46+
name: flake8
47+
language: system
48+
entry: flake8
49+
types: [python]
4550

46-
- repo: https://github.com/pre-commit/mirrors-mypy
47-
rev: v0.991
48-
hooks:
4951
- id: mypy
52+
name: mypy
53+
language: system
54+
entry: mypy --ignore-missing-imports
55+
types: [python]

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ This will cause all logs to have the `trace_id=123` pair regardless of including
234234

235235
### Required Software
236236

237-
Refer to the links provided below to install these development dependencies:
237+
If you are using [nix](https://zero-to-nix.com/start/install/) & [direnv](https://direnv.net/docs/installation.html), then your dev environment will be managed automatically. Otherwise, you will need to manually install the following software:
238238

239239
- [direnv](https://direnv.net)
240240
- [git](https://git-scm.com/)
@@ -244,8 +244,9 @@ Refer to the links provided below to install these development dependencies:
244244

245245
**Setup**
246246

247+
> If you are using pyenv, you will need to install the correct versions of python using `<runtimes.txt xargs -n 1 pyenv install -s`.
248+
247249
```sh
248-
$ <runtimes.txt xargs -n 1 pyenv install -s
249250
$ direnv allow
250251
$ pip install -r requirements/dev.txt
251252
$ pre-commit install

flake.lock

Lines changed: 61 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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
4+
flake-utils.url = "github:numtide/flake-utils";
5+
};
6+
7+
outputs =
8+
{ nixpkgs, flake-utils, ... }:
9+
flake-utils.lib.eachDefaultSystem (
10+
system:
11+
let
12+
pkgs = nixpkgs.legacyPackages.${system};
13+
in
14+
{
15+
devShells.default = pkgs.mkShell {
16+
packages = [
17+
pkgs.python39
18+
pkgs.python310
19+
pkgs.python311
20+
pkgs.python312
21+
];
22+
shellHook = "unset PYTHONPATH";
23+
};
24+
}
25+
);
26+
}

requirements/dev.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1+
-r ./pre-commit.txt
12
-r ./publish.txt
3+
-r ./setuptools.txt
24
-r ./test.txt
3-
black==22.10.0
4-
flake8==5.0.4
5-
isort==5.10.1
6-
mypy==0.991
7-
pre-commit==2.20.0
85
pytest-watch==4.2.0
9-
tox==3.27.1

requirements/pre-commit.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
black==22.10.0
2+
flake8==5.0.4
3+
isort==5.10.1
4+
mypy==0.991
5+
pre-commit==2.20.0

requirements/publish.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
-r ./setuptools.txt
12
build==0.7.0
23
twine==3.8.0

requirements/setuptools.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
setuptools==75.8.0

requirements/test.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
-r ./setuptools.txt
12
pytest==7.2.0
3+
tox==3.27.1

runtimes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.9.10 3.10.1 3.11.9 3.12.3
1+
3.9 3.10 3.11 3.12

0 commit comments

Comments
 (0)