Skip to content

Commit f1e2b5b

Browse files
committed
Nix
1 parent 1c111d1 commit f1e2b5b

4 files changed

Lines changed: 72 additions & 35 deletions

File tree

‎.editorconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ trim_trailing_whitespace = true
1414
insert_final_newline = true
1515

1616
[*.md]
17-
indent_style = space
1817
indent_size = 3
1918

2019
[*.py]

‎.justfile‎

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,71 @@
1+
# Like GNU `make`, but `just` rustier.
2+
# https://just.systems/
3+
# run `just` from this directory to see available commands
4+
15
alias i := install
6+
alias p := pre_commit
7+
alias b := build
28
alias r := run
39
alias t := test
4-
alias b := build
5-
alias p := pre_commit
6-
alias c := clean
710
alias ch := check
11+
alias c := clean
12+
alias f := format
13+
alias a := add_scripts
14+
15+
# Default command when 'just' is run without arguments
16+
default:
17+
@just --list
818

919
# Install the virtual environment and pre-commit hooks
1020
install:
11-
uv sync
12-
uv run pre-commit install
21+
@echo "Installing..."
22+
@uv sync
23+
@uv run pre-commit install
1324

1425
# Run pre-commit
1526
pre_commit:
16-
uv run pre-commit run -a
27+
@echo "Running pre-commit..."
28+
@uv run pre-commit run -a
1729

18-
# Clean the project
19-
clean:
20-
# Remove cached files
21-
find . -type d -name "__pycache__" -exec rm -r {} +
22-
find . -type d -name "*.egg-info" -exec rm -r {} +
30+
# Build the project
31+
build target:
32+
@echo "Building..."
33+
@docker build -t packages/{{target}} --build-arg PACKAGE={{target}} .
2334

2435
# Run a package
2536
run *args='core':
26-
uv run {{args}}
37+
@echo "Running..."
38+
@uv run {{args}}
2739

28-
# Test the code with pytest
40+
# Test the project
2941
test:
30-
uv run python -m pytest --cov --cov-config=pyproject.toml --cov-report=xml
42+
@echo "Testing..."
43+
@uv run python -m pytest --cov --cov-config=pyproject.toml --cov-report=xml
3144

3245
# Run code quality tools
3346
check:
34-
# Check lock file consistency
35-
uv lock --locked
36-
# Run pre-commit
37-
uv run pre-commit run -a
38-
# Run mypy
39-
uv run mypy .
40-
# Run deptry with ignored issues
41-
uv run deptry . --ignore=DEP002,DEP003
47+
@echo "Checking..."
48+
@# Check lock file consistency
49+
@uv lock --locked
50+
@# Run pre-commit
51+
@uv run pre-commit run -a
52+
@# Run mypy
53+
@uv run mypy .
54+
@# Run deptry with ignored issues
55+
@uv run deptry . --ignore=DEP002,DEP003
56+
57+
# Remove build artifacts and non-essential files
58+
clean:
59+
@echo "Cleaning..."
60+
@find . -type d -name "__pycache__" -exec rm -r {} +
61+
@find . -type d -name "*.egg-info" -exec rm -r {} +
62+
63+
# Format the project
64+
format:
65+
@echo "Formatting..."
66+
@nixfmt .
4267

4368
# Add scripts
4469
add_scripts:
45-
uv add --script scripts/this.py 'typer>=0.12.5'
46-
47-
# Build dockerfile for DAG
48-
build target:
49-
docker build -t packages/{{target}} --build-arg PACKAGE={{target}} .
70+
@echo "Adding scripts..."
71+
@uv add --script scripts/this.py 'typer>=0.12.5'

‎README.md‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ A template for developing production-ready Python applications.
3030

3131
[![Python][Python-shield]][Python-url]
3232
[![Pytest][Pytest-shield]][Pytest-url]
33+
[![Nix][Nix-shield]][Nix-url]
3334
[![Codecov][Codecov-shield]][Codecov-url]
34-
[![Docker][Docker-shield]][Docker-url]
3535
[![GitHub Actions][github-actions-shield]][github-actions-url]
3636

3737
<!-- GETTING STARTED -->
@@ -40,7 +40,7 @@ A template for developing production-ready Python applications.
4040

4141
### Prerequisites
4242

43-
Before attempting to build this project, make sure you have [Python 3.10 or higher](https://www.python.org/downloads/), [just](https://just.systems/), and [uv](https://docs.astral.sh/uv/#getting-started) installed on your machine.
43+
Before attempting to build this project, make sure you have [Nix](https://nixos.org/download.html) with [Flake](https://nixos.wiki/wiki/Flakes) support installed on your machine.
4444

4545
### Installation
4646

@@ -53,10 +53,11 @@ To get a local copy of the project up and running on your machine, follow these
5353
cd modern-python
5454
```
5555

56-
2. Install the virtual environment and pre-commit hooks
56+
2. Install the project dependencies
5757

5858
```sh
59-
just install
59+
nix-shell --max-jobs $(nproc) # Linux / Windows (WSL)
60+
nix-shell --max-jobs $(sysctl -n hw.ncpu) # macOS
6061
```
6162

6263
3. Run the project
@@ -85,7 +86,7 @@ modern-python/
8586

8687
## License
8788

88-
The source code for this project is distributed under the terms of the MIT License, as I firmly believe that collaborating on free and open-source software fosters innovations that mutually and equitably beneficial to both collaborators and users alike. See [`LICENSE`](./LICENSE) for details and more information.
89+
The source code for [Kaweees/modern-python](https://github.com/Kaweees/modern-python) is distributed under the terms of the MIT License, as I firmly believe that collaborating on free and open-source software fosters innovations that mutually and equitably beneficial to both collaborators and users alike. See [`LICENSE`](./LICENSE) for details and more information.
8990

9091
<!-- MARKDOWN LINKS & IMAGES -->
9192
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
@@ -104,8 +105,8 @@ The source code for this project is distributed under the terms of the MIT Licen
104105
[Python-url]: https://www.python.org/
105106
[Pytest-shield]: https://img.shields.io/badge/pytest-%23008080.svg?style=for-the-badge&logo=pytest&logoColor=2F9FE3&labelColor=222222&color=2F9FE3
106107
[Pytest-url]: https://docs.pytest.org
107-
[Docker-shield]: https://img.shields.io/badge/docker-%232671E5.svg?style=for-the-badge&logo=docker&logoColor=1D63ED&labelColor=222222&color=1D63ED
108-
[Docker-url]: https://www.docker.com/
108+
[Nix-shield]: https://img.shields.io/badge/NIX-%23008080.svg?style=for-the-badge&logo=NixOS&logoColor=5277C3&labelColor=222222&color=5277C3
109+
[Nix-url]: https://nixos.org/
109110
[Codecov-shield]: https://img.shields.io/badge/codecov-%23008080.svg?style=for-the-badge&logo=codecov&logoColor=FF0077&labelColor=222222&color=FF0077
110111
[Codecov-url]: https://codecov.io/
111112
[github-actions-shield]: https://img.shields.io/badge/github%20actions-%232671E5.svg?style=for-the-badge&logo=githubactions&logoColor=2671E5&labelColor=222222&color=2671E5

‎shell.nix‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{ pkgs ? import <nixpkgs> { } }:
2+
3+
pkgs.mkShell {
4+
buildInputs = with pkgs; [
5+
python311 # Python 3.11
6+
uv # Python package manage
7+
just # Just
8+
nixfmt-classic # Nix formatterr
9+
];
10+
11+
# Shell hook to set up environment
12+
shellHook = ''
13+
just install
14+
'';
15+
}

0 commit comments

Comments
 (0)