Files
zugferd-service/flake.nix

121 lines
2.9 KiB
Nix

{
description = "ZUGFeRD REST API Service";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
m3ta-nixpkgs.url = "git+https://code.m3ta.dev/m3tam3re/nixpkgs";
agents = {
url = "git+https://code.m3ta.dev/m3tam3re/AGENTS";
flake = false;
};
};
outputs = {
self,
nixpkgs,
flake-utils,
m3ta-nixpkgs,
agents,
} @ inputs:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
pythonPackages = pkgs.python311Packages;
# factur-x package - not available in nixpkgs, so we package it inline
factur-x = pythonPackages.buildPythonPackage rec {
pname = "factur_x";
version = "3.8";
format = "pyproject";
src = pythonPackages.fetchPypi {
inherit pname version;
hash = "sha256-/pNY5w09pxcGAFFh3USTkLlkGr+JOTUqhglYzNMByks=";
};
nativeBuildInputs = with pythonPackages; [
hatchling
hatch-requirements-txt
];
dependencies = with pythonPackages; [pypdf lxml];
pythonRelaxDeps = true;
meta = {
description = "Python library to generate and read Factur-X invoices";
license = pkgs.lib.licenses.mit;
};
};
zugferd-service = pythonPackages.buildPythonApplication {
pname = "zugferd-service";
version = "1.0.0";
pyproject = true;
src = ./.;
pythonRelaxDeps = true;
build-system = [pythonPackages.hatchling];
dependencies = with pythonPackages; [
fastapi
uvicorn
pydantic
python-multipart
factur-x
pypdf
lxml
];
nativeCheckInputs = with pythonPackages; [
pytestCheckHook
pytest-asyncio
httpx
];
passthru = {mainProgram = "zugferd-service";};
meta = {
description = "REST API for ZUGFeRD invoice extraction";
license = pkgs.lib.licenses.mit;
};
};
m3taLib = m3ta-nixpkgs.lib.x86_64-linux;
rules = m3taLib.opencode-rules.mkOpencodeRules {
inherit agents;
languages = ["python"];
};
in {
packages.default = zugferd-service;
packages.zugferd-service = zugferd-service;
devShells.default = pkgs.mkShell {
packages = [
(pkgs.python311.withPackages (ps:
with ps; [
fastapi
uvicorn
pydantic
python-multipart
pypdf
lxml
pytest
pytest-asyncio
httpx
factur-x
# factur-x - install via pip if not available
]))
pkgs.python311Packages.pip
];
inherit (rules) instructions;
shellHook = ''
${rules.shellHook}
'';
};
});
}