Files
Alexis (Poliorcetics) Bourget 2047417be9 datamodel-code-generator: fix mainProgram
Currently running `nix run nixpkgs#datamodel-code-generator -- --help`
produces an error:

```
error: unable to execute '/nix/store/v99ll0sn384sv52fy4mhxdyqic6438hk-python3.13-datamodel-code-generator-0.71.0/bin/datamodel-code-generator': No such file or directory
```

because of:

```bash
$ nix build nixpkgs#datamodel-code-generator
$ ls -la result/bin/
.r-xr-xr-x 2.9k root  1 Jan  1970 .datamodel-codegen-wrapped
.r-xr-xr-x 1.8k root  1 Jan  1970 datamodel-codegen
```

(cherry picked from commit f35afa3df0)
2026-09-26 17:46:51 +02:00

122 lines
2.2 KiB
Nix

{
lib,
argcomplete,
black,
buildPythonPackage,
email-validator,
fetchFromGitHub,
genson,
graphql-core,
grpcio-tools,
hatch-vcs,
hatchling,
httpx,
hypothesis,
hypothesis-jsonschema,
inflect,
inline-snapshot,
isort,
jsonschema,
msgspec,
jinja2,
openapi-spec-validator,
packaging,
prance,
ruff,
pydantic,
pysnooper,
pytest-mock,
pytest-timeout,
pytest-xdist,
pytestCheckHook,
pyyaml,
time-machine,
watchfiles,
}:
buildPythonPackage rec {
pname = "datamodel-code-generator";
version = "0.71.0";
pyproject = true;
src = fetchFromGitHub {
owner = "koxudaxi";
repo = "datamodel-code-generator";
tag = version;
hash = "sha256-0vh/iynZzmMzvdUXNScb+JWANdSrzPLT1qt+jyKleg4=";
};
pythonRelaxDeps = [
"inflect"
"isort"
];
build-system = [
hatchling
hatch-vcs
];
dependencies = [
argcomplete
black
genson
inflect
isort
jinja2
packaging
pydantic
pyyaml
];
optional-dependencies = {
all = lib.concatAttrValues (lib.removeAttrs optional-dependencies [ "all" ]);
debug = [ pysnooper ];
graphql = [ graphql-core ];
http = [ httpx ];
protobuf = [ grpcio-tools ];
ruff = [ ruff ];
validation = [
openapi-spec-validator
prance
];
watch = [
watchfiles
];
};
nativeCheckInputs = [
email-validator
inline-snapshot
hypothesis
hypothesis-jsonschema
jsonschema
msgspec
pytest-mock
pytest-timeout
pytest-xdist
pytestCheckHook
time-machine
]
++ optional-dependencies.all;
pytestFlags = [
"--maxfail=2"
];
disabledTests = [
# remote testing, name resolution failure.
"test_openapi_parser_parse_remote_ref"
];
pythonImportsCheck = [ "datamodel_code_generator" ];
meta = {
description = "Pydantic model and dataclasses.dataclass generator for easy conversion of JSON, OpenAPI, JSON Schema, and YAML data sources";
homepage = "https://github.com/koxudaxi/datamodel-code-generator";
changelog = "https://github.com/koxudaxi/datamodel-code-generator/releases/tag/${src.tag}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ tochiaha ];
mainProgram = "datamodel-codegen";
};
}