mirror of
https://github.com/nix-community/home-manager
synced 2024-12-25 03:09:47 +01:00
programs.ssh: Use nullable types for optional forward attrs (#1946)
Attempting to build a flake configuration using `ssh.remoteForwards' results in evaluation errors when `port' is undefined, as `!(entry ? port)' evaluates to false. This was verified in the nix repl, and also occurs for `nix flake check'. Set optional attrs in `bindOptions' and `forwardModule' to `null' by default and adjust the assertion to check for `null' instead of attr definitions.
This commit is contained in:
parent
d437baa41c
commit
18ad12d52b
1 changed files with 7 additions and 4 deletions
|
@ -26,7 +26,8 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
port = mkOption {
|
port = mkOption {
|
||||||
type = types.port;
|
type = types.nullOr types.port;
|
||||||
|
default = null;
|
||||||
example = 8080;
|
example = 8080;
|
||||||
description = "Specifies port number to bind on bind address.";
|
description = "Specifies port number to bind on bind address.";
|
||||||
};
|
};
|
||||||
|
@ -42,13 +43,15 @@ let
|
||||||
|
|
||||||
host = {
|
host = {
|
||||||
address = mkOption {
|
address = mkOption {
|
||||||
type = types.str;
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
example = "example.org";
|
example = "example.org";
|
||||||
description = "The address where to forward the traffic to.";
|
description = "The address where to forward the traffic to.";
|
||||||
};
|
};
|
||||||
|
|
||||||
port = mkOption {
|
port = mkOption {
|
||||||
type = types.port;
|
type = types.nullOr types.port;
|
||||||
|
default = null;
|
||||||
example = 80;
|
example = 80;
|
||||||
description = "Specifies port number to forward the traffic to.";
|
description = "Specifies port number to forward the traffic to.";
|
||||||
};
|
};
|
||||||
|
@ -450,7 +453,7 @@ in
|
||||||
any' = pred: items: if items == [] then true else any pred items;
|
any' = pred: items: if items == [] then true else any pred items;
|
||||||
# Check that if `entry.address` is defined, and is a path, that `entry.port` has not
|
# Check that if `entry.address` is defined, and is a path, that `entry.port` has not
|
||||||
# been defined.
|
# been defined.
|
||||||
noPathWithPort = entry: entry ? address && isPath entry.address -> !(entry ? port);
|
noPathWithPort = entry: entry.address != null && isPath entry.address -> entry.port == null;
|
||||||
checkDynamic = block: any' noPathWithPort block.dynamicForwards;
|
checkDynamic = block: any' noPathWithPort block.dynamicForwards;
|
||||||
checkBindAndHost = fwd: noPathWithPort fwd.bind && noPathWithPort fwd.host;
|
checkBindAndHost = fwd: noPathWithPort fwd.bind && noPathWithPort fwd.host;
|
||||||
checkLocal = block: any' checkBindAndHost block.localForwards;
|
checkLocal = block: any' checkBindAndHost block.localForwards;
|
||||||
|
|
Loading…
Reference in a new issue