improve ssh module using optionalString
This commit is contained in:
parent
a182bb4a2d
commit
021401540d
2 changed files with 9 additions and 11 deletions
|
@ -68,6 +68,10 @@ _: {
|
|||
port = 10471;
|
||||
user = "root";
|
||||
};
|
||||
gay = {
|
||||
hostName = "git.gay";
|
||||
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHqUMVlwisg8oXuJaYp49Og8hljAgHsccxiDuxIYQ+2q";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) attrsOf bool listOf nullOr number port str submodule;
|
||||
inherit (lib.strings) concatStrings;
|
||||
inherit (lib.strings) concatStrings optionalString;
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
|
||||
ksshaskpass = getExe' pkgs.libsForQt5.ksshaskpass "ksshaskpass";
|
||||
|
@ -98,16 +98,10 @@ in {
|
|||
Host ${name}
|
||||
HostName ${value.hostName}
|
||||
User ${value.user}
|
||||
${
|
||||
if value.port != null then
|
||||
"Port ${toString value.port}"
|
||||
else ""
|
||||
}
|
||||
${
|
||||
if value.publicKey != null then
|
||||
"IdentityFile ${pkgs.writeText "${name}.pub" value.publicKey}"
|
||||
else ""
|
||||
}
|
||||
${optionalString (value.port != null)
|
||||
"Port ${toString value.port}"}
|
||||
${optionalString (value.publicKey != null)
|
||||
"IdentityFile ${pkgs.writeText "${name}.pub" value.publicKey}"}
|
||||
'') cfg.agent.hostAliases)}
|
||||
'';
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue