main
  1{
  2  lib,
  3  stdenv,
  4  fetchFromGitHub,
  5  zellij,
  6  makeWrapper,
  7  installShellFiles,
  8  bash,
  9  coreutils,
 10  yazi ? null,
 11  nnn ? null,
 12  broot ? null,
 13  lf ? null,
 14  fff ? null,
 15  felix ? null,
 16  lazygit ? null,
 17}:
 18stdenv.mkDerivation (
 19  finalAttrs: {
 20    pname = "zide";
 21    version = "3.2.0";
 22    src = fetchFromGitHub {
 23      owner = "josephschmitt";
 24      repo = "zide";
 25      rev = "a0903f9a503f2261e768aa7c23628921c027a88e";
 26      sha256 = "0wlwywl5cai4b685il3hhk0wlmv31w4gwn0labn51hdmcwkg9sad";
 27    };
 28
 29    nativeBuildInputs = [
 30      makeWrapper
 31      installShellFiles
 32    ];
 33
 34    buildInputs = [
 35      bash
 36      coreutils
 37    ];
 38
 39    passthru = {
 40      defaultLayout = "default";
 41      defaultFilePicker = "yazi";
 42      layoutDir = null;
 43      alwaysName = false;
 44      useYaziConfig = true;
 45      useLfConfig = true;
 46    };
 47
 48    dontBuild = true;
 49
 50    installPhase = ''
 51      runHook preInstall
 52
 53      mkdir -p $out/share/zide
 54      mkdir -p $out/bin
 55
 56      cp -r . $out/share/zide/
 57
 58      for script in bin/zide bin/zide-pick bin/zide-edit bin/zide-rename; do
 59        if [[ -f "$script" ]]; then
 60          scriptName=$(basename "$script")
 61          makeWrapper "$out/share/zide/$script" "$out/bin/$scriptName" \
 62            --set ZIDE_DIR "$out/share/zide" \
 63            --prefix PATH : "${lib.makeBinPath (
 64        [
 65          zellij
 66          bash
 67          coreutils
 68        ]
 69        ++ lib.optional (yazi != null) yazi
 70        ++ lib.optional (nnn != null) nnn
 71        ++ lib.optional (broot != null) broot
 72        ++ lib.optional (lf != null) lf
 73        ++ lib.optional (fff != null) fff
 74        ++ lib.optional (felix != null) felix
 75        ++ lib.optional (lazygit != null) lazygit
 76      )}" \
 77            --set ZIDE_DEFAULT_LAYOUT "${finalAttrs.passthru.defaultLayout}" \
 78            --set ZIDE_FILE_PICKER "${finalAttrs.passthru.defaultFilePicker}" \
 79            ${lib.optionalString (finalAttrs.passthru.layoutDir != null)
 80        "--set ZIDE_LAYOUT_DIR \"${finalAttrs.passthru.layoutDir}\""} \
 81            ${lib.optionalString finalAttrs.passthru.alwaysName
 82        "--set ZIDE_ALWAYS_NAME \"true\""} \
 83            ${lib.optionalString (!finalAttrs.passthru.useYaziConfig)
 84        "--set ZIDE_USE_YAZI_CONFIG \"false\""} \
 85            ${lib.optionalString (!finalAttrs.passthru.useLfConfig)
 86        "--set ZIDE_USE_LF_CONFIG \"false\""}
 87        fi
 88      done
 89
 90
 91      chmod +x $out/bin/*
 92
 93      runHook postInstall
 94    '';
 95    meta = {
 96      description = "Group of configuration files and scripts to create an IDE-like experience in zellij";
 97      homepage = "https://github.com/josephschmitt/zide";
 98      license = lib.licenses.mit;
 99      maintainers = with lib.maintainers; [HPCesia];
100      platforms = lib.platforms.unix;
101      mainProgram = "zide";
102    };
103  }
104)