{
  pkgs ? import <nixpkgs> { },
  lib ? pkgs.lib,
  nix-unit ? pkgs.nix-unit,
}:

let
  legacyPackages = rec {
    inherit (pkgs.callPackage ./pkgs { }) wrapNeovimLazy lazyUtils luaUtils;
    neovim-lazy = wrapNeovimLazy pkgs.neovim-unwrapped { };
  };
in
{
  # https://github.com/NixOS/rfcs/pull/166
  formatter = pkgs.nixfmt-rfc-style;
  apps = {
    tests = {
      type = "app";
      program =
        (pkgs.writeScript "nix-unit" ''
          #!/usr/bin/env bash
          TEST_TARGET="tests''${1:+.}''${1}";
          ${nix-unit}/bin/nix-unit --flake ".#''${TEST_TARGET}";
        '').outPath;
    };
  };

  inherit legacyPackages;
  packages = lib.filterAttrs (name: value: lib.isDerivation value) legacyPackages;
}