diff --git a/infra/machines/fedi201/fedipanel.nix b/infra/machines/fedi201/fedipanel.nix index 85696b9d..99e02a0e 100644 --- a/infra/machines/fedi201/fedipanel.nix +++ b/infra/machines/fedi201/fedipanel.nix @@ -1,6 +1,7 @@ { self, config, + pkgs, ... }: let @@ -44,5 +45,6 @@ in }; systemd.services.${name}.env = { REPO_DIR = builtins.trace self self; + NIX_DIR = pkgs.nix; }; } diff --git a/panel/default.nix b/panel/default.nix index 0246337f..b47473bb 100644 --- a/panel/default.nix +++ b/panel/default.nix @@ -37,6 +37,7 @@ in ''; # FIXME: ending a path in a non-name produces a double hash :( REPO_DIR = ./..; + NIX_DIR = pkgs.nix; }; tests = pkgs'.callPackage ./nix/tests.nix { }; diff --git a/panel/src/panel/views.py b/panel/src/panel/views.py index 6629ade2..82c0f380 100644 --- a/panel/src/panel/views.py +++ b/panel/src/panel/views.py @@ -12,23 +12,18 @@ from panel import models from panel.configuration import forms - 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') @@ -48,10 +43,13 @@ class ConfigurationForm(LoginRequiredMixin, FormView): if "deploy" in self.request.POST.keys(): print("DEPLOYING:") print(os.getenv("REPO_DIR")) - 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}) + print(os.getenv("NIX_DIR")) + env={ + "DEPLOYMENT": obj.parsed_value.model_dump_json(), + "PATH": f"{os.getenv("NIX_DIR")}/bin/", + } + print(f"env: {env}") + subprocess.run(["nix", "develop", "--command", "nixops4", "--show-trace", "--verbose", "apply", "test"], cwd=os.getenv("REPO_DIR"), env=env) return obj # TODO(@fricklerhandwerk):