<@if(neq(context.project.frontend,"none"))>
    bundev = {
      exec = "bun dev";
      cwd = "./apps/web";
      after= ["devenv:processes:air@started"];
    };
    <@endif>{ pkgs, lib, config, inputs, ... }:

{
  packages = [
     pkgs.bun
     pkgs.nodejs_24
     pkgs.watchexec
     pkgs.sqlc
     pkgs.dbmate
     pkgs.air
     pkgs.buf
     pkgs.protoc-gen-go
     pkgs.protoc-gen-connect-go
     pkgs.protoc-gen-es
     pkgs.cobra-cli
     <@if(eq(context.project.mobile,"expo"))>
     pkgs.glib
     <@endif>
  ];
  <@if(eq(context.project.mobile,"expo"))>
  android = {
    enable = true;
    emulator = {
      enable = true;
    };
    buildTools.version = ["34.0.0" "35.0.0" "36.0.0" ];  # add 36.0.0
    reactNative.enable = true;
    android-studio = {
      enable = false;
    };
    ndk = {
      enable = true;
      version = [ "27.1.12297006" ];
    };
  };
 <@endif>
  languages.go.enable = true;
  languages.typescript.enable = true;
  services.postgres = {
    enable = true;
    listen_addresses = "127.0.0.1";
    initialDatabases = [
      {
        name = "<@var(context.project.name)>";
        user = "pp";
        pass = "<@var(context.project.name)>";
      }
    ];
  };
  <@if(eq(context.project.mobile,"expo"))>
  enterShell = ''
    export LD_LIBRARY_PATH=$ANDROID_HOME/emulator/lib64:$LD_LIBRARY_PATH
  '';
  tasks.'<@var(context.project.name)>:create-avd'.exec = ''
    avdmanager create avd
    -n "Pixel_5_API34"
    -k "system-images;android-34;google_apis_playstore;x86_64"
    -d "pixel_5"
  '';
  tasks.'<@var(context.project.name)>:run-emulator' = {
    exec = "emulator -avd Pixel_5_API34";
    after = [ "<@var(context.project.name)>:create-avd" ]
  };
  <@endif>
  processes = {
    air = {
      exec = "air";
      cwd = "./services/api";
      after = ["devenv:processes:postgres"];
    };
    protowatcher = {
      exec = "watchexec -r -e proto buf generate";
      cwd = "./packages/proto";
      after= ["devenv:processes:air@started"];
    };
    protojswatcher = {
      exec = "watchexec -e js,ts -w ./packages/rpc/src -r bun run ./scripts/gen-rpc-index.ts";
      cwd = "./";
      after= ["devenv:processes:protowatcher@started"];
    };
    sqlwatcher = {
      exec = "watchexec -w ./db/migrations -w ./db/query -r -e sql sqlc generate";
      cwd = "./services/api";
      after= ["devenv:processes:air@started"];
    };
    <@if(eq(context.project.mobile,"expo"))>
    emulator = {
      exec
    }
    <@endif>
    
  };
}
