I’ve been moving my development environments from being built in and around docker, to nix shells built with devenv. Everything’s working out great so far, but the only thing I’m having difficulty with is building a custom caddy binary with certain modules enabled.
In the docker world I’d put something like this in my Dockerfile:
RUN xcaddy build \
--with github.com/dunglas/mercure \
--with github.com/dunglas/mercure/caddy
But… Where do I put it? Putting it in a devenv.nix file won’t work, as that’s not a flake, so I think I have two options:
Convert devenv.nix into a flake.nix
Start my own caddy repository, add a flake file and add that one as input, so that I can use that caddy package instead of the default one
I think I like option two a bit more, as it’s easier to reuse in various situations and also, more in line with the nix philosophy, but it feels kind of silly to start a repository with basically a flake.nix and flake.lock file.
Does anyone have any pointers on how to proceed? Any help would be greatly appreciated
Unfortunately I don’t think devenv allows you to overwrite the pkgs argument globally without calling it from a flake.nix, but you should be able to locally extend the pkgs with your overlay like so
# devenv.nix
{pkgs, ...}:
let extendedPkgs = pkgs.extend (final: prev: {/* your overlay */});
in {
# Your devenv stuff
# ...
services.caddy.package = extendedPkgs.caddy;
# Optionally
packages = [ extendedPkgs.caddy ];
}
although you wouldn’t really need an overlay for that.
This should work too
# devenv.nix
{pkgs, ...}:
let myCaddy = with pkgs; stdenv.mkDerivation rec {/* your caddy definition */};
in {
# Your devenv stuff
# ...
services.caddy.package = myCaddy;
# Optionally
packages = [ myCaddy ];
}