1
0
Fork 0

Convert configuration form to json

WIP: Get nix in scope
This commit is contained in:
lois Verheij 2025-03-11 14:46:11 +01:00
parent e79c974969
commit 25e16fed7a
4 changed files with 15 additions and 6 deletions

View file

@ -22,6 +22,7 @@ in
packages = [
pkgs.npins
manage
pkgs.nix
];
env = {
NPINS_DIRECTORY = toString ../npins;

View file

@ -37,6 +37,7 @@ let
django-libsass
django_4
setuptools
pkgs.nix
]
++ cfg.package.propagatedBuildInputs
);

View file

@ -2,6 +2,7 @@
lib,
sqlite,
python3,
nix,
}:
let
src =
@ -50,6 +51,7 @@ python3.pkgs.buildPythonPackage {
in
[
sqlite
nix
]
++ pythonPackages;

View file

@ -11,18 +11,23 @@ from django.views.generic.edit import FormView
from panel import models
from panel.configuration import Version
class Index(TemplateView):
template_name = 'index.html'
class AccountDetail(LoginRequiredMixin, DetailView):
model = User
template_name = 'account_detail.html'
def get_object(self):
return self.request.user
class ServiceList(TemplateView):
template_name = 'service_list.html'
class ConfigurationForm(LoginRequiredMixin, FormView):
template_name = 'configuration_form.html'
success_url = reverse_lazy('configuration_form')
@ -42,14 +47,14 @@ class ConfigurationForm(LoginRequiredMixin, FormView):
operator=self.request.user,
)
button_name = self.request.POST.get('save_draft') or self.request.POST.get('publish')
print(f"self.request.POST: {self.request.POST}")
print(f"button_name: {button_name}")
if button_name == 'deploy':
# Check for deploy button
if "deploy" in self.request.POST.keys():
print("DEPLOYING:")
print(os.getenv("REPO_DIR"))
print(obj)
subprocess.run(["nix", "develop", "--command", "nixops4", "apply", "test"], cwd=os.getenv("REPO_DIR"), env={"DEPLOYMENT": obj})
config_dict = obj.parsed_value.model_dump_json()
print(f"config_dict: {config_dict}")
subprocess.run(["nix", "develop", "--command", "nixops4", "apply",
"test"], cwd=os.getenv("REPO_DIR"), env={"DEPLOYMENT": config_dict})
return obj
# TODO(@fricklerhandwerk):