{ stdenv, fetchFromGitHub, fetchgit, cmake, lib  }:
let
  ls = "ls -alR";
in
stdenv.mkDerivation rec {
  pname = "polycat";
  version = "1.2.0";  # replace with actual version if applicable

  src = fetchgit {
    # owner = "2IMT";
    # repo = "polycat";
    # rev = "main";  # or a specific commit/tag
    # fetchSubmodules = true;
    # deepClone = true;
    # leaveDotGit = false;
    url = "https://github.com/2IMT/polycat.git";
    hash = "sha256-wpDx6hmZe/dLv+F+kbo+YUIZ2A8XgnrZP0amkz6I5IQ=";  # replace this with the correct sha256 for the download
  };

  nativeBuildInputs = [ cmake ];

  # argparse = fetchFromGitHub {
  #   owner = "p-ranav";
  #   repo = "argparse";
  #   rev = "v2.9";  # Replace with the version needed by polycat
  #   sha256 = "1wdpy45qcipfyw9bbr9s42v67b88bkyniy76yvh0grp2wf8zidxx";  # Replace with correct hash
  # };

  # unpackPhase = ''
  #   cp -r ${src} ./source
  # '';

  # sourceRoot = "./source";

   # Use this phase to link the argparse dependency
  # patchPhase = ''
  #   # If the `argparse` dependency isn’t fetched automatically, fetch it here
  #   if [ ! -d dep/argparse ]; then
  #     mkdir -p dep/argparse
  #     cp -r ${fetchFromGitHub {
  #       owner = "p-ranav";
  #       repo = "argparse";
  #       rev = "v2.9";
  #       sha256 = "1wdpy45qcipfyw9bbr9s42v67b88bkyniy76yvh0grp2wf8zidxx";  # Replace with actual hash
  #     }}/* dep/argparse
  #   fi
  # '';


  # Unpack and link argparse manually
  # unpackPhase = ''
  #   # Unpack main source
  #   runHook preUnpack
  #   tar xzf ${src} --strip-components=1
  #   runHook postUnpack

  #   # Unpack argparse and link it
  #   mkdir -p dep
  #   tar xzf ${argparse} -C dep --strip-components=1
  #   ln -s ${argparse} dep/argparse
  # '';

   # Skip the problematic updateAutotoolsGnuConfigScriptsPhase
  configurePhase = ''
    # mkdir -p build
    # cd polycat
    echo ls .
    cmake -DCMAKE_BUILD_TYPE=Release .
  '';

  buildPhase = ''
    # mkdir -p build
    # cd build
    # cmake -DCMAKE_BUILD_TYPE=Release .
    cmake --build .
  '';

  installPhase = ''
    mkdir -p $out/bin
    cp polycat $out/bin/
  '';

  meta = with lib; {
    description = "runcat module for polybar (or waybar).";
    license = licenses.mit;  # Replace with correct license
    maintainers = with maintainers; [ "2IMT" ];
  };
}
