with import <nixpkgs> {
  overlays = map (uri: import (fetchTarball uri)) [
    https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz
  ];
};

let geolite2 = pkgs.callPackage ./geolite2.nix { };
    rust = (rustChannelOf { channel = "stable"; }).rust;
    stripe = stdenv.mkDerivation rec {
      name = "stripe-${version}";
      version = "1.5.5";
      src = fetchurl {
        url = "https://github.com/stripe/stripe-cli/releases/download/v1.5.5/stripe_1.5.5_linux_x86_64.tar.gz";
        sha256 = "sha256-kss7cuLS2G7Z/OKBRh7/WNIcVW90Mplhj3elwThZ6KM=";
      };
      unpackPhase = "tar -xf ${src}";
      installPhase = "mkdir -p $out/bin; mv stripe $out/bin";
    };
in
clangStdenv.mkDerivation rec {
    name = "nest-env";
    buildInputs = [
      rust openssl pkg-config libsodium
      bison flex zstd xxHash
      llvmPackages.libclang.lib
      stripe
      dbmate
      sops age
      diesel-cli
      cargo-edit
    ];
    DIESEL_DATABASE_URL="postgres://postgres@localhost/pijul?sslmode=disable";
    LIBCLANG_PATH="${llvmPackages.libclang}/lib";
    DATABASE_URL="postgres://postgres@localhost/pijul?sslmode=disable";
    LOCAL_DATABASE_URL="postgres://postgres@/pijul-local?sslmode=disable&socket=/var/run/postgresql";
    LOCAL_DATABASE_URL2="postgres://postgres@/pijul-local2?sslmode=disable&socket=/var/run/postgresql";
    LOCAL_DATABASE_URL3="postgres://postgres@/pijul-local3?sslmode=disable&socket=/var/run/postgresql";
    PROTOC="${protobuf}/bin/protoc";
    ETCDCTL_API=3;
    GEOLITE2_PATH="${geolite2}/share/GeoLite2-City.mmdb";
}