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