2020-12-22 23:06:27 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, buildGoModule
|
2021-02-18 12:00:22 +00:00
|
|
|
, coreutils
|
2020-12-22 23:06:27 +00:00
|
|
|
, pcsclite
|
|
|
|
, PCSC
|
|
|
|
, pkg-config
|
2021-02-18 12:01:26 +00:00
|
|
|
, hsmSupport ? true
|
2021-11-12 20:37:11 +00:00
|
|
|
, nixosTests
|
2020-12-22 23:06:27 +00:00
|
|
|
}:
|
2019-12-12 04:38:15 +00:00
|
|
|
|
2020-12-22 23:06:27 +00:00
|
|
|
buildGoModule rec {
|
2019-12-12 04:38:15 +00:00
|
|
|
pname = "step-ca";
|
2022-03-15 08:50:01 +00:00
|
|
|
version = "0.18.2";
|
2019-12-12 04:38:15 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "smallstep";
|
|
|
|
repo = "certificates";
|
|
|
|
rev = "v${version}";
|
2022-03-15 08:50:01 +00:00
|
|
|
sha256 = "sha256-BhPup3q2muYGWzAa/9b4vnIjBces4GhUHZ/mg4CWMRc=";
|
2019-12-12 04:38:15 +00:00
|
|
|
};
|
|
|
|
|
2022-03-15 08:50:01 +00:00
|
|
|
vendorSha256 = "sha256-oVaziWZGslZCVqkEXL32XvOVU54VOf41Qg+VoVWo7x0=";
|
2020-12-22 23:06:27 +00:00
|
|
|
|
2021-08-26 06:45:51 +00:00
|
|
|
ldflags = [ "-buildid=" ];
|
2021-07-28 14:39:09 +00:00
|
|
|
|
2021-02-18 12:01:26 +00:00
|
|
|
nativeBuildInputs = lib.optionals hsmSupport [ pkg-config ];
|
2020-12-22 23:06:27 +00:00
|
|
|
|
|
|
|
buildInputs =
|
2021-02-18 12:01:26 +00:00
|
|
|
lib.optionals (hsmSupport && stdenv.isLinux) [ pcsclite ]
|
|
|
|
++ lib.optionals (hsmSupport && stdenv.isDarwin) [ PCSC ];
|
2020-12-22 23:06:27 +00:00
|
|
|
|
2021-02-18 12:00:22 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace systemd/step-ca.service --replace "/bin/kill" "${coreutils}/bin/kill"
|
|
|
|
'';
|
|
|
|
|
2021-02-18 12:01:26 +00:00
|
|
|
preBuild = ''
|
|
|
|
${lib.optionalString (!hsmSupport) "export CGO_ENABLED=0"}
|
|
|
|
'';
|
|
|
|
|
2021-02-18 12:00:22 +00:00
|
|
|
postInstall = ''
|
|
|
|
install -Dm444 -t $out/lib/systemd/system systemd/step-ca.service
|
|
|
|
'';
|
|
|
|
|
2021-09-04 20:39:47 +00:00
|
|
|
# Tests start http servers which need to bind to local addresses:
|
|
|
|
# panic: httptest: failed to listen on a port: listen tcp6 [::1]:0: bind: operation not permitted
|
|
|
|
__darwinAllowLocalNetworking = true;
|
2019-12-12 04:38:15 +00:00
|
|
|
|
2021-11-12 20:37:11 +00:00
|
|
|
passthru.tests.step-ca = nixosTests.step-ca;
|
|
|
|
|
2019-12-12 04:38:15 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "A private certificate authority (X.509 & SSH) & ACME server for secure automated certificate management, so you can use TLS everywhere & SSO for SSH";
|
|
|
|
homepage = "https://smallstep.com/certificates/";
|
|
|
|
license = licenses.asl20;
|
2021-03-20 22:14:26 +00:00
|
|
|
maintainers = with maintainers; [ cmcdragonkai mohe2015 ];
|
2019-12-12 04:38:15 +00:00
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
|
|
|
};
|
|
|
|
}
|