summary refs log tree commit diff
path: root/nixos/modules/programs
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-08-27 15:31:21 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-08-27 15:32:46 +0200
commitf6eece6f8f4aac8598aed0fbc8bfc2a621f33633 (patch)
treeab9beabb06a5043e9820399f451d2ce46dbb6479 /nixos/modules/programs
parent7c6ff6c1da65684137d9c3554540720f2f28e6cd (diff)
downloadnixlib-f6eece6f8f4aac8598aed0fbc8bfc2a621f33633.tar
nixlib-f6eece6f8f4aac8598aed0fbc8bfc2a621f33633.tar.gz
nixlib-f6eece6f8f4aac8598aed0fbc8bfc2a621f33633.tar.bz2
nixlib-f6eece6f8f4aac8598aed0fbc8bfc2a621f33633.tar.lz
nixlib-f6eece6f8f4aac8598aed0fbc8bfc2a621f33633.tar.xz
nixlib-f6eece6f8f4aac8598aed0fbc8bfc2a621f33633.tar.zst
nixlib-f6eece6f8f4aac8598aed0fbc8bfc2a621f33633.zip
programs.ssh.knownHosts: Use attribute name
This allows writing:

  programs.ssh.knownHosts."10.1.2.3".publicKey = "bar";

instead of

  programs.ssh.knownHosts = [ { hostNames = [ "10.1.2.3" ]; publicKey = "bar"; } ];
Diffstat (limited to 'nixos/modules/programs')
-rw-r--r--nixos/modules/programs/ssh.nix9
1 files changed, 6 insertions, 3 deletions
diff --git a/nixos/modules/programs/ssh.nix b/nixos/modules/programs/ssh.nix
index 87a00497621a..cf7ef455eb85 100644
--- a/nixos/modules/programs/ssh.nix
+++ b/nixos/modules/programs/ssh.nix
@@ -21,7 +21,7 @@ let
   knownHosts = map (h: getAttr h cfg.knownHosts) (attrNames cfg.knownHosts);
 
   knownHostsText = flip (concatMapStringsSep "\n") knownHosts
-    (h:
+    (h: assert h.hostNames != [];
       concatStringsSep "," h.hostNames + " "
       + (if h.publicKey != null then h.publicKey else readFile h.publicKeyFile)
     );
@@ -102,7 +102,7 @@ in
 
       knownHosts = mkOption {
         default = {};
-        type = types.loaOf (types.submodule {
+        type = types.loaOf (types.submodule ({ name, ... }: {
           options = {
             hostNames = mkOption {
               type = types.listOf types.str;
@@ -136,7 +136,10 @@ in
               '';
             };
           };
-        });
+          config = {
+            hostNames = mkDefault [ name ];
+          };
+        }));
         description = ''
           The set of system-wide known SSH hosts.
         '';