forked from fediversity/fediversity
Compare commits
3 commits
bf488f89e1
...
89b22df3a4
Author | SHA1 | Date | |
---|---|---|---|
89b22df3a4 | |||
b49e426ed4 | |||
421d7b6f93 |
3 changed files with 34 additions and 16 deletions
|
@ -106,16 +106,17 @@ in
|
||||||
module =
|
module =
|
||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
enable = lib.mkEnableOption "Hello in the shell";
|
options.enable = lib.mkEnableOption "Hello in the shell";
|
||||||
};
|
};
|
||||||
implementation =
|
implementation = cfg: {
|
||||||
cfg:
|
input = cfg;
|
||||||
lib.optionalAttrs cfg.enable {
|
output = lib.optionalAttrs cfg.enable {
|
||||||
hello.login-shell.packages = {
|
resources.hello.login-shell.packages = {
|
||||||
inherit (pkgs) hello;
|
inherit (pkgs) hello;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
environments.single-nixos-vm =
|
environments.single-nixos-vm =
|
||||||
{ config, ... }:
|
{ config, ... }:
|
||||||
{
|
{
|
||||||
|
@ -161,10 +162,15 @@ in
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
{
|
rec {
|
||||||
inherit (fediversity) example-deployment;
|
config = fediversity.example-configuration;
|
||||||
|
resources = fediversity.applications.hello.implementation config.applications.hello;
|
||||||
};
|
};
|
||||||
expected = {
|
expected = {
|
||||||
|
config = {
|
||||||
|
enable = true;
|
||||||
|
applications.hello.enable = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,15 +17,28 @@ let
|
||||||
;
|
;
|
||||||
|
|
||||||
functionType = import ./function.nix;
|
functionType = import ./function.nix;
|
||||||
application-resources = {
|
application-resources = submodule {
|
||||||
options.resources = mkOption {
|
options.resources = mkOption {
|
||||||
# TODO: maybe transpose, and group the resources by type instead
|
# TODO: maybe transpose, and group the resources by type instead
|
||||||
type = attrsOf (
|
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
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
@ -103,7 +116,7 @@ in
|
||||||
type = submodule functionType;
|
type = submodule functionType;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
default = {
|
default = {
|
||||||
input-type = application.config.module;
|
input-type = submodule application.config.module;
|
||||||
output-type = application-resources;
|
output-type = application-resources;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types;
|
||||||
inherit (types)
|
inherit (types)
|
||||||
deferredModule
|
|
||||||
submodule
|
submodule
|
||||||
functionTo
|
functionTo
|
||||||
optionType
|
optionType
|
||||||
|
@ -14,10 +13,10 @@ in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
input-type = mkOption {
|
input-type = mkOption {
|
||||||
type = deferredModule;
|
type = optionType;
|
||||||
};
|
};
|
||||||
output-type = mkOption {
|
output-type = mkOption {
|
||||||
type = deferredModule;
|
type = optionType;
|
||||||
};
|
};
|
||||||
function-type = mkOption {
|
function-type = mkOption {
|
||||||
type = optionType;
|
type = optionType;
|
||||||
|
@ -26,10 +25,10 @@ in
|
||||||
submodule (function: {
|
submodule (function: {
|
||||||
options = {
|
options = {
|
||||||
input = mkOption {
|
input = mkOption {
|
||||||
type = submodule config.input-type;
|
type = config.input-type;
|
||||||
};
|
};
|
||||||
output = mkOption {
|
output = mkOption {
|
||||||
type = submodule config.output-type;
|
type = config.output-type;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue