36 # Tools needed by ipsec scripts
37 binPath = lib.makeBinPath [
38 iproute2 iptables procps
44 stdenv.mkDerivation rec {
49 url = "https://download.libreswan.org/${pname}-${version}.tar.gz";
50 sha256 = "0xj974yc0y1r7235zl4jhvxqz3bpb8js2fy9ic820zq9swh0lgsz";
67 gnused gawk gmp unbound pam libevent
68 libcap_ng curl nspr nss ldns
69 # needed to patch shebangs
71 ] ++ lib.optional stdenv.isLinux libselinux;
74 # Fix compilation on aarch64, remove on next update
76 url = "https://github.com/libreswan/libreswan/commit/ea50d36d2886e44317ba5ba841de1d1bf91aee6c.patch";
77 sha256 = "1jp89rm9jp55zmiyimyhg7yadj0fwwxaw7i5gyclrs38w3y1aacj";
82 # Correct iproute2 path
83 sed -e 's|"/sbin/ip"|"${iproute2}/bin/ip"|' \
84 -e 's|"/sbin/iptables"|"${iptables}/bin/iptables"|' \
85 -i initsystems/systemd/ipsec.service.in \
86 programs/verify/verify.in
88 # Prevent the makefile from trying to
89 # reload the systemd daemon or create tmpfiles
90 sed -e 's|systemctl|true|g' \
91 -e 's|systemd-tmpfiles|true|g' \
92 -i initsystems/systemd/Makefile
94 # Fix the ipsec program from crushing the PATH
95 sed -e 's|\(PATH=".*"\):.*$|\1:$PATH|' -i programs/ipsec/ipsec.in
97 # Fix python script to use the correct python
98 sed -e 's/^\(\W*\)installstartcheck()/\1sscmd = "ss"\n\0/' \
99 -i programs/verify/verify.in
101 # Replace wget with curl to save a dependency
102 curlArgs='-s --remote-name-all --output-dir'
103 sed -e "s|wget -q -P|${curl}/bin/curl $curlArgs|g" \
104 -i programs/letsencrypt/letsencrypt.in
106 # Patch the Makefile:
107 # 1. correct the pam.d directory install path
108 # 2. do not create the /var/lib/ directory
109 sed -e 's|$(DESTDIR)/etc/pam.d|$(out)/etc/pam.d|' \
110 -e '/test ! -d $(NSSDIR)/,+3d' \
114 # Set appropriate paths for build
115 preBuild = "export INC_USRLOCAL=\${out}";
119 "UNITDIR=$(out)/etc/systemd/system/"
120 "TMPFILESDIR=$(out)/lib/tmpfiles.d/"
123 # Hack to make install work
125 "FINALVARDIR=\${out}/var"
126 "FINALSYSCONFDIR=\${out}/etc"
130 # Install examples directory (needed for letsencrypt)
131 cp -r docs/examples $out/share/doc/libreswan/examples
135 # Add a PATH to the main "ipsec" script
136 sed -e '0,/^$/{s||export PATH=${binPath}:$PATH|}' \
140 passthru.tests.libreswan = nixosTests.libreswan;
143 homepage = "https://libreswan.org";
144 description = "A free software implementation of the VPN protocol based on IPSec and the Internet Key Exchange";
145 platforms = platforms.linux ++ platforms.freebsd;
146 license = with licenses; [ gpl2Plus mpl20 ] ;
147 maintainers = with maintainers; [ afranchuk rnhmjoj ];