forked from fediversity/fediversity
Compare commits
15 commits
3e2c83435d
...
f50ee049f2
| Author | SHA1 | Date | |
|---|---|---|---|
| f50ee049f2 | |||
| e872b3fde0 | |||
| 42a0a798e7 | |||
| 98b3947a8e | |||
| 7c5259181f | |||
| 782bbc4d8e | |||
| 2a8ae9d320 | |||
| 5355e57378 | |||
| 76ff180ca7 | |||
| ae08673c1b | |||
| e86712beec | |||
| cc5101063b | |||
| 6bc3016585 | |||
| fcbbce0405 | |||
| 1411136f75 |
7 changed files with 70 additions and 6 deletions
|
|
@ -58,7 +58,10 @@
|
|||
packages = [
|
||||
pkgs.nil
|
||||
inputs'.agenix.packages.default
|
||||
inputs'.nixops4.packages.default
|
||||
(inputs'.nixops4.packages.default.overrideAttrs {
|
||||
impureEnvVars = [ "DEPLOYMENT" ];
|
||||
})
|
||||
pkgs.openssh
|
||||
pkgs.httpie
|
||||
pkgs.jq
|
||||
];
|
||||
|
|
|
|||
|
|
@ -143,7 +143,17 @@ in
|
|||
## - We add a “test” deployment with all test machines.
|
||||
nixops4Deployments = genAttrs machines makeDeployment' // {
|
||||
default = makeDeployment machines;
|
||||
test = makeTestDeployment (fromJSON (readFile ./test-machines/configuration.json));
|
||||
test = makeTestDeployment (
|
||||
fromJSON (
|
||||
let
|
||||
env = builtins.getEnv "DEPLOYMENT";
|
||||
in
|
||||
if env != "" then
|
||||
env
|
||||
else
|
||||
builtins.trace "env var DEPLOYMENT not set, falling back to ./test-machines/configuration.json!" (readFile ./test-machines/configuration.json)
|
||||
)
|
||||
);
|
||||
};
|
||||
flake.nixosConfigurations =
|
||||
genAttrs machines (makeConfiguration false)
|
||||
|
|
|
|||
|
|
@ -1,17 +1,25 @@
|
|||
{
|
||||
inputs,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
name = "panel";
|
||||
panel = (import ../../../panel/default.nix { }).package;
|
||||
in
|
||||
# builtins.trace args.pkgs
|
||||
{
|
||||
imports = [
|
||||
../../../panel/nix/configuration.nix
|
||||
];
|
||||
|
||||
nix.settings = {
|
||||
extra-experimental-features = "configurable-impure-env";
|
||||
};
|
||||
|
||||
environment.systemPackages = [
|
||||
inputs.self.outPath
|
||||
panel
|
||||
];
|
||||
|
||||
|
|
@ -36,4 +44,8 @@ in
|
|||
STATIC_ROOT = "/var/lib/${name}/static";
|
||||
};
|
||||
};
|
||||
systemd.services.${name}.environment = {
|
||||
REPO_DIR = inputs.self.outPath;
|
||||
NIX_DIR = pkgs.nix;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ in
|
|||
export CREDENTIALS_DIRECTORY=${builtins.toString ./.credentials}
|
||||
export DATABASE_URL="sqlite:///${toString ./src}/db.sqlite3"
|
||||
'';
|
||||
NIX_DIR = pkgs.nix;
|
||||
};
|
||||
|
||||
tests = pkgs'.callPackage ./nix/tests.nix { };
|
||||
|
|
|
|||
|
|
@ -39,11 +39,11 @@ class Configuration(BaseModel):
|
|||
# XXX: hard-code available apex domains for now,
|
||||
# they will be prefixed by the user name
|
||||
class Domain(Enum):
|
||||
EU = "fediversity.eu"
|
||||
# EU = "fediversity.eu"
|
||||
NET = "fediversity.net"
|
||||
|
||||
domain: Domain = Field(
|
||||
default=Domain.EU,
|
||||
default=Domain.NET,
|
||||
description="DNS domain where to expose services"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
{{ form.as_p }}
|
||||
|
||||
<button class="button" disabled>Deploy</button>
|
||||
<button class="button" type="submit" >Save</button>
|
||||
<button class="button" type="submit" name="deploy">Deploy</button>
|
||||
<button class="button" type="submit" name="save">Save</button>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
from enum import Enum
|
||||
import os
|
||||
import json
|
||||
|
||||
from django.urls import reverse_lazy
|
||||
import os
|
||||
import subprocess
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.auth.models import User
|
||||
from django.views.generic import TemplateView, DetailView
|
||||
|
|
@ -10,6 +14,7 @@ from panel import models
|
|||
from panel.configuration import forms
|
||||
|
||||
|
||||
|
||||
class Index(TemplateView):
|
||||
template_name = 'index.html'
|
||||
|
||||
|
|
@ -41,6 +46,39 @@ class ConfigurationForm(LoginRequiredMixin, FormView):
|
|||
operator=self.request.user,
|
||||
)
|
||||
|
||||
# Check for deploy button
|
||||
if "deploy" in self.request.POST.keys():
|
||||
print("DEPLOYING:")
|
||||
print(os.getenv("REPO_DIR"))
|
||||
print(os.getenv("NIX_DIR"))
|
||||
submission = obj.parsed_value.model_dump_json()
|
||||
deployment = json.dumps(json.loads(submission) | {
|
||||
"initialUser": {
|
||||
"displayName": "Testy McTestface",
|
||||
"username": "test",
|
||||
"password": "testtest",
|
||||
"email": "test@test.com",
|
||||
},
|
||||
})
|
||||
env = {
|
||||
"DEPLOYMENT": deployment,
|
||||
"PATH": f"{os.getenv("NIX_DIR")}/bin/",
|
||||
}
|
||||
print(f"env: {env}")
|
||||
print(f"Path: {os.getcwd()}/..")
|
||||
cmd = [
|
||||
"nix",
|
||||
"develop",
|
||||
"--extra-experimental-features",
|
||||
"configurable-impure-env",
|
||||
"--command",
|
||||
"nixops4",
|
||||
"--show-trace",
|
||||
"--verbose",
|
||||
"apply",
|
||||
"test",
|
||||
]
|
||||
subprocess.run(cmd, cwd=os.getenv("REPO_DIR") or f"{os.getcwd()}/..", env=env)
|
||||
return obj
|
||||
|
||||
# TODO(@fricklerhandwerk):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue