{ inputs, flake, self }: { pkgs }: let
  system = pkgs.system;
  dev-help = pkgs.writeShellScriptBin "dev-help" /* sh */ ''
    printf '%s\n' \
    'dev-briefing - how to configure project first time' \
    'check        - run command remotely on vproxy and open answer in pager localy' \
    'cmd          - run command remotely on vproxy' \
    'run          - development runner for services' \
    ' ' \
    'dev-help     - this message'
  '';
  dev-briefing = pkgs.writeShellScriptBin "dev-briefing" /* sh */ ''
    printf '%s\n' \
    '1. you need vproxy ${pkgs.openssh}/bin/ssh config to use this tools' \
    '2. comming soon'
  '';
  check = pkgs.writeShellScriptBin "check" /* sh */ ''
      ${pkgs.openssh}/bin/ssh vproxy "$@" | ${pkgs.hectic.prettify-log}/bin/prettify-log --color-output | ${pkgs.hectic.nvim-pager}/bin/pager
  '';
  cmd = pkgs.writeShellScriptBin "cmd" /* sh */ ''
      ${pkgs.openssh}/bin/ssh vproxy "$@" 
  '';
  emojiSet = /* sh */ ''
    GIT_USER=$(${pkgs.git}/bin/git config user.name 2>/dev/null | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]//g')
    if [ -n "$GIT_USER" ]; then
      PROFILE="$GIT_USER"
    fi

    INFO_EM="";    SUCC_EM="";   WARN_EM="";    ERRO_EM="";   STEP_EM=""
  '';
  run = pkgs.writeShellScriptBin "run" /* sh */ ''
    set -a
    ${emojiSet}
    BIN_RSYNC=${pkgs.rsync}/bin/rsync
    BIN_SSH=${pkgs.openssh}/bin/ssh
    BIN_SCP=${pkgs.openssh}/bin/scp
    BIN_GIT=${pkgs.git}/bin/git
    REMOTE=''${REMOTE:-"lab"}
    set +a
    ${pkgs.bash}/bin/sh ${flake}/script/run.sh "$@"
  '';

  load-schema = pkgs.writeShellScriptBin "load-schema" /* sh */ ''
    set -a
    ${emojiSet}
    BIN_PG_DUMP=${pkgs.postgresql_15}/bin/pg_dump
    BIN_PSQL=${pkgs.postgresql_15}/bin/psql
    BIN_GIT=${pkgs.git}/bin/git
    set +a
    ${pkgs.bash}/bin/sh ${flake}/script/load-schema.sh "$@"
  '';
 
   deploy = pkgs.writeShellScriptBin "deploy" /* sh */ ''
    set -a
    ${emojiSet}
    BIN_GIT=${pkgs.git}/bin/git
    set +a
    ${pkgs.bash}/bin/sh ${flake}/script/deploy.sh "$@"
  '';
 
   # Determine if we're in remote mode (only need essentials)
   isRemoteMode = builtins.getEnv "VPROXY_REMOTE_MODE" == "1";
   
   # Minimal packages for remote development
   remotePackages = with pkgs; [
     git
     openssh 
     cargo-leptos
     dart-sass
     openssl
     rsync
     run
   ];
   
   # Full development packages
   fullPackages = 
   (with pkgs; [ 
     postgresql_15
     jq
     dos2unix 
     yq-go
     cargo-leptos
     cargo-cache
     cargo-generate
     cargo-expand
     binaryen
     openssl
     dart-sass
     entr
     inotify-tools
     trunk
     php
   ]) 
   ++ (with self.packages.${system}; [ ])
   ++ (with pkgs.hectic; [ 
     nvim-alias
     sops
   ]) 
   ++ [ 
     check 
     dev-help 
     dev-briefing
     cmd 
     deploy 
     load-schema
     run
     # suckless sqlite shell, atleast with history
     (pkgs.writeShellScriptBin "sqlite" ''
      ${pkgs.rlwrap}/bin/rlwrap ${pkgs.sqlite}/bin/sqlite3 "$@"
     '')
   ];
   pkgs-unstable = import inputs.nixpkgs-unstable { inherit system; };
in {
  default = pkgs.mkShell {
    nativeBuildInputs = [ (self.lib.rustToolchain system) pkgs.pkg-config ];
    buildInputs = if isRemoteMode then remotePackages else fullPackages;

    # environment
    PAGER = if isRemoteMode then "${pkgs.less}/bin/less" else "${pkgs.hectic.nvim-pager}/bin/pager";
  
    shellHook = if isRemoteMode then ''
      echo "🚀 Remote development mode loaded"
    '' else ''
      printf '🛠️  Vproxy development shell\n\n'
      ${dev-help}/bin/dev-help
    '';
  };
}
