From 0c943a7ea978ce9bbc0c68e7dc94c06ae0d7ec2e Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Thu, 21 Mar 2024 13:16:34 +1300 Subject: [PATCH] feat: Add Nix support --- .gitignore | 1 + .pre-commit-config.yaml | 24 ++++++++++++++++++++++++ shell.nix | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 shell.nix diff --git a/.gitignore b/.gitignore index de40c11..471b7dd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ *.pyc __pycache__ /.pytest_cache/ +/python Thumbs.db /.vscode/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 965adaf..1dbaed9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,6 +11,14 @@ repos: stages: [commit] types: [python] + - id: deadnix + name: deadnix + entry: deadnix + args: [--edit, --fail] + files: \.nix$ + language: system + stages: [commit] + - id: isort name: isort entry: isort @@ -18,6 +26,13 @@ repos: stages: [commit] types: [python] + - id: nixfmt + name: nixfmt + entry: nixfmt + files: \.nix$ + language: system + stages: [commit] + - id: pylint name: pylint entry: pylint @@ -25,3 +40,12 @@ repos: stages: [commit] types: [python] require_serial: true + + - id: statix + name: statix + entry: statix + args: [check] + files: \.nix$ + pass_filenames: false + language: system + stages: [commit] diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..91bd87e --- /dev/null +++ b/shell.nix @@ -0,0 +1,32 @@ +let + pkgs = import (builtins.fetchTarball { + name = "nixos-unstable-2024-09-17"; + url = "https://github.com/nixos/nixpkgs/archive/345c263f2f53a3710abe117f28a5cb86d0ba4059.tar.gz"; + sha256 = "1llzyzw7a0jqdn7p3px0sqa35jg24v5pklwxdybwbmbyr2q8cf5j"; + }) { overlays = [ (_final: prev: { geos = prev.geos_3_11; }) ]; }; + poetry2nix = import (builtins.fetchTarball { + url = "https://github.com/nix-community/poetry2nix/archive/2024.9.1542864.tar.gz"; + sha256 = "06vz5hwylvjvx4ywbv4y3kadq8zxmvpf5h7pjy6w1yhkwpjd6k25"; + }) { inherit pkgs; }; + poetryPackages = poetry2nix.mkPoetryPackages { + projectDir = builtins.path { + path = ./.; + name = "python-linz-logger"; + }; + }; +in +pkgs.mkShell { + packages = [ + pkgs.bashInteractive + pkgs.poetry + pkgs.deadnix + pkgs.nixfmt-rfc-style + pkgs.statix + poetryPackages.poetryPackages + poetryPackages.python.pkgs.pip # For IDEA package resolution + poetryPackages.python.pkgs.setuptools # For IDEA package resolution + ]; + shellHook = '' + ln --force --no-target-directory --symbolic "${poetryPackages.python}/bin/python" python + ''; +}