2022-09-22 02:12:25 +00:00
|
|
|
{ lib
|
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
|
|
|
, nixosTests
|
|
|
|
, caddy
|
|
|
|
, testers
|
|
|
|
, installShellFiles
|
2024-05-10 15:10:27 +00:00
|
|
|
, stdenv
|
2022-09-22 02:12:25 +00:00
|
|
|
}:
|
2021-11-29 14:16:25 +00:00
|
|
|
let
|
2023-12-08 22:38:30 +00:00
|
|
|
version = "2.7.6";
|
2021-11-29 14:16:25 +00:00
|
|
|
dist = fetchFromGitHub {
|
|
|
|
owner = "caddyserver";
|
|
|
|
repo = "dist";
|
|
|
|
rev = "v${version}";
|
2023-10-12 20:20:36 +00:00
|
|
|
hash = "sha256-aZ7hdAZJH1PvrX9GQLzLquzzZG3LZSKOvt7sWQhTiR8=";
|
2021-11-29 14:16:25 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
buildGoModule {
|
|
|
|
pname = "caddy";
|
|
|
|
inherit version;
|
2016-06-05 08:43:36 +00:00
|
|
|
|
2016-08-21 15:08:33 +00:00
|
|
|
src = fetchFromGitHub {
|
2019-09-23 03:22:22 +00:00
|
|
|
owner = "caddyserver";
|
2021-11-29 14:16:25 +00:00
|
|
|
repo = "caddy";
|
2016-09-21 16:52:17 +00:00
|
|
|
rev = "v${version}";
|
2023-12-08 22:38:30 +00:00
|
|
|
hash = "sha256-th0R3Q1nGT0q5PGOygtD1/CpJmrT5TYagrwQR4t/Fvg=";
|
2016-06-05 08:43:36 +00:00
|
|
|
};
|
|
|
|
|
2023-12-08 22:38:30 +00:00
|
|
|
vendorHash = "sha256-ebnSehuhbCY58ctM8IRVMfNxxbJBp6ht9cbuLdGFNek=";
|
2022-09-22 02:12:25 +00:00
|
|
|
|
|
|
|
subPackages = [ "cmd/caddy" ];
|
|
|
|
|
|
|
|
ldflags = [
|
|
|
|
"-s" "-w"
|
2022-10-13 19:14:42 +00:00
|
|
|
"-X github.com/caddyserver/caddy/v2.CustomVersion=${version}"
|
2022-09-22 02:12:25 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ installShellFiles ];
|
|
|
|
|
2021-11-29 14:16:25 +00:00
|
|
|
postInstall = ''
|
|
|
|
install -Dm644 ${dist}/init/caddy.service ${dist}/init/caddy-api.service -t $out/lib/systemd/system
|
|
|
|
|
2024-05-10 15:09:55 +00:00
|
|
|
substituteInPlace $out/lib/systemd/system/caddy.service \
|
|
|
|
--replace-fail "/usr/bin/caddy" "$out/bin/caddy"
|
|
|
|
substituteInPlace $out/lib/systemd/system/caddy-api.service \
|
|
|
|
--replace-fail "/usr/bin/caddy" "$out/bin/caddy"
|
2024-05-10 15:10:27 +00:00
|
|
|
'' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
|
|
|
|
# Generating man pages and completions fail on cross-compilation
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/308283
|
2022-09-22 02:12:25 +00:00
|
|
|
|
2023-02-19 16:44:35 +00:00
|
|
|
$out/bin/caddy manpage --directory manpages
|
|
|
|
installManPage manpages/*
|
|
|
|
|
2023-06-16 15:15:24 +00:00
|
|
|
installShellCompletion --cmd caddy \
|
2022-09-22 02:12:25 +00:00
|
|
|
--bash <($out/bin/caddy completion bash) \
|
2023-02-19 16:44:35 +00:00
|
|
|
--fish <($out/bin/caddy completion fish) \
|
2022-09-22 02:12:25 +00:00
|
|
|
--zsh <($out/bin/caddy completion zsh)
|
2021-11-29 14:16:25 +00:00
|
|
|
'';
|
|
|
|
|
2022-09-22 02:12:25 +00:00
|
|
|
passthru.tests = {
|
|
|
|
inherit (nixosTests) caddy;
|
|
|
|
version = testers.testVersion {
|
|
|
|
command = "${caddy}/bin/caddy version";
|
|
|
|
package = caddy;
|
|
|
|
};
|
|
|
|
};
|
2016-08-14 17:55:52 +00:00
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2019-12-02 14:18:23 +00:00
|
|
|
homepage = "https://caddyserver.com";
|
2023-02-09 02:31:08 +00:00
|
|
|
description = "Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS";
|
2016-09-21 16:52:17 +00:00
|
|
|
license = licenses.asl20;
|
2023-10-14 07:42:35 +00:00
|
|
|
mainProgram = "caddy";
|
2023-05-21 14:00:44 +00:00
|
|
|
maintainers = with maintainers; [ Br1ght0ne emilylange techknowlogick ];
|
2016-09-21 16:52:17 +00:00
|
|
|
};
|
2020-07-31 03:58:04 +00:00
|
|
|
}
|