ca: extend script a bit to use opensc too

This commit is contained in:
Aaron Bieber 2023-03-06 18:33:56 -07:00
parent f4e0994581
commit 52f973c2eb
No known key found for this signature in database

View File

@ -1,11 +1,20 @@
{ lib, buildGoModule, fetchFromGitHub, pkg-config, pcsclite, softhsm { lib, buildGoModule, fetchFromGitHub, pkg-config, pcsclite, softhsm, opensc
, writeScriptBin }: , writeScriptBin }:
let let
getScriptName = "get_softhsm_so_path"; getScriptName = "step-kms-module";
getSoftHSMsoPath = writeScriptBin getScriptName '' getSoftHSMsoPath = writeScriptBin getScriptName ''
#!/usr/bin/env sh #!/usr/bin/env sh
case $1 in
softhsm)
echo ${softhsm}/lib/softhsm/libsofthsm2.so echo ${softhsm}/lib/softhsm/libsofthsm2.so
;;
opensc)
echo ${opensc}/lib/opensc-pkcs11.so
;;
*)
echo "usage: ${getScriptName} [softhsm|opensc]"
esac
''; '';
in buildGoModule rec { in buildGoModule rec {
@ -21,7 +30,7 @@ in buildGoModule rec {
nativeBuildInputs = [ pkg-config ]; nativeBuildInputs = [ pkg-config ];
buildInputs = [ pcsclite softhsm ]; buildInputs = [ pcsclite softhsm opensc ];
ldflags = [ "-w" "-s" "-X github.com/smallstep/step-kms-plugin/cmd.Version=${version}" ]; ldflags = [ "-w" "-s" "-X github.com/smallstep/step-kms-plugin/cmd.Version=${version}" ];
@ -29,7 +38,7 @@ in buildGoModule rec {
postBuild = '' postBuild = ''
mkdir -p $out/bin mkdir -p $out/bin
ln -s ${getSoftHSMsoPath}/bin/get_softhsm_so_path $out/bin/ ln -s ${getSoftHSMsoPath}/bin/${getScriptName} $out/bin/
''; '';
meta = with lib; { meta = with lib; {