Skip to content

Instantly share code, notes, and snippets.

@aszlig
Created May 1, 2014 17:04
Show Gist options
  • Save aszlig/b01a8a1a69016b2ad93c to your computer and use it in GitHub Desktop.
Save aszlig/b01a8a1a69016b2ad93c to your computer and use it in GitHub Desktop.
{ stdenv, fetchgit, coreutils, openssh, writeScript }:
attrs:
let
cleanAttrs = removeAttrs attrs [ "privateKey" ];
in stdenv.lib.overrideDerivation (fetchgit cleanAttrs) (o: {
inherit (attrs) privateKey;
GIT_SSH = writeScript "gitssh.sh" ''
#!${stdenv.shell}
if privkeyFile="$(${coreutils}/bin/mktemp gitssh.XXXXXXXXXX)"; then
cleanup() { rm -f "$privkeyFile"; }
trap cleanup EXIT
echo -n "$privateKey" > "$privkeyFile"
${openssh}/bin/ssh \
-o UserKnownHostsFile=/dev/null \
-o StrictHostKeyChecking=no \
-i "$privkeyFile" \
"$@"
exit $?
fi
'';
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment