Unable to build Caddy with custom modules

TLDR: The files I’m using to attempt to build this are in this gist (I can post them directly here if that’s the preferred approach).

I’m attempting to build this with the command nix-build ./build_caddy.nix
The error message is

install: cannot stat '/nix/store/krcc44294g624jah0vf778czc4j3dxk5-source/init/caddy.service': No such file or directory
install: cannot stat '/nix/store/krcc44294g624jah0vf778czc4j3dxk5-source/init/caddy-api.service': No such file or directory
build failed in installPhase with exit code 1

Any ideas what I’m doing wrong?

I’ve been trying to build a custom package for the Caddy Web Server. I’m running on NixOS 21.11, and wanted to use the latest version of Caddy 2.5.1.

I saw that a derivation for 2.5.1 exists in nixos-unstable. So I started with copying this over to see I could build a package with it. I quickly discovered that the newer version of Caddy requires Go 1.17+, so I switched over to using buildGo117Module instead of buildGoModule.

I was also trying to add some custom plugins to Caddy, and plugins in caddy are added by compiling a version with the plugins added as imports. I found this blog post which led me to most of my derivation. It builds on work from @diamondburned and @phaer that’s seen in this comment.

However my attempt at building this seems to fail, apparently in the installation of the systemd unit files based on the error message at the top of this post.

I tried using the breakpointHook, but I wasn’t able to see the init files, and I’m not sure if that’s an artifact of breakpointHook or if it’s a problem with the build.


Hosted by Flying Circus.