2021-05-13 11:26:45 +01:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchurl
|
2021-05-15 22:22:03 +01:00
|
|
|
, nixosTests
|
2021-05-13 11:26:45 +01:00
|
|
|
, pkg-config
|
|
|
|
, systemd
|
|
|
|
, gmp
|
|
|
|
, unbound
|
|
|
|
, bison
|
|
|
|
, flex
|
|
|
|
, pam
|
|
|
|
, libevent
|
|
|
|
, libcap_ng
|
2022-09-29 16:18:39 +01:00
|
|
|
, libxcrypt
|
2021-05-13 11:26:45 +01:00
|
|
|
, curl
|
|
|
|
, nspr
|
|
|
|
, bash
|
2022-01-24 14:51:36 +00:00
|
|
|
, runtimeShell
|
2021-05-13 11:26:45 +01:00
|
|
|
, iproute2
|
|
|
|
, iptables
|
|
|
|
, procps
|
|
|
|
, coreutils
|
|
|
|
, gnused
|
|
|
|
, gawk
|
|
|
|
, nss
|
|
|
|
, which
|
|
|
|
, python3
|
|
|
|
, libselinux
|
|
|
|
, ldns
|
|
|
|
, xmlto
|
|
|
|
, docbook_xml_dtd_412
|
|
|
|
, docbook_xsl
|
|
|
|
, findXMLCatalogs
|
2022-10-05 22:31:45 +01:00
|
|
|
, dns-root-data
|
2021-05-13 11:26:45 +01:00
|
|
|
}:
|
2016-02-24 04:06:45 +00:00
|
|
|
|
|
|
|
let
|
2021-05-13 11:26:45 +01:00
|
|
|
# Tools needed by ipsec scripts
|
2021-01-15 09:19:50 +00:00
|
|
|
binPath = lib.makeBinPath [
|
2021-05-13 11:26:45 +01:00
|
|
|
iproute2 iptables procps
|
|
|
|
coreutils gnused gawk
|
|
|
|
nss.tools which
|
2016-02-24 04:06:45 +00:00
|
|
|
];
|
|
|
|
in
|
|
|
|
|
2020-05-18 23:43:36 +01:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "libreswan";
|
2022-10-19 09:26:34 +01:00
|
|
|
version = "4.9";
|
2016-02-24 04:06:45 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2020-05-18 23:43:36 +01:00
|
|
|
url = "https://download.libreswan.org/${pname}-${version}.tar.gz";
|
2022-10-19 09:26:34 +01:00
|
|
|
sha256 = "sha256-9kLctjXpCVZMqP2Z6kSrQ/YHI7TXbBWO2BKXjEWzmLk=";
|
2016-02-24 04:06:45 +00:00
|
|
|
};
|
|
|
|
|
2021-03-26 08:13:11 +00:00
|
|
|
strictDeps = true;
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
bison
|
|
|
|
flex
|
|
|
|
pkg-config
|
2021-05-13 11:26:45 +01:00
|
|
|
xmlto
|
|
|
|
docbook_xml_dtd_412
|
|
|
|
docbook_xsl
|
|
|
|
findXMLCatalogs
|
2021-03-26 08:13:11 +00:00
|
|
|
];
|
|
|
|
|
2021-05-13 11:26:45 +01:00
|
|
|
buildInputs = [
|
|
|
|
systemd coreutils
|
|
|
|
gnused gawk gmp unbound pam libevent
|
2022-09-29 16:18:39 +01:00
|
|
|
libcap_ng libxcrypt curl nspr nss ldns
|
2021-05-13 11:26:45 +01:00
|
|
|
# needed to patch shebangs
|
|
|
|
python3 bash
|
|
|
|
] ++ lib.optional stdenv.isLinux libselinux;
|
2016-02-24 04:06:45 +00:00
|
|
|
|
|
|
|
prePatch = ''
|
2022-01-19 10:44:58 +00:00
|
|
|
# Correct iproute2 and iptables path
|
2022-01-24 14:51:36 +00:00
|
|
|
sed -e 's|/sbin/ip|${iproute2}/bin/ip|g' \
|
2022-01-19 10:44:58 +00:00
|
|
|
-e 's|/sbin/\(ip6\?tables\)|${iptables}/bin/\1|' \
|
2022-01-24 14:51:36 +00:00
|
|
|
-e 's|/bin/bash|${runtimeShell}|g' \
|
2021-05-13 11:26:45 +01:00
|
|
|
-i initsystems/systemd/ipsec.service.in \
|
2022-01-19 10:44:58 +00:00
|
|
|
programs/barf/barf.in \
|
2022-10-05 22:31:45 +01:00
|
|
|
programs/verify.linux/verify.in
|
2022-01-19 10:44:58 +00:00
|
|
|
sed -e 's|\([[:blank:]]\)\(ip6\?tables\(-save\)\? -\)|\1${iptables}/bin/\2|' \
|
2022-10-05 22:31:45 +01:00
|
|
|
-i programs/verify.linux/verify.in
|
2021-05-13 11:26:45 +01:00
|
|
|
|
|
|
|
# Prevent the makefile from trying to
|
|
|
|
# reload the systemd daemon or create tmpfiles
|
|
|
|
sed -e 's|systemctl|true|g' \
|
|
|
|
-e 's|systemd-tmpfiles|true|g' \
|
|
|
|
-i initsystems/systemd/Makefile
|
2016-02-24 04:06:45 +00:00
|
|
|
|
|
|
|
# Fix the ipsec program from crushing the PATH
|
2021-05-13 11:26:45 +01:00
|
|
|
sed -e 's|\(PATH=".*"\):.*$|\1:$PATH|' -i programs/ipsec/ipsec.in
|
2016-02-24 04:06:45 +00:00
|
|
|
|
|
|
|
# Fix python script to use the correct python
|
2021-05-13 11:26:45 +01:00
|
|
|
sed -e 's/^\(\W*\)installstartcheck()/\1sscmd = "ss"\n\0/' \
|
2022-10-05 22:31:45 +01:00
|
|
|
-i programs/verify.linux/verify.in
|
2021-05-13 11:26:45 +01:00
|
|
|
|
|
|
|
# Replace wget with curl to save a dependency
|
|
|
|
curlArgs='-s --remote-name-all --output-dir'
|
|
|
|
sed -e "s|wget -q -P|${curl}/bin/curl $curlArgs|g" \
|
|
|
|
-i programs/letsencrypt/letsencrypt.in
|
|
|
|
|
|
|
|
# Patch the Makefile:
|
|
|
|
# 1. correct the pam.d directory install path
|
|
|
|
# 2. do not create the /var/lib/ directory
|
|
|
|
sed -e 's|$(DESTDIR)/etc/pam.d|$(out)/etc/pam.d|' \
|
|
|
|
-e '/test ! -d $(NSSDIR)/,+3d' \
|
|
|
|
-i configs/Makefile
|
2016-02-24 04:06:45 +00:00
|
|
|
'';
|
2017-11-16 02:43:15 +00:00
|
|
|
|
|
|
|
makeFlags = [
|
2021-08-29 20:22:55 +01:00
|
|
|
"PREFIX=$(out)"
|
2016-02-24 04:06:45 +00:00
|
|
|
"INITSYSTEM=systemd"
|
2021-05-13 11:26:45 +01:00
|
|
|
"UNITDIR=$(out)/etc/systemd/system/"
|
|
|
|
"TMPFILESDIR=$(out)/lib/tmpfiles.d/"
|
2022-06-11 15:00:13 +01:00
|
|
|
"LINUX_VARIANT=nixos"
|
2022-10-05 22:31:45 +01:00
|
|
|
"DEFAULT_DNSSEC_ROOTKEY_FILE=${dns-root-data}/root.key"
|
2016-02-24 04:06:45 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# Hack to make install work
|
|
|
|
installFlags = [
|
|
|
|
"FINALVARDIR=\${out}/var"
|
|
|
|
"FINALSYSCONFDIR=\${out}/etc"
|
|
|
|
];
|
|
|
|
|
|
|
|
postInstall = ''
|
2021-05-13 11:26:45 +01:00
|
|
|
# Install examples directory (needed for letsencrypt)
|
|
|
|
cp -r docs/examples $out/share/doc/libreswan/examples
|
2016-02-24 04:06:45 +00:00
|
|
|
'';
|
|
|
|
|
2021-05-13 11:26:45 +01:00
|
|
|
postFixup = ''
|
|
|
|
# Add a PATH to the main "ipsec" script
|
|
|
|
sed -e '0,/^$/{s||export PATH=${binPath}:$PATH|}' \
|
|
|
|
-i $out/bin/ipsec
|
|
|
|
'';
|
2016-03-02 15:36:22 +00:00
|
|
|
|
2021-05-15 22:22:03 +01:00
|
|
|
passthru.tests.libreswan = nixosTests.libreswan;
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2020-03-06 19:37:20 +00:00
|
|
|
homepage = "https://libreswan.org";
|
2016-02-24 04:06:45 +00:00
|
|
|
description = "A free software implementation of the VPN protocol based on IPSec and the Internet Key Exchange";
|
2020-10-24 13:52:18 +01:00
|
|
|
platforms = platforms.linux ++ platforms.freebsd;
|
2021-05-13 11:44:20 +01:00
|
|
|
license = with licenses; [ gpl2Plus mpl20 ] ;
|
2021-05-13 11:44:45 +01:00
|
|
|
maintainers = with maintainers; [ afranchuk rnhmjoj ];
|
2016-02-24 04:06:45 +00:00
|
|
|
};
|
|
|
|
}
|