Skip to content

Commit

Permalink
Merge pull request #43 from cgahr/nix
Browse files Browse the repository at this point in the history
add a nix environment to ensure a reproducible build
  • Loading branch information
cgahr authored Sep 12, 2024
2 parents 55338a4 + b1f6893 commit b11a600
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 11 deletions.
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"
'';
};
}
);
}

0 comments on commit b11a600

Please sign in to comment.