From 72d2d59cd4d10cab69bc981c95a1db1a7ab61930 Mon Sep 17 00:00:00 2001 From: Vladimír Čunát Date: Sun, 11 Jan 2015 22:04:04 +0100 Subject: /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. --- nixos/modules/services/networking/ssh/sshd.nix | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/nixos/modules/services/networking/ssh/sshd.nix b/nixos/modules/services/networking/ssh/sshd.nix index 4db8d1e25450a..c0ad9e17c4130 100644 --- a/nixos/modules/services/networking/ssh/sshd.nix +++ b/nixos/modules/services/networking/ssh/sshd.nix @@ -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"; } ]; -- cgit 1.4.1