Compare commits

...

3 commits

3 changed files with 34 additions and 16 deletions

View file

@ -106,15 +106,16 @@ in
module =
{ ... }:
{
enable = lib.mkEnableOption "Hello in the shell";
options.enable = lib.mkEnableOption "Hello in the shell";
};
implementation =
cfg:
lib.optionalAttrs cfg.enable {
hello.login-shell.packages = {
implementation = cfg: {
input = cfg;
output = lib.optionalAttrs cfg.enable {
resources.hello.login-shell.packages = {
inherit (pkgs) hello;
};
};
};
};
environments.single-nixos-vm =
{ config, ... }:
@ -161,10 +162,15 @@ in
}
);
in
{
inherit (fediversity) example-deployment;
rec {
config = fediversity.example-configuration;
resources = fediversity.applications.hello.implementation config.applications.hello;
};
expected = {
config = {
enable = true;
applications.hello.enable = true;
};
};
};
}

View file

@ -17,15 +17,28 @@ let
;
functionType = import ./function.nix;
application-resources = {
application-resources = submodule {
options.resources = mkOption {
# TODO: maybe transpose, and group the resources by type instead
type = attrsOf (
attrTag (lib.mapAttrs (_name: resource: mkOption { type = resource.request; }) config.resources)
attrTag (
lib.mapAttrs (_name: resource: mkOption { type = submodule resource.request; }) config.resources
)
);
};
};
nixops4Deployment = inputs.nixops4.modules.nixops4Deployment.default;
nixops4Deployment = types.deferredModuleWith {
staticModules = [
inputs.nixops4.modules.nixops4Deployment.default
{
_module.args = {
resourceProviderSystem = builtins.currentSystem;
resources = { };
};
}
];
};
in
{
options = {
@ -103,7 +116,7 @@ in
type = submodule functionType;
readOnly = true;
default = {
input-type = application.config.module;
input-type = submodule application.config.module;
output-type = application-resources;
};
};

View file

@ -5,7 +5,6 @@
let
inherit (lib) mkOption types;
inherit (types)
deferredModule
submodule
functionTo
optionType
@ -14,10 +13,10 @@ in
{
options = {
input-type = mkOption {
type = deferredModule;
type = optionType;
};
output-type = mkOption {
type = deferredModule;
type = optionType;
};
function-type = mkOption {
type = optionType;
@ -26,10 +25,10 @@ in
submodule (function: {
options = {
input = mkOption {
type = submodule config.input-type;
type = config.input-type;
};
output = mkOption {
type = submodule config.output-type;
type = config.output-type;
};
};
})