From 87810a6c2f8ec43b1170e9abb311b3bcf3fb4bb2 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Wed, 21 Sep 2022 22:12:25 -0400 Subject: [PATCH] caddy: 2.6.0 -> 2.6.1 --- pkgs/servers/caddy/default.nix | 40 ++++++++++++++++++++++---- pkgs/servers/caddy/inject_version.diff | 15 ++++++++++ 2 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 pkgs/servers/caddy/inject_version.diff diff --git a/pkgs/servers/caddy/default.nix b/pkgs/servers/caddy/default.nix index f30515766a74..51088486809a 100644 --- a/pkgs/servers/caddy/default.nix +++ b/pkgs/servers/caddy/default.nix @@ -1,6 +1,13 @@ -{ lib, buildGoModule, fetchFromGitHub, nixosTests }: +{ lib +, buildGoModule +, fetchFromGitHub +, nixosTests +, caddy +, testers +, installShellFiles +}: let - version = "2.6.0"; + version = "2.6.1"; dist = fetchFromGitHub { owner = "caddyserver"; repo = "dist"; @@ -12,25 +19,46 @@ buildGoModule { pname = "caddy"; inherit version; - subPackages = [ "cmd/caddy" ]; - src = fetchFromGitHub { owner = "caddyserver"; repo = "caddy"; rev = "v${version}"; - sha256 = "sha256-BZGfYpQM5e+/LrGqs1oms/vOp9q4UY/ZyDODEsi/wl8="; + sha256 = "sha256-Z8MiMhXH1er+uYvmDQiamF/jSxHbTMwjo61qbH0ioEo="; }; vendorSha256 = "sha256-6UTErIPB/z4RfndPSLKFJDFweLB3ax8WxEDA+3G5asI="; + patches = [ + ./inject_version.diff + ]; + + subPackages = [ "cmd/caddy" ]; + + ldflags = [ + "-s" "-w" + "-X github.com/caddyserver/caddy/v2.ShortVersion=${version}" + ]; + + nativeBuildInputs = [ installShellFiles ]; + postInstall = '' install -Dm644 ${dist}/init/caddy.service ${dist}/init/caddy-api.service -t $out/lib/systemd/system substituteInPlace $out/lib/systemd/system/caddy.service --replace "/usr/bin/caddy" "$out/bin/caddy" substituteInPlace $out/lib/systemd/system/caddy-api.service --replace "/usr/bin/caddy" "$out/bin/caddy" + + installShellCompletion --cmd metal \ + --bash <($out/bin/caddy completion bash) \ + --zsh <($out/bin/caddy completion zsh) ''; - passthru.tests = { inherit (nixosTests) caddy; }; + passthru.tests = { + inherit (nixosTests) caddy; + version = testers.testVersion { + command = "${caddy}/bin/caddy version"; + package = caddy; + }; + }; meta = with lib; { homepage = "https://caddyserver.com"; diff --git a/pkgs/servers/caddy/inject_version.diff b/pkgs/servers/caddy/inject_version.diff new file mode 100644 index 000000000000..3636f026a77a --- /dev/null +++ b/pkgs/servers/caddy/inject_version.diff @@ -0,0 +1,15 @@ +diff --git a/caddy.go b/caddy.go +index 584865bd..082b9b6c 100644 +--- a/caddy.go ++++ b/caddy.go +@@ -840,7 +840,10 @@ func InstanceID() (uuid.UUID, error) { + // and https://github.com/golang/go/issues/50603. + // + // This function is experimental and subject to change or removal. ++var ShortVersion = "(devel)" ++ + func Version() (simple, full string) { ++ return ShortVersion, ShortVersion + // the currently-recommended way to build Caddy involves + // building it as a dependency so we can extract version + // information from go.mod tooling; once the upstream \ No newline at end of file