From 72eb82b6872a135673aae5fc0cd2359e67687165 Mon Sep 17 00:00:00 2001 From: Johan Thomsen Date: Fri, 24 Aug 2018 11:54:21 +0200 Subject: [PATCH 1/3] certmgr: Add patch for optional trust of self-signed certificates at remote cfssl apiserver --- pkgs/tools/security/certmgr/default.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/security/certmgr/default.nix b/pkgs/tools/security/certmgr/default.nix index fa3076e8b593..28cdcfdad084 100644 --- a/pkgs/tools/security/certmgr/default.nix +++ b/pkgs/tools/security/certmgr/default.nix @@ -1,4 +1,4 @@ -{ stdenv, buildGoPackage, fetchFromGitHub }: +{ stdenv, buildGoPackage, fetchFromGitHub, fetchpatch }: buildGoPackage rec { version = "1.6.1"; @@ -13,6 +13,16 @@ buildGoPackage rec { sha256 = "1ky2pw1wxrb2fxfygg50h0mid5l023x6xz9zj5754a023d01qqr2"; }; + # The following patch makes it possible to use a self-signed x509 cert + # for the cfssl apiserver. + # TODO: remove patch when PR is merged. + patches = [ + (fetchpatch { + url = "https://github.com/cloudflare/certmgr/pull/51.patch"; + sha256 = "0jhsw159d2mgybvbbn6pmvj4yqr5cwcal5fjwkcn9m4f4zlb6qrs"; + }) + ]; + meta = with stdenv.lib; { homepage = https://cfssl.org/; description = "Cloudflare's certificate manager"; From 016128dd93eb6dd7689a37333432a60502bf9899 Mon Sep 17 00:00:00 2001 From: Franz Pletz Date: Thu, 24 Jan 2019 12:10:33 +0100 Subject: [PATCH 2/3] certmgr: move selfsigned patch into a separate attribute --- pkgs/tools/security/certmgr/default.nix | 60 ++++++++++++++----------- pkgs/top-level/all-packages.nix | 3 +- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/pkgs/tools/security/certmgr/default.nix b/pkgs/tools/security/certmgr/default.nix index 28cdcfdad084..4a9cd4867da6 100644 --- a/pkgs/tools/security/certmgr/default.nix +++ b/pkgs/tools/security/certmgr/default.nix @@ -1,33 +1,43 @@ { stdenv, buildGoPackage, fetchFromGitHub, fetchpatch }: -buildGoPackage rec { - version = "1.6.1"; - name = "certmgr-${version}"; +let + generic = { patches ? [] }: + buildGoPackage rec { + version = "1.6.1"; + name = "certmgr-${version}"; - goPackagePath = "github.com/cloudflare/certmgr/"; + goPackagePath = "github.com/cloudflare/certmgr/"; - src = fetchFromGitHub { - owner = "cloudflare"; - repo = "certmgr"; - rev = "v${version}"; - sha256 = "1ky2pw1wxrb2fxfygg50h0mid5l023x6xz9zj5754a023d01qqr2"; - }; + src = fetchFromGitHub { + owner = "cloudflare"; + repo = "certmgr"; + rev = "v${version}"; + sha256 = "1ky2pw1wxrb2fxfygg50h0mid5l023x6xz9zj5754a023d01qqr2"; + }; - # The following patch makes it possible to use a self-signed x509 cert - # for the cfssl apiserver. - # TODO: remove patch when PR is merged. - patches = [ - (fetchpatch { - url = "https://github.com/cloudflare/certmgr/pull/51.patch"; - sha256 = "0jhsw159d2mgybvbbn6pmvj4yqr5cwcal5fjwkcn9m4f4zlb6qrs"; - }) - ]; + inherit patches; - meta = with stdenv.lib; { - homepage = https://cfssl.org/; - description = "Cloudflare's certificate manager"; - platforms = platforms.linux; - license = licenses.bsd2; - maintainers = with maintainers; [ johanot srhb ]; + meta = with stdenv.lib; { + homepage = https://cfssl.org/; + description = "Cloudflare's certificate manager"; + platforms = platforms.linux; + license = licenses.bsd2; + maintainers = with maintainers; [ johanot srhb ]; + }; + }; +in +{ + certmgr = generic {}; + + certmgr-selfsigned = generic { + # The following patch makes it possible to use a self-signed x509 cert + # for the cfssl apiserver. + # TODO: remove patch when PR is merged. + patches = [ + (fetchpatch { + url = "https://github.com/cloudflare/certmgr/pull/51.patch"; + sha256 = "0jhsw159d2mgybvbbn6pmvj4yqr5cwcal5fjwkcn9m4f4zlb6qrs"; + }) + ]; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 556dfcf0c040..987b712c8a80 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1877,7 +1877,8 @@ in }; ceph-dev = ceph; - certmgr = callPackage ../tools/security/certmgr { }; + inherit (callPackages ../tools/security/certmgr { }) + certmgr certmgr-selfsigned; cfdg = callPackage ../tools/graphics/cfdg { ffmpeg = ffmpeg_2; From 4602b43a33a98d31f29a2928da58559444ebfdb6 Mon Sep 17 00:00:00 2001 From: Franz Pletz Date: Thu, 24 Jan 2019 12:11:15 +0100 Subject: [PATCH 3/3] certmgr service: add package option --- nixos/modules/services/security/certmgr.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/security/certmgr.nix b/nixos/modules/services/security/certmgr.nix index 22d5817ec4f0..e89078883ebe 100644 --- a/nixos/modules/services/security/certmgr.nix +++ b/nixos/modules/services/security/certmgr.nix @@ -30,13 +30,20 @@ let preStart = '' ${concatStringsSep " \\\n" (["mkdir -p"] ++ map escapeShellArg specPaths)} - ${pkgs.certmgr}/bin/certmgr -f ${certmgrYaml} check + ${cfg.package}/bin/certmgr -f ${certmgrYaml} check ''; in { options.services.certmgr = { enable = mkEnableOption "certmgr"; + package = mkOption { + type = types.package; + default = pkgs.certmgr; + defaultText = "pkgs.certmgr"; + description = "Which certmgr package to use in the service."; + }; + defaultRemote = mkOption { type = types.str; default = "127.0.0.1:8888"; @@ -187,7 +194,7 @@ in serviceConfig = { Restart = "always"; RestartSec = "10s"; - ExecStart = "${pkgs.certmgr}/bin/certmgr -f ${certmgrYaml}"; + ExecStart = "${cfg.package}/bin/certmgr -f ${certmgrYaml}"; }; }; };