forked from fediversity/fediversity
allow use of readOnly attributes in modular function output types (#577)
Reviewed-on: fediversity/fediversity#577
This commit is contained in:
parent
c0024739b2
commit
b0b32af2ab
4 changed files with 59 additions and 10 deletions
|
|
@ -140,6 +140,7 @@ in
|
|||
type = functionType;
|
||||
readOnly = true;
|
||||
default = {
|
||||
type-output = false;
|
||||
input-type = submodule {
|
||||
options = {
|
||||
deployment-name = mkOption {
|
||||
|
|
@ -159,6 +160,7 @@ in
|
|||
type = functionType;
|
||||
readOnly = true;
|
||||
default = {
|
||||
type-output = false;
|
||||
input-type = submodule {
|
||||
options = {
|
||||
deployment-name = mkOption {
|
||||
|
|
|
|||
|
|
@ -105,4 +105,48 @@ in
|
|||
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
|
||||
{
|
||||
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 {
|
||||
type = optionType;
|
||||
};
|
||||
|
|
@ -54,7 +59,7 @@ in
|
|||
function-type = mkOption {
|
||||
type = optionType;
|
||||
readOnly = true;
|
||||
default = functionTo config.output-type;
|
||||
default = functionTo (if config.type-output then config.output-type else types.unspecified);
|
||||
};
|
||||
wrapper-type = mkOption {
|
||||
type = optionType;
|
||||
|
|
@ -65,7 +70,7 @@ in
|
|||
type = config.input-type;
|
||||
};
|
||||
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 {
|
||||
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 =
|
||||
let
|
||||
inherit (ssh-host.config)
|
||||
|
|
@ -282,8 +281,7 @@ in
|
|||
};
|
||||
run = mkOption {
|
||||
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 =
|
||||
let
|
||||
inherit (tf-host.config)
|
||||
|
|
@ -354,8 +352,7 @@ in
|
|||
};
|
||||
run = mkOption {
|
||||
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 =
|
||||
let
|
||||
inherit (tf-host.config)
|
||||
|
|
@ -499,8 +496,7 @@ in
|
|||
};
|
||||
run = mkOption {
|
||||
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 =
|
||||
let
|
||||
inherit (tf-host.config)
|
||||
|
|
@ -587,6 +583,7 @@ in
|
|||
};
|
||||
run = mkOption {
|
||||
type = types.package;
|
||||
readOnly = true;
|
||||
default =
|
||||
let
|
||||
inherit (tf-netbox-store-ips.config)
|
||||
|
|
@ -614,6 +611,7 @@ in
|
|||
inherit httpBackend;
|
||||
run = mkOption {
|
||||
type = types.package;
|
||||
readOnly = true;
|
||||
default =
|
||||
let
|
||||
inherit (tf-netbox-get-ip.config)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue