2023-01-11 07:51:40 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, openssl, makeWrapper, runtimeShell }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-01-11 07:51:40 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "easyrsa";
|
2023-10-09 19:29:22 +00:00
|
|
|
version = "3.1.6";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "OpenVPN";
|
|
|
|
repo = "easy-rsa";
|
|
|
|
rev = "v${version}";
|
2023-10-09 19:29:22 +00:00
|
|
|
sha256 = "sha256-VbL2QXc4IaTe6u17nhByIk+SEsKLhl6sk85E5moGfjs=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-01-11 07:51:40 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
2023-01-11 07:51:40 +00:00
|
|
|
mkdir -p $out/share/easy-rsa
|
|
|
|
cp -r easyrsa3/{*.cnf,x509-types,vars.example} $out/share/easy-rsa
|
2020-04-24 23:36:52 +00:00
|
|
|
install -D -m755 easyrsa3/easyrsa $out/bin/easyrsa
|
2023-01-11 07:51:40 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace $out/bin/easyrsa \
|
2023-01-11 07:51:40 +00:00
|
|
|
--replace /usr/ $out/ \
|
|
|
|
--replace '~VER~' '${version}' \
|
|
|
|
--replace '~GITHEAD~' 'v${version}' \
|
|
|
|
--replace '~DATE~' '1970-01-01'
|
|
|
|
|
|
|
|
# Wrap it with the correct OpenSSL binary.
|
|
|
|
wrapProgram $out/bin/easyrsa \
|
|
|
|
--set EASYRSA_OPENSSL ${openssl.bin}/bin/openssl
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Helper utility
|
|
|
|
cat > $out/bin/easyrsa-init <<EOF
|
|
|
|
#!${runtimeShell} -e
|
2023-01-11 07:51:40 +00:00
|
|
|
cp -r $out/share/easy-rsa/* .
|
2020-04-24 23:36:52 +00:00
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/easyrsa-init
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Simple shell based CA utility";
|
|
|
|
homepage = "https://openvpn.net/";
|
|
|
|
license = licenses.gpl2;
|
2020-12-07 07:45:13 +00:00
|
|
|
maintainers = [ maintainers.offline maintainers.numinit ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|