Files
zugferd-service/flake.nix
T
m3ta-chironandClaude Fable 5.2 630dd696da build(nix): package factur-x 6.8 and add beads to the dev shell
The flake still built factur-x 3.8 while uv.lock and CI use 6.8; the
versions differ in behavior (e.g. XRechnung profile detection). The
flake now builds 6.8 with its new build and runtime dependencies.

The dev shell also provides bd (beads). The pinned nixpkgs only ships
bd 0.42, which cannot read the .beads database, so bd comes from a
separate, newer nixpkgs input.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-11 18:33:40 +01:00

134 lines
3.5 KiB
Nix

{
description = "ZUGFeRD REST API Service";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
# Newer nixpkgs only for the beads issue tracker (bd >= 1.0): the pinned
# nixpkgs ships bd 0.42, which cannot read the .beads database.
# Drop this input once nixpkgs itself is updated.
nixpkgs-beads.url = "github:NixOS/nixpkgs/nixos-unstable";
m3ta-nixpkgs.url = "git+https://code.m3ta.dev/m3tam3re/nixpkgs";
agents = {
url = "git+https://code.m3ta.dev/m3tam3re/AGENTS";
flake = false;
};
};
outputs = {
self,
nixpkgs,
nixpkgs-beads,
flake-utils,
m3ta-nixpkgs,
agents,
}:
{
nixosModules.default = import ./nix/module.nix;
}
// 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";
# Keep in sync with uv.lock (CI and Docker install from the lockfile)
version = "6.8";
format = "pyproject";
src = pythonPackages.fetchPypi {
inherit pname version;
hash = "sha256-0AcenHIXZm6tAl9EJ2Xh4u9KC6jiZ3urZAQn6wi7s0k=";
};
nativeBuildInputs = with pythonPackages; [
hatchling
hatch-requirements-txt
hatch-vcs
];
dependencies = with pythonPackages; [pypdf lxml python-stdnum requests];
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
# Issue tracker (bd); issues live in .beads/
nixpkgs-beads.legacyPackages.${system}.beads
];
inherit (rules) instructions;
shellHook = ''
${rules.shellHook}
'';
};
});
}