Merge pull request #155522 from Julow/single_line_str

types.singleLineStr: strings that don't contain '\n'
main
Robert Hensing 2 years ago committed by GitHub
commit c4a5efa965
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      lib/types.nix
  2. 2
      nixos/modules/services/networking/ssh/sshd.nix

@ -300,6 +300,19 @@ rec {
inherit (str) merge;
};
# Allow a newline character at the end and trim it in the merge function.
singleLineStr =
let
inherit (strMatching "[^\n\r]*\n?") check merge;
in
mkOptionType {
name = "singleLineStr";
description = "(optionally newline-terminated) single-line string";
inherit check;
merge = loc: defs:
lib.removeSuffix "\n" (merge loc defs);
};
strMatching = pattern: mkOptionType {
name = "strMatching ${escapeNixString pattern}";
description = "string matching the pattern ${pattern}";

@ -30,7 +30,7 @@ let
options.openssh.authorizedKeys = {
keys = mkOption {
type = types.listOf types.str;
type = types.listOf types.singleLineStr;
default = [];
description = ''
A list of verbatim OpenSSH public keys that should be added to the

Loading…
Cancel
Save