{
  lib,
  stdenv,
  fetchFromGitLab,
  writeText,
  nixosTests,
}:

let
  localConfig = writeText "config.local.php" ''
    <?php
      return require(getenv('JIRAFEAU_CONFIG'));
    ?>
  '';
in
stdenv.mkDerivation rec {
  pname = "jirafeau";
  version = "4.7.1";

  src = fetchFromGitLab {
    owner = "jirafeau";
    repo = "Jirafeau";
    rev = version;
    hash = "sha256-jXUO+tj6VFNjJkT0vkCCtG7yNWf3QeCx7izZPekAng8=";
  };

  installPhase = ''
    mkdir $out
    cp -r * $out/
    cp ${localConfig} $out/lib/config.local.php
  '';

  passthru.tests = { inherit (nixosTests) jirafeau; };

  meta = {
    description = "Jirafeau: a simple way to upload a file";
    homepage = "https://gitlab.com/jirafeau/Jirafeau";
    changelog = "https://gitlab.com/jirafeau/Jirafeau/-/blob/${src.rev}/CHANGELOG.md";
    license = lib.licenses.agpl3Plus;
    mainProgram = "jirafeau";
    platforms = lib.platforms.all;
  };
}
