From 52f973c2eb3cdb717779397075656a5f56290972 Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Mon, 6 Mar 2023 18:33:56 -0700 Subject: [PATCH] ca: extend script a bit to use opensc too --- pkgs/step-kms-plugin.nix | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pkgs/step-kms-plugin.nix b/pkgs/step-kms-plugin.nix index ecdadf5..79c9d48 100644 --- a/pkgs/step-kms-plugin.nix +++ b/pkgs/step-kms-plugin.nix @@ -1,11 +1,20 @@ -{ lib, buildGoModule, fetchFromGitHub, pkg-config, pcsclite, softhsm +{ lib, buildGoModule, fetchFromGitHub, pkg-config, pcsclite, softhsm, opensc , writeScriptBin }: let - getScriptName = "get_softhsm_so_path"; + getScriptName = "step-kms-module"; getSoftHSMsoPath = writeScriptBin getScriptName '' #!/usr/bin/env sh - echo ${softhsm}/lib/softhsm/libsofthsm2.so + case $1 in + softhsm) + echo ${softhsm}/lib/softhsm/libsofthsm2.so + ;; + opensc) + echo ${opensc}/lib/opensc-pkcs11.so + ;; + *) + echo "usage: ${getScriptName} [softhsm|opensc]" + esac ''; in buildGoModule rec { @@ -21,7 +30,7 @@ in buildGoModule rec { nativeBuildInputs = [ pkg-config ]; - buildInputs = [ pcsclite softhsm ]; + buildInputs = [ pcsclite softhsm opensc ]; ldflags = [ "-w" "-s" "-X github.com/smallstep/step-kms-plugin/cmd.Version=${version}" ]; @@ -29,7 +38,7 @@ in buildGoModule rec { postBuild = '' mkdir -p $out/bin - ln -s ${getSoftHSMsoPath}/bin/get_softhsm_so_path $out/bin/ + ln -s ${getSoftHSMsoPath}/bin/${getScriptName} $out/bin/ ''; meta = with lib; {