projects involving the gemini protocol
{
  description = "Gemini projects";

  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
    naersk = {
      url = "github:nmattia/naersk";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    nixpkgs.url = "nixpkgs/nixpkgs-unstable";
  };

  outputs = { self, flake-utils, naersk, nixpkgs }:
    flake-utils.lib.eachDefaultSystem (system:

      let
        pkgs = nixpkgs.legacyPackages.${system};
        naersk-lib = naersk.lib.${system};
        libs = [ "gemini" ];
        apps = [
          "setka"
          # "sputnik"
          # "vostok"
        ];
        crates = libs ++ apps;
        build = f: crates:
          pkgs.lib.foldr (crate: set: set // { "${crate}" = f crate; }) { }
            crates;
      in
      with pkgs; rec {

        packages = build
          (crate:
            naersk-lib.buildPackage {
              pname = crate;
              root = ./.;
              src = ./. + "/${crate}";
            })
          crates;
        defaultPackage = packages.gemini;

        apps = build (crate: flake-utils.lib.mkApp { drv = packages.${crate}; })
          apps;
        # defaultApp = apps.vostok;

        devShell = mkShell {
          nativeBuildInputs = [
            rustc
            cargo
            clippy
            rustfmt
            rust-analyzer

            cargo-edit
            # cargo-watch # -- broken

            gnutar
            libiconv
          ];

          RUST_BACKTRACE = 1;
          RUST_LOG = "vostok=trace";
          RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
        };

      });
}