diff --git a/.gitignore b/.gitignore index b6b850f2c..de944d44d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,8 @@ pyvenv.cfg /.venv* /venv* /.env/ +/.direnv/ +.envrc # sensitive environment variables .env diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..6f5f869b2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1676721149, + "narHash": "sha256-mN2EpTGxxVNnFZLoLWRwh6f7UWhXy4qE+wO2CZyrXps=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "5f4e07deb7c44f27d498f8df9c5f34750acf52d2", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..503f9ceb9 --- /dev/null +++ b/flake.nix @@ -0,0 +1,52 @@ +{ + inputs = { + nixpkgs = { + url = "github:nixos/nixpkgs/nixos-unstable"; + }; + flake-utils = { + url = "github:numtide/flake-utils"; + }; + }; + outputs = { nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + }; + python = pkgs.python310; + lib-path = with pkgs; lib.makeLibraryPath [ + stdenv.cc.cc + ]; + + + in + rec { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ + python + pre-commit + (python3.withPackages (ps: with ps; [ + virtualenvwrapper + ])) + ]; + shellHook = '' + # Augment the dynamic linker path + export "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${lib-path}" + + # Setup the virtual environment if it doesn't already exist. + VENV=.venv + if test ! -d $VENV; then + virtualenv $VENV + # Install Python dependencies + pip install -r requirements_dev.txt + pip install -e . + fi + source ./$VENV/bin/activate + export PYTHONPATH=`pwd`/$VENV/${python.sitePackages}/:$PYTHONPATH + + pre-commit install + ''; + + }; + } + ); +} diff --git a/pyproject.toml b/pyproject.toml index 2504650ab..b5eba90ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -77,6 +77,8 @@ ignore = [ ".sourcery.yaml", ".zenodo.json", "codecov.yml", + "flake.nix", + "flake.lock", "readthedocs.yml", "requirements_dev.txt", "tox.ini",