Vscode with extensions and settings using home-manager

Has anyone got an example of using vscode with extensions and settings using home-manager?

vscode-with-extensions doesn’t include settings as far as I could see, so I thought I’d try home manager’s vscode but for some reason it doesn’t seem to be linking code.

Would love it if someone could share their config (via github?)?

(I’m wondering is if there’s a way to consolidate all our configs so that we could search through all the nix examples that people have. Hmm, maybe a git repo with many submodules… I really need to see lots of examples of how other people nix.)

1 Like

I must have an example in here:

So thomashoneyman’s configuration was great starter for vscode in home manager and this script is excellent: https://github.com/NixOS/nixpkgs/blob/42d815d1026e57f7e6f178de5a280c14f7aba1a5/pkgs/misc/vscode-extensions/update_installed_exts.sh

(though I did remove the error handling because I didn’t want it to stop if it got a 404)

But for extensions like CodeLLDB that try and download a native extension they trip over everything being read only. Not sure what the nicest way to handle that is. Maybe they need to be specifically repackaged? I’m not sure I can see any alternative…

This would all just work if the extensions dir wasn’t a read only file system…

1 Like

Same kind of issues here, i get

Error: EROFS: read-only file system, open '/home/jlucas/.config/Code/User/settings.json'

and

EROFS: read-only file system, open '/nix/store/ligj18a3amxv34fb9hliklcp8jahnb03-vscode-extensions-1.41.0/share/vscode/extensions/alanz.vscode-hie-server/package.json'

while trying to follow this tutorial https://nokomprendo.gitlab.io/posts/tuto_fonctionnel_42/2019-12-22-en-README.html

if it was mutable, then it wouldn’t be reproducible

2 Likes

settings are through the userSettings attr set:

       programs.vscode.userSettings
           Configuration written to Visual Studio Code's settings.json.

           Type: attribute set

           Default: { }

           Example:

               {
                 "update.channel" = "none";
                 "[nix]"."editor.tabSize" = 2;
               }
1 Like

Having used it for a while now I really don’t think locking down settings.json is a great idea. It would be better to pull in a settings file from somewhere else, but for now I’ve just wrapped my settings as an extension which then sets them on startup if they’re not already set. ( It’s called correct.defaults ). That way I have some canned settings and I am also free to tinker.

The extensions works well with home manager using this script to capture the ones I like:

Now if I could only get codelldb to behave I’d be in a good place.