Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / by-name / ca / caddy / package.nix
blobd6832d396c77347a382d32c292b9dc8e0826841e
1 { lib
2 , buildGoModule
3 , fetchFromGitHub
4 , nixosTests
5 , caddy
6 , testers
7 , installShellFiles
8 , stdenv
9 }:
10 let
11   version = "2.8.4";
12   dist = fetchFromGitHub {
13     owner = "caddyserver";
14     repo = "dist";
15     rev = "v${version}";
16     hash = "sha256-O4s7PhSUTXoNEIi+zYASx8AgClMC5rs7se863G6w+l0=";
17   };
19 buildGoModule {
20   pname = "caddy";
21   inherit version;
23   src = fetchFromGitHub {
24     owner = "caddyserver";
25     repo = "caddy";
26     rev = "v${version}";
27     hash = "sha256-CBfyqtWp3gYsYwaIxbfXO3AYaBiM7LutLC7uZgYXfkQ=";
28   };
30   vendorHash = "sha256-1Api8bBZJ1/oYk4ZGIiwWCSraLzK9L+hsKXkFtk6iVM=";
32   subPackages = [ "cmd/caddy" ];
34   ldflags = [
35     "-s" "-w"
36     "-X github.com/caddyserver/caddy/v2.CustomVersion=${version}"
37   ];
39   # matches upstream since v2.8.0
40   tags = [ "nobadger" ];
42   nativeBuildInputs = [ installShellFiles ];
44   postInstall = ''
45     install -Dm644 ${dist}/init/caddy.service ${dist}/init/caddy-api.service -t $out/lib/systemd/system
47     substituteInPlace $out/lib/systemd/system/caddy.service \
48       --replace-fail "/usr/bin/caddy" "$out/bin/caddy"
49     substituteInPlace $out/lib/systemd/system/caddy-api.service \
50       --replace-fail "/usr/bin/caddy" "$out/bin/caddy"
51   '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
52     # Generating man pages and completions fail on cross-compilation
53     # https://github.com/NixOS/nixpkgs/issues/308283
55     $out/bin/caddy manpage --directory manpages
56     installManPage manpages/*
58     installShellCompletion --cmd caddy \
59       --bash <($out/bin/caddy completion bash) \
60       --fish <($out/bin/caddy completion fish) \
61       --zsh <($out/bin/caddy completion zsh)
62   '';
64   passthru.tests = {
65     inherit (nixosTests) caddy;
66     version = testers.testVersion {
67       command = "${caddy}/bin/caddy version";
68       package = caddy;
69     };
70   };
72   meta = with lib; {
73     homepage = "https://caddyserver.com";
74     description = "Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS";
75     license = licenses.asl20;
76     mainProgram = "caddy";
77     maintainers = with maintainers; [ Br1ght0ne emilylange techknowlogick ];
78   };