vscode-with-extensions.overrideAttrs overrideAttrs to get kubectl recognized

  • system: "x86_64-linux"
  • host os: Linux 6.1.31, NixOS, 23.05 (Stoat), 23.05.419.3a70dd92993
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.13.3
  • channels(root): "nixgl, nixos-23.05, nixos-hardware"
  • channels(usera): ""
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

following Combining override and overrideAttrs - #12 by NobbZ

at runtime, I try to get

  • ms-kubernetes-tools.vscode-kubernetes-tools
    working, which tells me that kubectl is missing

Add ‘kubectl’ directory to path, or set “vs-kubernetes.kubectl-path” config to kubectl binary.

without effect:

( (vscode-with-extensions.overrideAttrs (oldAttrs: rec {            
            buildInputs = oldAttrs.buildInputs ++ [ pkgs.kubectl  ];
        .override {
            vscodeExtensions =   with pkgs.vscode-extensions; [ ms-kubernetes-tools.vscode-kubernetes-tools

This snippet gives me an error that vscodeExtensions isn’t defined, can you please provide a self-contained example that can be built and shows exactly your problem?

Also can you please elaborate if the error about the mising kubectl happens during build or during runtime of VScode? If it is the latter, just add kubectl to your environment.systemPackages/home.packages. The VScode buildscript doesn’t use kubectl in anyway and will therefore discard the given buildtime dependency for runtime.

If you want to create a selfcontained VScode that comes with its own kubectl, you need to “wrap” vscode, which I would probably do in another derivation, rather than through an override.

One example of a wrapper that adds to an environment variable can be seen in my configuration for gnucash. Be aware that this is one of the first wrappers I wrote and today I would probably use a symlinkJoin rather than runCommand.

Thanks for you reply
it’s runtime related and so I have to see what I can do with the wrapper

  • trying to put it not directly into environment.systemPackages