forked from Fediversity/Fediversity
FediPanel: allow configuring flake and deployment
This commit is contained in:
parent
ace56e754e
commit
1fafec482e
5 changed files with 29 additions and 16 deletions
|
@ -26,7 +26,9 @@ in
|
|||
pkgs.nix
|
||||
pkgs.openssh
|
||||
];
|
||||
env = import ./env.nix { } // {
|
||||
env = {
|
||||
DEPLOYMENT_FLAKE = ../.;
|
||||
DEPLOYMENT_NAME = "test";
|
||||
NPINS_DIRECTORY = toString ../npins;
|
||||
CREDENTIALS_DIRECTORY = toString ./.credentials;
|
||||
DATABASE_URL = "sqlite:///${toString ./src}/db.sqlite3";
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (builtins) toString;
|
||||
in
|
||||
{
|
||||
REPO_DIR = toString ../.;
|
||||
}
|
|
@ -23,7 +23,9 @@ let
|
|||
cfg = config.services.${name};
|
||||
package = pkgs.callPackage ./package.nix { };
|
||||
|
||||
environment = import ../env.nix { } // {
|
||||
environment = {
|
||||
DEPLOYMENT_FLAKE = cfg.deployment.flake;
|
||||
DEPLOYMENT_NAME = cfg.deployment.name;
|
||||
DATABASE_URL = "sqlite:////var/lib/${name}/db.sqlite3";
|
||||
USER_SETTINGS_FILE = pkgs.concatText "configuration.py" [
|
||||
((pkgs.formats.pythonVars { }).generate "settings.py" cfg.settings)
|
||||
|
@ -144,6 +146,23 @@ in
|
|||
this workaround.
|
||||
'';
|
||||
};
|
||||
|
||||
deployment = {
|
||||
flake = mkOption {
|
||||
type = types.path;
|
||||
default = ../..;
|
||||
description = ''
|
||||
The path to the flake containing the deployment. This is used to run the deployment button.
|
||||
'';
|
||||
};
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
default = "test";
|
||||
description = ''
|
||||
The name of the deployment within the flake.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
|
|
@ -240,6 +240,7 @@ if user_settings_file is not None:
|
|||
# The correct thing to do here would be using a helper function such as with `get_secret()` that will catch the exception and explain what's wrong and where to put the right values.
|
||||
# Replacing the `USER_SETTINGS_FILE` mechanism following the comment there would probably be a good thing.
|
||||
|
||||
# path of the root flake to trigger nixops from, see #94.
|
||||
# to deploy this should be specified, for dev just use a relative path.
|
||||
repo_dir = env["REPO_DIR"]
|
||||
# Path of the root flake to trigger nixops from, see #94, and name of the
|
||||
# deployment.
|
||||
deployment_flake = env["DEPLOYMENT_FLAKE"]
|
||||
deployment_name = env["DEPLOYMENT_NAME"]
|
||||
|
|
|
@ -96,13 +96,13 @@ class DeploymentStatus(ConfigurationForm):
|
|||
cmd = [
|
||||
"nixops4",
|
||||
"apply",
|
||||
"test",
|
||||
settings.deployment_name,
|
||||
"--show-trace",
|
||||
"--no-interactive",
|
||||
]
|
||||
deployment_result = subprocess.run(
|
||||
cmd,
|
||||
cwd = settings.repo_dir,
|
||||
cwd = settings.deployment_flake,
|
||||
env = env,
|
||||
stderr = subprocess.STDOUT,
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue