{ pkgs, ... }:
let
  styleScript = pkgs.writeText "inject.js" ''
    ;(() => {
      const el = document.createElement('style')
      el.innerText = `
      .part.editor>.content .editor-group-container .editor-group-watermark .letterpress {
        background-image: url("https://file.mizuki.guru/.tesiotjosaeifjpoeawsjfnpoiawsejfopieawjfopjakweopfjawieof/IN_VISUAL_STUDIO_CODE.webp") !important;
        opacity: 1.0;
        overflow: visible;
        filter: none;
        aspect-ratio: 16 / 9 !important;
        max-height: fit-content !important;
      }
      `
      document.head.appendChild(el)
    })();
  '';
in
{
  programs.vscode = {
    enable = true;
    mutableExtensionsDir = true;
    userSettings = {
      "extensions.autoUpdate" = true;
    };
    package = (pkgs.vscode.override { isInsiders = true; }).overrideAttrs (oldAttrs: {
      version = "latest";

      src = builtins.fetchTarball {
        url = "https://code.visualstudio.com/sha/download?build=insider&os=linux-x64";
        sha256 = "0j21dnn1kj7gazyqiz9ip6qvpzi1zva33mf5l18ljv3sn34jgyzw";
      };

      buildInputs = oldAttrs.buildInputs ++ [
        pkgs.krb5
        pkgs.libsoup_3
        pkgs.webkitgtk_4_1
        pkgs.libxtst
        pkgs.libjpeg8
        pkgs.pipewire
        pkgs.libei
      ];

      postFixup = ''
        cat ${styleScript} >> $out/lib/vscode/resources/app/out/vs/code/electron-browser/workbench/workbench.js
      ''
      + (oldAttrs.postFixup or "");
    });
  };
}
