mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-27 08:04:14 +00:00
571c71e6f7
We are migrating packages that meet below requirements: 1. using `callPackage` 2. called path is a directory 3. overriding set is empty (`{ }`) 4. not containing path expressions other than relative path (to makenixpkgs-vet happy) 5. not referenced by nix files outside of the directory, other than`pkgs/top-level/all-packages.nix` 6. not referencing nix files outside of the directory 7. not referencing `default.nix` (since it's changed to `package.nix`) 8. `outPath` doesn't change after migration The tool is here: https://github.com/Aleksanaa/by-name-migrate.
63 lines
1.8 KiB
Nix
63 lines
1.8 KiB
Nix
{ lib, stdenv, fetchFromGitHub, openssl, makeWrapper, runtimeShell }:
|
|
|
|
stdenv.mkDerivation rec {
|
|
pname = "easyrsa";
|
|
version = "3.2.1";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "OpenVPN";
|
|
repo = "easy-rsa";
|
|
rev = "v${version}";
|
|
hash = "sha256-/c2Redb6whfM2D8hHBrcSaQ3YsBESLjeoKFb5a2lFbQ=";
|
|
};
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
nativeInstallCheckInputs = [ openssl.bin ];
|
|
|
|
installPhase = ''
|
|
mkdir -p $out/share/easy-rsa
|
|
cp -r easyrsa3/{*.cnf,x509-types,vars.example} $out/share/easy-rsa
|
|
install -D -m755 easyrsa3/easyrsa $out/bin/easyrsa
|
|
|
|
substituteInPlace $out/bin/easyrsa \
|
|
--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-default EASYRSA_OPENSSL ${openssl.bin}/bin/openssl
|
|
|
|
# Helper utility
|
|
cat > $out/bin/easyrsa-init <<EOF
|
|
#!${runtimeShell} -e
|
|
cp -r $out/share/easy-rsa/* .
|
|
EOF
|
|
chmod +x $out/bin/easyrsa-init
|
|
'';
|
|
|
|
doInstallCheck = true;
|
|
postInstallCheck = ''
|
|
set -euo pipefail
|
|
export EASYRSA_BATCH=1
|
|
export EASYRSA_PASSIN=pass:nixpkgs
|
|
export EASYRSA_PASSOUT="$EASYRSA_PASSIN"
|
|
export EASYRSA_REQ_CN='nixpkgs test CA'
|
|
export EASYRSA_KEY_SIZE=3072
|
|
export EASYRSA_ALGO=rsa
|
|
export EASYRSA_DIGEST=sha512
|
|
$out/bin/easyrsa init-pki
|
|
$out/bin/easyrsa build-ca
|
|
openssl x509 -in pki/ca.crt -noout -subject | tee /dev/stderr | grep -zq "$EASYRSA_REQ_CN"
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "Simple shell based CA utility";
|
|
homepage = "https://openvpn.net/";
|
|
license = licenses.gpl2Only;
|
|
maintainers = [ maintainers.offline maintainers.numinit ];
|
|
platforms = platforms.unix;
|
|
};
|
|
}
|