1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-09-11 15:08:33 +01:00

/etc/ssh/ssh_known_hosts: refactor and fix #5612

Generating the file was refactored to be completely in nix.
Functionally it should create the same content as before,
only adding the newlines.

CC recent updaters: @aszlig, @rickynils.
This commit is contained in:
Vladimír Čunát 2015-01-11 22:04:04 +01:00
parent e98a443e71
commit 72d2d59cd4

View file

@ -17,13 +17,11 @@ let
knownHosts = map (h: getAttr h cfg.knownHosts) (attrNames cfg.knownHosts);
knownHostsFile = pkgs.runCommand "ssh_known_hosts" {} ''
touch "$out"
${flip concatMapStrings knownHosts (h: ''
pubkeyfile=${builtins.toFile "host.pub" (if h.publicKey == null then readFile h.publicKeyFile else h.publicKey)}
${pkgs.gnused}/bin/sed 's/^/${concatStringsSep "," h.hostNames} /' $pubkeyfile >> "$out"
'')}
'';
knownHostsText = flip (concatMapStringsSep "\n") knownHosts
(h:
concatStringsSep "," h.hostNames + " "
+ (if h.publicKey != null then h.publicKey else readFile h.publicKeyFile)
);
userOptions = {
@ -301,7 +299,7 @@ in
{ source = "${cfgc.package}/etc/ssh/moduli";
target = "ssh/moduli";
}
{ source = knownHostsFile;
{ text = knownHostsText;
target = "ssh/ssh_known_hosts";
}
];