From 1ced704a405cdb486f00741b1b6ece7d52ab8cb3 Mon Sep 17 00:00:00 2001 From: cswimr Date: Wed, 20 Nov 2024 11:41:01 -0500 Subject: [PATCH] make vscode's configuration file writable at runtime --- home-manager/vscode.nix | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/home-manager/vscode.nix b/home-manager/vscode.nix index bc4b753..650b923 100644 --- a/home-manager/vscode.nix +++ b/home-manager/vscode.nix @@ -1,7 +1,26 @@ -{ pkgs, system, inputs, ... }: { +{ pkgs, config, system, inputs, ... }: rec { + + # Make VSCode config writable + # https://github.com/nix-community/home-manager/issues/1800#issuecomment-2262881846 + home.activation.makeVSCodeConfigWritable = let + configDirName = { + "vscode" = "Code"; + "vscode-insiders" = "Code - Insiders"; + "vscodium" = "VSCodium"; + }.${programs.vscode.package.pname}; + configPath = "${config.xdg.configHome}/${configDirName}/User/settings.json"; + in { + after = [ "writeBoundary" ]; + before = [ ]; + data = '' + install -m 0640 "$(readlink ${configPath})" ${configPath} + ''; + }; + programs.vscode = { enable = true; - #package = pkgs.vscode.fhsWithPackages (ps: [ ]); + package = pkgs.vscode.fhsWithPackages + (ps: with pkgs; [ dotnetCorePackages.sdk_8_0 mypy ]); extensions = with inputs.nix-vscode-extensions.extensions.${system}.vscode-marketplace; with inputs.nix-vscode-extensions.extensions.${system}.vscode-marketplace-release; [ @@ -140,6 +159,9 @@ d-koppenhagen.file-tree-to-text-generator ]; userSettings = { + "DO-NOT-EDIT-1" = "This file is managed by the Nix module located at `/etc/nixos/home-manager/vscode.nix`."; + "DO-NOT-EDIT-2" = "Changes will be overwritten when VSCode is restarted."; + "DO-NOT-EDIT-3" = "To persist changes, edit the module and run `upd` in your terminal."; "editor.tokenColorCustomizations" = { "[Catppuccin*]" = { "variables" = "#82eaf0";