Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a nix environment to ensure a reproducible build #43

Merged
merged 5 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .envrc

This file was deleted.

2 changes: 2 additions & 0 deletions .envrc.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
watch_file pyproject.toml
use flake
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.envrc

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
11 changes: 1 addition & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ci:
skip: [pytest]
autoupdate_schedule: monthly
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
repos:
Expand Down Expand Up @@ -42,12 +41,4 @@ repos:
hooks:
- id: mypy
exclude: tests
- repo: local
hooks:
- id: pytest
name: pytest
entry: pytest
language: python
pass_filenames: false
always_run: true
fail_fast: true
fail_fast: false
152 changes: 152 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
description = "A very basic flake";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";

pyproject-nix = {
url = "github:nix-community/pyproject.nix";
inputs.nixpkgs.follows = "nixpkgs";
};

flake-utils.url = "github:numtide/flake-utils";
};

outputs =
{
self,
nixpkgs,
pyproject-nix,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };

project = pyproject-nix.lib.project.loadPyproject { projectRoot = ./.; };
python = pkgs.python312;
in
{
devShells.default =
let
attrs = project.renderers.withPackages {
inherit python;
extras = [ "tests" ];
extraPackages = python-pkgs: [ python-pkgs.ipykernel ];
};
pythonEnv = python.withPackages attrs;
in
pkgs.mkShell {
packages =
[ pythonEnv ]
++ (with pkgs; [
ruff
pre-commit
rustc # for pre-commit ruff
cargo # for pre-commit ruff
]);
shellHook = ''
export PYTHONPATH="$(pwd)/src"
export PIP_NO_BINARY="ruff"
'';
};
}
);
}