Merge pull request #136006 from zseri/dropbear-scp

dropbear: expose optional scp support
This commit is contained in:
Franz Pletz 2022-08-23 15:45:50 +02:00 committed by GitHub
commit e716acda8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,8 +1,19 @@
{ stdenv, lib, fetchurl, glibc, zlib
{ lib, stdenv, fetchurl, glibc, zlib
, enableStatic ? stdenv.hostPlatform.isStatic
, enableSCP ? false
, sftpPath ? "/run/current-system/sw/libexec/sftp-server"
}:
let
# NOTE: DROPBEAR_PATH_SSH_PROGRAM is only necessary when enableSCP is true,
# but it is enabled here always anyways for consistency
dflags = {
SFTPSERVER_PATH = sftpPath;
DROPBEAR_PATH_SSH_PROGRAM = "${placeholder "out"}/bin/dbclient";
};
in
stdenv.mkDerivation rec {
pname = "dropbear";
version = "2020.81";
@ -13,14 +24,23 @@ stdenv.mkDerivation rec {
};
dontDisableStatic = enableStatic;
configureFlags = lib.optional enableStatic "LDFLAGS=-static";
CFLAGS = "-DSFTPSERVER_PATH=\\\"${sftpPath}\\\"";
CFLAGS = lib.pipe (lib.attrNames dflags) [
(builtins.map (name: "-D${name}=\\\"${dflags.${name}}\\\""))
(lib.concatStringsSep " ")
];
# https://www.gnu.org/software/make/manual/html_node/Libraries_002fSearch.html
preConfigure = ''
makeFlags=VPATH=`cat $NIX_CC/nix-support/orig-libc`/lib
makeFlagsArray=(
VPATH=$(cat $NIX_CC/nix-support/orig-libc)/lib
PROGRAMS="${lib.concatStringsSep " " ([ "dropbear" "dbclient" "dropbearkey" "dropbearconvert" ] ++ lib.optionals enableSCP ["scp"])}"
)
'';
postInstall = lib.optionalString enableSCP ''
ln -rs $out/bin/scp $out/bin/dbscp
'';
patches = [