forked from fediversity/fediversity
allow use of readOnly attributes in modular function output types
Signed-off-by: Kiara Grouwstra <kiara@procolix.eu>
This commit is contained in:
parent
c0024739b2
commit
da724b3511
4 changed files with 59 additions and 10 deletions
|
|
@ -140,6 +140,7 @@ in
|
||||||
type = functionType;
|
type = functionType;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
default = {
|
default = {
|
||||||
|
type-output = false;
|
||||||
input-type = submodule {
|
input-type = submodule {
|
||||||
options = {
|
options = {
|
||||||
deployment-name = mkOption {
|
deployment-name = mkOption {
|
||||||
|
|
@ -159,6 +160,7 @@ in
|
||||||
type = functionType;
|
type = functionType;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
default = {
|
default = {
|
||||||
|
type-output = false;
|
||||||
input-type = submodule {
|
input-type = submodule {
|
||||||
options = {
|
options = {
|
||||||
deployment-name = mkOption {
|
deployment-name = mkOption {
|
||||||
|
|
|
||||||
|
|
@ -105,4 +105,48 @@ in
|
||||||
value = false;
|
value = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
test-read-only = {
|
||||||
|
expr =
|
||||||
|
tryEval
|
||||||
|
(lib.evalModules {
|
||||||
|
modules = [
|
||||||
|
(
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
fn = mkOption {
|
||||||
|
type = functionType;
|
||||||
|
};
|
||||||
|
call = mkOption {
|
||||||
|
default = config.fn.apply { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config.fn =
|
||||||
|
let
|
||||||
|
sub = submodule {
|
||||||
|
options.foo = mkOption {
|
||||||
|
type = int;
|
||||||
|
readOnly = true;
|
||||||
|
default = 1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
implementation = x: x;
|
||||||
|
input-type = sub;
|
||||||
|
output-type = sub;
|
||||||
|
type-output = false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}).config.call;
|
||||||
|
expected = {
|
||||||
|
success = true;
|
||||||
|
value = {
|
||||||
|
foo = 1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,11 @@ let
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
type-output = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
description = "Whether to type function output. This may need to be disabled if the output type contains read-only attributes.";
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
input-type = mkOption {
|
input-type = mkOption {
|
||||||
type = optionType;
|
type = optionType;
|
||||||
};
|
};
|
||||||
|
|
@ -54,7 +59,7 @@ in
|
||||||
function-type = mkOption {
|
function-type = mkOption {
|
||||||
type = optionType;
|
type = optionType;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
default = functionTo config.output-type;
|
default = functionTo (if config.type-output then config.output-type else types.unspecified);
|
||||||
};
|
};
|
||||||
wrapper-type = mkOption {
|
wrapper-type = mkOption {
|
||||||
type = optionType;
|
type = optionType;
|
||||||
|
|
@ -65,7 +70,7 @@ in
|
||||||
type = config.input-type;
|
type = config.input-type;
|
||||||
};
|
};
|
||||||
output = mkOption {
|
output = mkOption {
|
||||||
type = config.output-type;
|
type = if config.type-output then config.output-type else types.unspecified;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -202,8 +202,7 @@ in
|
||||||
};
|
};
|
||||||
run = mkOption {
|
run = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
# error: The option `ssh-deployment.ssh-host.run' is read-only, but it's set multiple times.
|
readOnly = true;
|
||||||
# readOnly = true;
|
|
||||||
default =
|
default =
|
||||||
let
|
let
|
||||||
inherit (ssh-host.config)
|
inherit (ssh-host.config)
|
||||||
|
|
@ -282,8 +281,7 @@ in
|
||||||
};
|
};
|
||||||
run = mkOption {
|
run = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
# error: The option `tf-deployment.tf-host.run' is read-only, but it's set multiple times.
|
readOnly = true;
|
||||||
# readOnly = true;
|
|
||||||
default =
|
default =
|
||||||
let
|
let
|
||||||
inherit (tf-host.config)
|
inherit (tf-host.config)
|
||||||
|
|
@ -354,8 +352,7 @@ in
|
||||||
};
|
};
|
||||||
run = mkOption {
|
run = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
# error: The option `tf-deployment.tf-host.run' is read-only, but it's set multiple times.
|
readOnly = true;
|
||||||
# readOnly = true;
|
|
||||||
default =
|
default =
|
||||||
let
|
let
|
||||||
inherit (tf-host.config)
|
inherit (tf-host.config)
|
||||||
|
|
@ -499,8 +496,7 @@ in
|
||||||
};
|
};
|
||||||
run = mkOption {
|
run = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
# error: The option `tf-deployment.tf-host.run' is read-only, but it's set multiple times.
|
readOnly = true;
|
||||||
# readOnly = true;
|
|
||||||
default =
|
default =
|
||||||
let
|
let
|
||||||
inherit (tf-host.config)
|
inherit (tf-host.config)
|
||||||
|
|
@ -587,6 +583,7 @@ in
|
||||||
};
|
};
|
||||||
run = mkOption {
|
run = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
|
readOnly = true;
|
||||||
default =
|
default =
|
||||||
let
|
let
|
||||||
inherit (tf-netbox-store-ips.config)
|
inherit (tf-netbox-store-ips.config)
|
||||||
|
|
@ -614,6 +611,7 @@ in
|
||||||
inherit httpBackend;
|
inherit httpBackend;
|
||||||
run = mkOption {
|
run = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
|
readOnly = true;
|
||||||
default =
|
default =
|
||||||
let
|
let
|
||||||
inherit (tf-netbox-get-ip.config)
|
inherit (tf-netbox-get-ip.config)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue