Compare commits

..

13 commits

Author SHA1 Message Date
2ed7f3ebe5
get TF in prod to the same 'installable ... does not correspond to a Nix language value' for non-flakes
seemingly gets further when a similar command is tried from terminal.
as per https://github.com/NixOS/nix/issues/8752#issuecomment-1694714693,
this may have to do with aligning the current working directory.
2025-03-28 21:08:55 +01:00
66c0425e1c
document updating TF module 2025-03-27 16:18:10 +01:00
7e35b1244e
update 2025-03-27 16:18:10 +01:00
ed5853f432
specify XDG_CACHE_HOME, workaround to error writing to /var/empty/.cache 2025-03-27 16:18:10 +01:00
35279d7305
skip tf lock in views.py over read-only nix env 2025-03-27 16:18:09 +01:00
b7833fdb03
move tf init out of python over read-only nix env 2025-03-27 16:18:09 +01:00
d428faa9a3
properly pass repo dir for prod, be it with hard-coded TF init 2025-03-27 16:18:09 +01:00
232c0e8963
use flake-sourced nixos-anywhere in tf, to reproduce modules for nix 2025-03-27 16:18:09 +01:00
3d3804a6ad
switch launch shell to root flake's nixpkgs, see #279 2025-03-27 16:18:09 +01:00
cbd869a6f2
Revert "deduplicate flake inputs"
This reverts commit 95769084ce.
2025-03-27 16:18:09 +01:00
6ef68f3681
make re-exports explicit again 2025-03-27 16:18:09 +01:00
6189ae28fa
deduplicate flake inputs 2025-03-27 16:18:09 +01:00
a6ad9533bb
tf 2025-03-27 16:18:09 +01:00
3 changed files with 13 additions and 44 deletions

View file

@ -9,8 +9,7 @@
hx-trigger="click"
hx-indicator="#spinner-container"
hx-disabled-elt="this"
hx-target="#deployment-result"
hx-swap="innerHTML"
hx-swap="none"
name="deploy">
Deploy
</button>
@ -20,8 +19,5 @@
<div id="spinner-container" class="htmx-indicator">
<span class="loader"></span>
</div>
<div id="deployment-result">
</div>
</form>
{% endblock %}

View file

@ -1,13 +0,0 @@
{% if deployment_status %}
<p>{{ deployment_status }}</p>
<ul>
{% for service, state in services.items %}
{% if state %}
<li>
✓ {{ service }}
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}

View file

@ -10,11 +10,10 @@ from django.contrib.auth.models import User
from django.views.generic import TemplateView, DetailView
from django.views.generic.edit import FormView
from django.shortcuts import render
from panel import models, settings
from panel import models
from panel.configuration import forms
class Index(TemplateView):
template_name = 'index.html'
@ -84,7 +83,6 @@ class ConfigurationForm(LoginRequiredMixin, FormView):
initial.update(self.convert_enums_to_names(config_dict))
return initial
class Save(ConfigurationForm):
def form_valid(self, form):
obj = self.get_object()
@ -93,7 +91,6 @@ class Save(ConfigurationForm):
return super().form_valid(form)
class DeploymentStatus(ConfigurationForm):
def form_valid(self, form):
obj = self.get_object()
@ -102,34 +99,23 @@ class DeploymentStatus(ConfigurationForm):
# Check for deploy button
if "deploy" in self.request.POST.keys():
deployment_result, deployment_params = self.deployment(obj)
if deployment_result.returncode == 0:
deployment_status = "Deployment Succeeded"
else:
deployment_status = "Deployment Failed"
self.deployment(obj)
return render(self.request, "partials/deployment_result.html", {
"deployment_status": deployment_status,
"services": {
"peertube": deployment_params['peertube']['enable'],
"pixelfed": deployment_params['pixelfed']['enable'],
"mastodon": deployment_params['mastodon']['enable']
}
})
return super().form_valid(form)
def deployment(self, obj):
submission = obj.parsed_value.model_dump_json()
# FIXME: let the user specify these from the form (#190)
dummy_user = {
"initialUser": {
"displayName": "Testy McTestface",
"username": "test",
"password": "testtest",
"email": "test@test.com",
},
"initialUser": {
"displayName": "Testy McTestface",
"username": "test",
"password": "testtest",
"email": "test@test.com",
},
}
# serialize back and forth now we still need to manually inject the dummy user
deployment_params = dummy_user | json.loads(submission)
deployment = dummy_user | json.loads(submission)
env = {
"PATH": settings.bin_path,
# used in nixos-anywhere for ssh-copy-id
@ -138,7 +124,7 @@ class DeploymentStatus(ConfigurationForm):
} | {
# pass in form info to our deployment
# FIXME: ensure sensitive info is protected
f"TF_VAR_{k}": v if isinstance(v, str) else json.dumps(v) for k, v in deployment_params.items()
f"TF_VAR_{k}": v if isinstance(v, str) else json.dumps(v) for k, v in deployment.items()
}
cwd = f"{settings.repo_dir}/launch"
# FIXME: move init to packaging phase
@ -152,4 +138,4 @@ class DeploymentStatus(ConfigurationForm):
]
deployment_result = subprocess.run(cmd, cwd=cwd, env=env)
print(deployment_result)
return deployment_result, deployment_params
return deployment_result