Skip to content

Commit

Permalink
feat: Add Nix support
Browse files Browse the repository at this point in the history
  • Loading branch information
l0b0 committed Sep 23, 2024
1 parent 77c1e1b commit ec1d3ae
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 8 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
- uses: cachix/install-nix-action@8887e596b4ee1134dae06b98d573bd674693f47c # v26
- uses: cachix/cachix-action@18cf96c7c98e048e10a83abd92116114cd8504be # v14
with:
python-version: "3.12.3"
- name: Install
run: |
pip install poetry
poetry install --no-root
name: linz
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Lint & format
run: |
poetry run pre-commit run --all-files
nix-shell --pure --run 'pre-commit run --all-files'
- name: Test
run: |
poetry run pytest
nix-shell --pure --run pytest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
*.pyc
__pycache__
/.pytest_cache/
/python
Thumbs.db
/.vscode/
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,41 @@ 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
language: system
stages: [commit]
types: [python]

- id: nixfmt
name: nixfmt
entry: nixfmt
files: \.nix$
language: system
stages: [commit]

- id: pylint
name: pylint
entry: pylint
language: system
stages: [commit]
types: [python]
require_serial: true

- id: statix
name: statix
entry: statix
args: [check]
files: \.nix$
pass_filenames: false
language: system
stages: [commit]
33 changes: 33 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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.gitFull
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
'';
}

0 comments on commit ec1d3ae

Please sign in to comment.