forked from Fediversity/Fediversity
generate-module-options-rebase #1
3 changed files with 164 additions and 139 deletions
|
@ -31,18 +31,40 @@
|
||||||
|
|
||||||
## Information on the specific deployment that we request.
|
## Information on the specific deployment that we request.
|
||||||
## This is the information coming from the FediPanel.
|
## This is the information coming from the FediPanel.
|
||||||
config:
|
deployment-configuration:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib) mkIf;
|
inherit (lib) mkIf;
|
||||||
# TODO(@fricklerhandwerk): misusing this will produce obscure errors that will be truncated by NixOps4
|
|
||||||
panelConfig = (lib.evalModules { modules = [ ./options.nix ]; }).config;
|
|
||||||
in
|
in
|
||||||
|
|
||||||
## Regular arguments of a NixOps4 deployment module.
|
## Regular arguments of a NixOps4 deployment module.
|
||||||
{ providers, ... }:
|
{ config, providers, ... }:
|
||||||
|
let
|
||||||
|
panelConfig = config.deployment;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
|
options = {
|
||||||
|
deployment = lib.mkOption {
|
||||||
|
description = ''
|
||||||
|
Configuration to be deployed
|
||||||
|
'';
|
||||||
|
# XXX(@fricklerhandwerk):
|
||||||
|
# misusing this will produce obscure errors that will be truncated by NixOps4
|
||||||
|
type = lib.types.submodule ./options.nix;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
deployment = deployment-configuration;
|
||||||
|
#// {
|
||||||
|
# TODO(@fricklerhandwerk):
|
||||||
|
# the Clan JSON schema converter always marks "object" types as optional,
|
||||||
|
# which means we need to deal with that *somewhere*, and as a hack it's done here.
|
||||||
|
# right now, since initial form contents are produced from Pydantic default values, we get None for those nested objects, which translates to `null` here.
|
||||||
|
#mastodon = optionalAttrs (isNull deployment-configuration.mastodon) { };
|
||||||
|
#peertube = optionalAttrs (isNull deployment-configuration.peertube) { };
|
||||||
|
#pixelfed = optionalAttrs (isNull deployment-configuration.pixelfed) { };
|
||||||
|
#};
|
||||||
providers = {
|
providers = {
|
||||||
inherit (nixops4.modules.nixops4Provider) local;
|
inherit (nixops4.modules.nixops4Provider) local;
|
||||||
};
|
};
|
||||||
|
@ -73,7 +95,7 @@ in
|
||||||
s3SecretKeyFile = pkgs.writeText "s3SecretKey" "5be6799a88ca9b9d813d1a806b64f15efa49482dbe15339ddfaf7f19cf434987";
|
s3SecretKeyFile = pkgs.writeText "s3SecretKey" "5be6799a88ca9b9d813d1a806b64f15efa49482dbe15339ddfaf7f19cf434987";
|
||||||
};
|
};
|
||||||
|
|
||||||
makeConfigurationResource = resourceModule: config: {
|
makeConfigurationResource = resourceModule: deployment-configuration: {
|
||||||
type = providers.local.exec;
|
type = providers.local.exec;
|
||||||
imports = [
|
imports = [
|
||||||
nixops4-nixos.modules.nixops4Resource.nixos
|
nixops4-nixos.modules.nixops4Resource.nixos
|
||||||
|
@ -92,7 +114,7 @@ in
|
||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
config
|
deployment-configuration
|
||||||
fediversity
|
fediversity
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
@ -179,4 +201,5 @@ in
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
{% for service_name, service_meta in services.items %}
|
{% for service_name, service_meta in services.items %}
|
||||||
{% if service_meta.enable %}
|
{% if service_meta.enable %}
|
||||||
<li>
|
<li>
|
||||||
✓ <a target="_blank" href=https://{{ service_name }}.{{ domain }}>{{ service_name }}</a>
|
✓ <a target="_blank" href=https://{{ service_name }}.{{ services.domain }}>{{ service_name }}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -65,6 +65,8 @@ class ConfigurationForm(LoginRequiredMixin, APIView):
|
||||||
return Response({'serializer': serializer})
|
return Response({'serializer': serializer})
|
||||||
|
|
||||||
config.value = json.dumps(serializer.validated_data)
|
config.value = json.dumps(serializer.validated_data)
|
||||||
|
print(request.data)
|
||||||
|
print(config.value)
|
||||||
config.save()
|
config.save()
|
||||||
return redirect(self.success_url)
|
return redirect(self.success_url)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue