# This file defines overlays
{
  # This one brings our custom packages from the 'pkgs' directory
  additions = final: _prev: import ../pkgs { pkgs = final; };

  # This one contains whatever you want to overlay
  # You can change versions, add patches, set compilation flags, anything really.
  # https://nixos.wiki/wiki/Overlays
  modifications = final: prev: {
    calibre-web = prev.calibre-web.overrideAttrs (prevAttrs: rec {
      propagatedBuildInputs = prevAttrs.propagatedBuildInputs ++ [ final.python3.pkgs.jsonschema ]; # allow kobo sync stuff
    });
    mautrix-signal = prev.mautrix-signal.overrideAttrs (prevAttrs: rec {
      buildInputs = prevAttrs.propagatedBuildInputs ++ [ final.python3.pkgs.aiosqlite ]; # We're using sqlite and upstream doesn't package this dependency
    });

    wallabag = prev.wallabag.overrideAttrs (attrs: {
      patches = builtins.filter (patch: builtins.baseNameOf patch != "wallabag-data.patch") attrs.patches ++ [
        # Out of the box, Wallabag wants to write to various subdirectories of the project directory.
        # Let’s replace references to such paths with designated systemd locations
        # so that the project source can remain immutable.
        ../pkgs/wallabag-data.patch
      ];
    });

    # Need to do server and agent too, maybe
    # woodpecker-cli-next = 
    # let
    #   common = prev.callPackage "${inputs.unstable}/pkgs/development/tools/continuous-integration/woodpecker/common.nix" { };
    # in
    # (prev.buildGoModule rec {
    #   pname = "woodpecker-cli";
    #   version = "next-${inputs.woodpecker.shortRev}";
    #   src = inputs.woodpecker;
    #   vendorSha256 = "sha256-8st1LdgrQQqEZ6oSBm/nE1WI/v7NI+f56qZJySJIFJw=";
    #   inherit (common) postBuild;

    #   subPackages = "cmd/cli";

    #   ldflags = [
    #     "-s"
    #     "-w"
    #     "-X github.com/woodpecker-ci/woodpecker/version.Version=${version}"
    #   ];

    #   CGO_ENABLED = 0;

    #   meta = common.meta // {
    #     description = "Command line client for the Woodpecker Continuous Integration server";
    #   };
    # });

    # example = prev.example.overrideAttrs (oldAttrs: rec {
    # ...
    # });
  };
}
