generate-module-options-rebase #1

Closed
kiara wants to merge 10 commits from generate-module-options-rebase into generate-module-options
3 changed files with 164 additions and 139 deletions
Showing only changes of commit 334719f529 - Show all commits

View file

@ -31,18 +31,40 @@
## Information on the specific deployment that we request.
## This is the information coming from the FediPanel.
config:
deployment-configuration:
let
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
## 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 = {
inherit (nixops4.modules.nixops4Provider) local;
};
@ -73,7 +95,7 @@ in
s3SecretKeyFile = pkgs.writeText "s3SecretKey" "5be6799a88ca9b9d813d1a806b64f15efa49482dbe15339ddfaf7f19cf434987";
};
makeConfigurationResource = resourceModule: config: {
makeConfigurationResource = resourceModule: deployment-configuration: {
type = providers.local.exec;
imports = [
nixops4-nixos.modules.nixops4Resource.nixos
@ -92,7 +114,7 @@ in
{ ... }:
{
imports = [
config
deployment-configuration
fediversity
];
};
@ -179,4 +201,5 @@ in
}
);
};
};
}

View file

@ -5,7 +5,7 @@
{% for service_name, service_meta in services.items %}
{% if service_meta.enable %}
<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>
{% endif %}
{% endfor %}

View file

@ -65,6 +65,8 @@ class ConfigurationForm(LoginRequiredMixin, APIView):
return Response({'serializer': serializer})
config.value = json.dumps(serializer.validated_data)
print(request.data)
print(config.value)
config.save()
return redirect(self.success_url)