forked from Fediversity/Fediversity
pass in description fix syntax configure proxmox provider typo add doc comment in existing modules add comment allow insecure proxmox connection for use in dev wip proxmox progress use service configurations moved to machine-independent location wire settings directly without option block terraform adjust cwd try tf on null input update .envrc.sample with sample proxmox credentials
104 lines
2.5 KiB
Nix
104 lines
2.5 KiB
Nix
{
|
|
lib,
|
|
pkgs,
|
|
sqlite,
|
|
python3,
|
|
python3Packages,
|
|
callPackage,
|
|
runCommand,
|
|
sources ? import ../../npins,
|
|
}:
|
|
let
|
|
src =
|
|
with lib.fileset;
|
|
toSource {
|
|
root = ../src;
|
|
fileset = intersection (gitTracked ../../.) ../src;
|
|
};
|
|
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
|
|
version = "0.0.0";
|
|
pyproject-toml = ''
|
|
[project]
|
|
name = "Fediversity-Panel"
|
|
version = "${version}"
|
|
|
|
[tool.setuptools]
|
|
packages = [ "${name}" ]
|
|
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";
|
|
}
|
|
];
|
|
in
|
|
python3.pkgs.buildPythonPackage {
|
|
pname = name;
|
|
inherit (pyproject.project) version;
|
|
pyproject = true;
|
|
inherit src;
|
|
|
|
preBuild = ''
|
|
echo "recursive-include ${name} *" > MANIFEST.in
|
|
cp ${builtins.toFile "source" pyproject-toml} pyproject.toml
|
|
'';
|
|
|
|
propagatedBuildInputs =
|
|
let
|
|
pythonPackages = with python3.pkgs; [
|
|
dj-database-url
|
|
django-compressor
|
|
django-debug-toolbar
|
|
django-libsass
|
|
django-pydantic-field
|
|
drf-pydantic
|
|
django_4
|
|
setuptools
|
|
];
|
|
in
|
|
[
|
|
sqlite
|
|
]
|
|
++ pythonPackages;
|
|
|
|
passthru = {
|
|
inherit generated;
|
|
};
|
|
|
|
postInstall = ''
|
|
mkdir -p $out/bin
|
|
cp -v ${src}/manage.py $out/bin/manage.py
|
|
chmod +x $out/bin/manage.py
|
|
wrapProgram $out/bin/manage.py \
|
|
--set REPO_DIR "${
|
|
import ../../infra/tf-env.nix {
|
|
inherit lib pkgs;
|
|
}
|
|
}" \
|
|
--prefix PYTHONPATH : "$PYTHONPATH"
|
|
${lib.concatStringsSep "\n" (
|
|
map (file: "cp ${file.from} $out/${python3.sitePackages}/${file.to}") generated
|
|
)}
|
|
'';
|
|
}
|