{
  inputs,
  flake,
  self,
  makeWrapper,
  cargo-leptos,
  binaryen,
  dart-sass,
  pkgs,
  config,
  system,
  openssl,
  pkg-config,
  ...
}: let
  src = ./.;
  cargoToml = inputs.util.lib.cargoToml;
  cargo = cargoToml src;
  craneLib = (inputs.crane.mkLib pkgs).overrideToolchain (self.lib.rustToolchain system);
  craneBuild = rec {
    args = {
      src = "${flake}";
      pname = cargo.package.name;
      version = cargo.package.version;
      buildInputs = [
        cargo-leptos
        binaryen
	dart-sass
	openssl
      ];
      nativeBuildInputs = [
        pkg-config
      ];
    };
    cargoArtifacts = craneLib.buildDepsOnly args;
    buildArgs = args // {
      inherit cargoArtifacts;
      buildPhaseCargoCommand = "cargo leptos build --release -vvv";
      cargoTestCommand = "cargo leptos test --release -vvv";
      nativeBuildInputs = args.nativeBuildInputs ++ [ makeWrapper ];
      installPhaseCommand = ''
        mkdir -p $out/bin
        cp target/release/${cargo.package.name} $out/bin/
        cp -r target/site $out/bin/
        wrapProgram $out/bin/${cargo.package.name} \
          --set LEPTOS_SITE_ROOT $out/bin/site
      '';
      doCheck = false;
      doNotPostBuildInstallCargoBinaries = true;
    };
    package = craneLib.buildPackage buildArgs;
  
    check = craneLib.cargoClippy (args // {
      inherit cargoArtifacts;
      cargoClippyExtraArgs = "--all-targets --all-features -- --deny warnings";
    });
  
    doc = craneLib.cargoDoc (args // {
      inherit cargoArtifacts;
    });
  };
in craneBuild.package
