diff --git a/panel/.gitignore b/panel/.gitignore index bcdd5369..6d302370 100644 --- a/panel/.gitignore +++ b/panel/.gitignore @@ -11,5 +11,5 @@ db.sqlite3 src/db.sqlite3 src/static src/panel/static/htmx* -src/panel/configuration/schema.py +src/panel/configuration/schema.* .credentials diff --git a/panel/nix/package.nix b/panel/nix/package.nix index e13e015a..42440261 100644 --- a/panel/nix/package.nix +++ b/panel/nix/package.nix @@ -14,7 +14,7 @@ let root = ../src; fileset = intersection (gitTracked ../../.) ../src; }; - pyproject = with lib; fromTOML pyproject-toml; + pyproject = fromTOML pyproject-toml; # TODO: define this globally name = "panel"; # TODO: we may want this in a file so it's easier to read statically @@ -29,28 +29,35 @@ let include-package-data = true ''; - generated = [ - { - from = "${sources.htmx}/dist/htmx.min.js"; - to = "./panel/static/htmx.min.js"; - } - { - from = - let - jsonschema = callPackage "${sources.clan-core}/lib/jsonschema" { } { }; - frontend-options = jsonschema.parseModule ../../deployment/options.nix; - schema = with builtins; toFile "schema.json" (toJSON frontend-options); - codegen = "${python3Packages.datamodel-code-generator}/bin/datamodel-codegen"; - pydantic = runCommand "schema.py" { } '' - # replace plain `pydantic` with `drf_pydantic` so we can create forms automatically - ${codegen} --input ${schema} | sed '/from pydantic/a\ - from drf_pydantic import BaseModel' > $out - ''; - in - "${pydantic}"; - to = "./panel/configuration/schema.py"; - } - ]; + generated = + let + jsonschema = callPackage "${sources.clan-core}/lib/jsonschema" { } { }; + frontend-options = jsonschema.parseModule ../../deployment/options.nix; + schema = with builtins; toFile "schema.json" (toJSON frontend-options); + in + [ + { + from = "${sources.htmx}/dist/htmx.min.js"; + to = "./panel/static/htmx.min.js"; + } + { + from = schema; + to = "./panel/configuration/schema.json"; + } + { + from = + let + codegen = "${python3Packages.datamodel-code-generator}/bin/datamodel-codegen"; + pydantic = runCommand "schema.py" { } '' + # replace plain `pydantic` with `drf_pydantic` so we can create forms automatically + ${codegen} --input ${schema} | sed '/from pydantic/a\ + from drf_pydantic import BaseModel' > $out + ''; + in + "${pydantic}"; + to = "./panel/configuration/schema.py"; + } + ]; in python3.pkgs.buildPythonPackage { pname = name;