nixpkgs/pkgs/by-name/ca/caddy/package.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

77 lines
2.0 KiB
Nix
Raw Normal View History

2022-09-22 02:12:25 +00:00
{ lib
, buildGoModule
, fetchFromGitHub
, nixosTests
, caddy
, testers
, installShellFiles
, stdenv
2022-09-22 02:12:25 +00:00
}:
let
version = "2.7.6";
dist = fetchFromGitHub {
owner = "caddyserver";
repo = "dist";
rev = "v${version}";
hash = "sha256-aZ7hdAZJH1PvrX9GQLzLquzzZG3LZSKOvt7sWQhTiR8=";
};
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";
repo = "caddy";
2016-09-21 16:52:17 +00:00
rev = "v${version}";
hash = "sha256-th0R3Q1nGT0q5PGOygtD1/CpJmrT5TYagrwQR4t/Fvg=";
2016-06-05 08:43:36 +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 ];
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-fail "/usr/bin/caddy" "$out/bin/caddy"
substituteInPlace $out/lib/systemd/system/caddy-api.service \
--replace-fail "/usr/bin/caddy" "$out/bin/caddy"
'' + 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)
'';
2022-09-22 02:12:25 +00:00
passthru.tests = {
inherit (nixosTests) caddy;
version = testers.testVersion {
command = "${caddy}/bin/caddy version";
package = caddy;
};
};
meta = with lib; {
2019-12-02 14:18:23 +00:00
homepage = "https://caddyserver.com";
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;
mainProgram = "caddy";
maintainers = with maintainers; [ Br1ght0ne emilylange techknowlogick ];
2016-09-21 16:52:17 +00:00
};
}