#──────────────────────────────────────────────────────────────────────────────┐
# SPDX-FileCopyrightText: 2026 toastal <https://toast.al/contact/>             │
# SPDX-License-Identifier: MPL-2.0                                             │
#──────────────────────────────────────────────────────────────────────────────┘
{
   lib,
   stdenvNoCC,
   nickel,
}:

stdenvNoCC.mkDerivation {
   pname = "funding.json.ncl";
   version = "1.0.0";

   _structuredAttrs = true;

   src = let
      fs = lib.fileset;
   in
   fs.toSource {
      root = ../..;
      fileset = fs.unions [
         ../../main.ncl
         ../../lib
      ];
   };

   strictDeps = true;

   nativeCheckInputs = [
      nickel
   ];

   dontBuild = true;
   doCheck = true;

   checkPhase = ''
      runHook preCheck

      nickel typecheck main.ncl

      runHook postCheck
   '';

   installPhase = ''
      runHook preInstall

      mkdir -p "$out"
      cp -r *.ncl lib/ "$out/"

      runHook postInstall
   '';

   meta = {
      license = with lib.licenses; [ mpl20 ];
      homepage = "https://pijul.toastal.in.th/funding.json.ncl";
      donationPage = "https://toast.al/funding/";
   };
}
