summary refs log tree commit diff
path: root/lib/types.nix
diff options
context:
space:
mode:
authorKlemens Nanni <klemens@posteo.de>2022-06-25 15:59:43 +0400
committerKlemens Nanni <klemens@posteo.de>2022-06-25 16:34:47 +0400
commit574a90771f3c0eeeeab798c38fea5f7bf6b44066 (patch)
treebcf394db8441ed6e9d163016fb6253141f6a419a /lib/types.nix
parent41c91c48eee8801b91eb6c18ef763b11dc059047 (diff)
downloadnixpkgs-574a90771f3c0eeeeab798c38fea5f7bf6b44066.tar
nixpkgs-574a90771f3c0eeeeab798c38fea5f7bf6b44066.tar.gz
nixpkgs-574a90771f3c0eeeeab798c38fea5f7bf6b44066.tar.bz2
nixpkgs-574a90771f3c0eeeeab798c38fea5f7bf6b44066.tar.lz
nixpkgs-574a90771f3c0eeeeab798c38fea5f7bf6b44066.tar.xz
nixpkgs-574a90771f3c0eeeeab798c38fea5f7bf6b44066.tar.zst
nixpkgs-574a90771f3c0eeeeab798c38fea5f7bf6b44066.zip
lib.types, nixos/users: Make passwdEntry available
More nixpkgs code such as `boot.initrd.systemd.emergencyAccess` defines
options that takes hashed passwords, so move the type definition from
modules/ into lib/.

The type definition itself stays unchanged.
Diffstat (limited to 'lib/types.nix')
-rw-r--r--lib/types.nix6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/types.nix b/lib/types.nix
index 354714b2873..d7655bc1a6a 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -55,6 +55,7 @@ let
     concatMapStringsSep
     concatStringsSep
     escapeNixString
+    hasInfix
     isCoercibleToString
     ;
   inherit (lib.trivial)
@@ -360,6 +361,11 @@ rec {
       deprecationMessage = "See https://github.com/NixOS/nixpkgs/pull/66346 for better alternative types.";
     };
 
+    passwdEntry = entryType: addCheck entryType (str: !(hasInfix ":" str || hasInfix "\n" str)) // {
+      name = "passwdEntry ${entryType.name}";
+      description = "${entryType.description}, not containing newlines or colons";
+    };
+
     attrs = mkOptionType {
       name = "attrs";
       description = "attribute set";