diff options
| author | Fuwn <[email protected]> | 2024-10-07 20:56:10 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-10-07 20:56:10 -0700 |
| commit | bfba0a8f07020f01d68770a8c8933bbc80ac1843 (patch) | |
| tree | 6323d40100b123e01fa80c77d05129865d08d45e /pkgs | |
| parent | containers: bring up dozzle (diff) | |
| download | nixos-config-bfba0a8f07020f01d68770a8c8933bbc80ac1843.tar.xz nixos-config-bfba0a8f07020f01d68770a8c8933bbc80ac1843.zip | |
server: use caddy-tailscale
Diffstat (limited to 'pkgs')
| -rw-r--r-- | pkgs/caddy-tailscale.nix | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/pkgs/caddy-tailscale.nix b/pkgs/caddy-tailscale.nix new file mode 100644 index 0000000..7ee29bd --- /dev/null +++ b/pkgs/caddy-tailscale.nix @@ -0,0 +1,87 @@ +{ + lib, + buildGoModule, + fetchFromGitHub, + nixosTests, + caddy, + testers, + installShellFiles, + stdenv, +}: +let + version = "2.8.4"; + dist = fetchFromGitHub { + owner = "caddyserver"; + repo = "dist"; + rev = "v${version}"; + hash = "sha256-O4s7PhSUTXoNEIi+zYASx8AgClMC5rs7se863G6w+l0="; + }; +in +buildGoModule { + pname = "caddy"; + version = "c357e484b153daf7000ec5dc64a06c704d500d26"; + + src = fetchFromGitHub { + owner = "tailscale"; + repo = "caddy-tailscale"; + rev = version; + hash = "sha256-/UIQiT7IpPmD/7bzI8a50po9Y/IYV8W4Ycl3yqa5wj8="; + }; + + vendorHash = "sha256-x6A59S6ySK5Ws+H45O6aO0VahQxy2mPt7cnEMtHTmQ8="; + + subPackages = [ "cmd/caddy" ]; + + ldflags = [ + "-s" + "-w" + "-X github.com/caddyserver/caddy/v2.CustomVersion=${version}" + ]; + + # matches upstream since v2.8.0 + tags = [ "nobadger" ]; + + 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 + + $out/bin/caddy manpage --directory manpages + installManPage manpages/* + + installShellCompletion --cmd caddy \ + --bash <($out/bin/caddy completion bash) \ + --fish <($out/bin/caddy completion fish) \ + --zsh <($out/bin/caddy completion zsh) + ''; + + passthru.tests = { + inherit (nixosTests) caddy; + version = testers.testVersion { + command = "${caddy}/bin/caddy version"; + package = caddy; + }; + }; + + meta = with lib; { + homepage = "https://caddyserver.com"; + description = "Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS"; + license = licenses.asl20; + mainProgram = "caddy"; + maintainers = with maintainers; [ + Br1ght0ne + emilylange + techknowlogick + ]; + }; +} |