# SPDX-FileCopyrightText: 2025 toastal <toastal@posteo.net>
# SPDX-License-Identifier: MPL-2.0
final: prev: {
  tup = prev.tup.overrideAttrs (
    finalAttrs: prevAttrs: {
      version = "0.8.0+2024-06-06";
      src = final.fetchzip {
        url = "https://github.com/gittup/tup/archive/4247a523587df54bd4a65ec42c4247a8488c050e.tar.gz";
        hash = "sha256-vHzfUf7O7DoiuyxCu/zpXmQcqcyBOJoF5UM4CTtB1B8=";
      };
      patches = (prevAttrs.patches or [ ]) ++ [
        (final.fetchpatch {
          url = "https://github.com/toastal/tup/commit/3efa5912dd2a81a4ce999950a6a0a0b3a5f7ceb4.patch";
          hash = "sha256-PaMUQadhBeGmgIZMO7OcSVCCgoHl3jcAeyjOEvYml9w=";
        })
        (final.fetchpatch {
          url = "https://github.com/toastal/tup/commit/ca3e97764b83537d192833ca78ce9dcae5d8d15a.patch";
          hash = "sha256-tpGqd37uCRq0aKuIhg1R6wI5UFRAYQ1u4VzYs2sNSgo=";
        })
        (final.fetchpatch {
          url = "https://github.com/toastal/tup/commit/7d4954dd1fc0cab638c711aaa7e834e8798083e3.patch";
          hash = "sha256-FdupkfjcfuYgadnYVF9BE5fUnoX3/bq75C+Ibxdftds=";
        })
      ];
    }
  );

  w3m-site_dev-shell = final.mkShellNoCC {
    name = "w3m-site";
    inputsFrom = with final; [
      w3m-site
      w3m-site_assets
      w3m-site_scripts
    ];
    packages = with final; [
      nickel
      nixfmt-rfc-style
      topiary
      watchexec
      w3m-site_scripts
    ];
    env = {
      NICKEL_IMPORT_PATH = "${../../ncl}";
      TOPIARY_CONFIG_FILE = "${../../.topiary.ncl}";
      BROWSERSLIST_CONFIG = "${../../.browserslistrc}";
    };
    shellHook = ''
      export SOUPAULT_BUILD_DIR="$PWD/build";
      export ASSETS_DIR="$SOUPAULT_BUILD_DIR/assets";
    '';
  };
}
