make vscode's configuration file writable at runtime

This commit is contained in:
Seaswimmer 2024-11-20 11:41:01 -05:00
parent 92ed8a4d48
commit 1ced704a40
Signed by: cswimr
GPG key ID: 0EC431A8DA8F8087

View file

@ -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 = { programs.vscode = {
enable = true; enable = true;
#package = pkgs.vscode.fhsWithPackages (ps: [ ]); package = pkgs.vscode.fhsWithPackages
(ps: with pkgs; [ dotnetCorePackages.sdk_8_0 mypy ]);
extensions = extensions =
with inputs.nix-vscode-extensions.extensions.${system}.vscode-marketplace; with inputs.nix-vscode-extensions.extensions.${system}.vscode-marketplace;
with inputs.nix-vscode-extensions.extensions.${system}.vscode-marketplace-release; [ with inputs.nix-vscode-extensions.extensions.${system}.vscode-marketplace-release; [
@ -140,6 +159,9 @@
d-koppenhagen.file-tree-to-text-generator d-koppenhagen.file-tree-to-text-generator
]; ];
userSettings = { 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" = { "editor.tokenColorCustomizations" = {
"[Catppuccin*]" = { "[Catppuccin*]" = {
"variables" = "#82eaf0"; "variables" = "#82eaf0";