3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/tools/security/step-ca/default.nix
ckie 72bd24702b
step-ca: fix flaky test parallelism
step-ca seems to run some tests using the global `localhost` interface
inside the build sandbox, and on big x86_64-linux machines we've
observed they occasionally fail.

This restricts the tests to one core.

https://hydra.nixos.org/build/206729862
2023-01-25 16:45:34 +02:00

62 lines
1.7 KiB
Nix

{ stdenv
, lib
, fetchFromGitHub
, buildGoModule
, coreutils
, pcsclite
, PCSC
, pkg-config
, hsmSupport ? true
, nixosTests
}:
buildGoModule rec {
pname = "step-ca";
version = "0.23.1";
src = fetchFromGitHub {
owner = "smallstep";
repo = "certificates";
rev = "v${version}";
sha256 = "sha256-zIF7R0zIoqQx0epTJAVdesT6IOoNek7Blt7W3Ulng4A=";
};
vendorHash = "sha256-JX5jUIMwd+eCYRytaf+EXV/xHh6CCS2Ia0K+UQZxG7E=";
ldflags = [ "-buildid=" ];
nativeBuildInputs = lib.optionals hsmSupport [ pkg-config ];
buildInputs =
lib.optionals (hsmSupport && stdenv.isLinux) [ pcsclite ]
++ lib.optionals (hsmSupport && stdenv.isDarwin) [ PCSC ];
postPatch = ''
substituteInPlace systemd/step-ca.service --replace "/bin/kill" "${coreutils}/bin/kill"
'';
preBuild = ''
${lib.optionalString (!hsmSupport) "export CGO_ENABLED=0"}
'';
postInstall = ''
install -Dm444 -t $out/lib/systemd/system systemd/step-ca.service
'';
# 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;
# Tests need to run in a reproducible order, otherwise they run unreliably on
# (at least) x86_64-linux.
checkFlags = [ "-p 1" ];
passthru.tests.step-ca = nixosTests.step-ca;
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;
maintainers = with maintainers; [ cmcdragonkai mohe2015 techknowlogick ];
};
}