base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / li / libreswan / package.nix
blob8484185404519b422f51eeb60c12e0a3272ca219
1 { lib
2 , stdenv
3 , fetchurl
4 , nixosTests
5 , pkg-config
6 , systemd
7 , gmp
8 , unbound
9 , bison
10 , flex
11 , pam
12 , libevent
13 , libcap_ng
14 , libxcrypt
15 , curl
16 , nspr
17 , bash
18 , runtimeShell
19 , iproute2
20 , iptables
21 , procps
22 , coreutils
23 , gnused
24 , gawk
25 , nss
26 , which
27 , python3
28 , libselinux
29 , ldns
30 , xmlto
31 , docbook_xml_dtd_45
32 , docbook_xsl
33 , findXMLCatalogs
34 , dns-root-data
37 let
38   # Tools needed by ipsec scripts
39   binPath = lib.makeBinPath [
40     iproute2 iptables procps
41     coreutils gnused gawk
42     nss.tools which
43   ];
46 stdenv.mkDerivation rec {
47   pname = "libreswan";
48   version = "5.1";
50   src = fetchurl {
51     url = "https://download.libreswan.org/${pname}-${version}.tar.gz";
52     hash = "sha256-HO6dQSyJeZ64v3EUUA1cFOAUPpVGBWFj7r45YOf0Y3w=";
53   };
55   strictDeps = true;
57   nativeBuildInputs = [
58     bison
59     flex
60     pkg-config
61     xmlto
62     docbook_xml_dtd_45
63     docbook_xsl
64     findXMLCatalogs
65   ];
67   buildInputs = [
68     systemd coreutils
69     gnused gawk gmp unbound pam libevent
70     libcap_ng libxcrypt curl nspr nss ldns
71     # needed to patch shebangs
72     python3 bash
73   ] ++ lib.optional stdenv.hostPlatform.isLinux libselinux;
75   prePatch = ''
76     # Replace wget with curl to save a dependency
77     substituteInPlace programs/letsencrypt/letsencrypt.in \
78       --replace-fail 'wget -q -P' '${curl}/bin/curl -s --remote-name-all --output-dir'
79   '';
81   makeFlags = [
82     "PREFIX=$(out)"
83     "INITSYSTEM=systemd"
84     "SYSTEMUNITDIR=$(out)/etc/systemd/system/"
85     "TMPFILESDIR=$(out)/lib/tmpfiles.d/"
86     "LINUX_VARIANT=nixos"
87     "DEFAULT_DNSSEC_ROOTKEY_FILE=${dns-root-data}/root.key"
88   ];
90   # Hack to make install work
91   installFlags = [
92     "VARDIR=\${out}/var"
93     "SYSCONFDIR=\${out}/etc"
94   ];
96   postInstall = ''
97     # Install letsencrypt config files
98     install -m644 -Dt "$out/share/doc/libreswan/letsencrypt" docs/examples/*
99   '';
101   postFixup = ''
102     # Add a PATH to the main "ipsec" script
103     sed -e '0,/^$/{s||export PATH=${binPath}:$PATH|}' \
104         -i $out/bin/ipsec
105   '';
107   passthru.tests = { inherit (nixosTests) libreswan libreswan-nat; };
109   meta = with lib; {
110     homepage = "https://libreswan.org";
111     description = "Free software implementation of the VPN protocol based on IPSec and the Internet Key Exchange";
112     platforms = platforms.linux ++ platforms.freebsd;
113     license = with licenses; [ gpl2Plus mpl20 ] ;
114     maintainers = with maintainers; [ afranchuk rnhmjoj ];
115     mainProgram = "ipsec";
116   };