{
  description = "horizon-haskell-packages";

  nixConfig = {
    extra-substituters = "https://horizon.cachix.org";
    extra-trusted-public-keys = "horizon.cachix.org-1:MeEEDRhRZTgv/FFGCv3479/dmJDfJ82G6kfUDxMSAw0=";
  };

  inputs = {
    flake-parts.url = "github:hercules-ci/flake-parts";
    horizon-core.url = "git+https://gitlab.horizon-haskell.net/package-sets/horizon-core";
    lint-utils = {
      url = "git+https://gitlab.nixica.dev/nix/lint-utils";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
  };

  outputs =
    inputs@
    { self
    , flake-parts
    , horizon-core
    , lint-utils
    , nixpkgs
    , ...
    }:
    flake-parts.lib.mkFlake { inherit inputs; } {
      systems = [
        "aarch64-darwin"
        "x86_64-darwin"
        "x86_64-linux"
      ];
      perSystem = { pkgs, system, ... }:
        with pkgs.writers;
        let

          make-foliage-repo = writeBashBin "make-foliage-repo" ''
            mkdir _keys
            echo "$FOLIAGE_KEYS" | base64 -d | tar xz -C _keys
            ${horizon-core.packages.${system}.foliage}/bin/foliage -- build
            ls _repo/* -alh
          '';

          make-foliage-repo-app = {
            type = "app";
            program = "${make-foliage-repo}/bin/make-foliage-repo";
          };

        in
        {

          apps = {

            default = make-foliage-repo-app;

          };

          checks =
            with lint-utils.outputs.linters.${system}; {
              nixpkgs-fmt = nixpkgs-fmt { src = self; };
            };

          packages.default = make-foliage-repo;

        };

    };
}