在 Nixos 中配置 vscode

在 Nixos 中配置 vscode

我的 Nixos 使用 tmpfs 作为根文件系统,我想在 Home Manager 中配置 VSCode。我想问一下,VSCode应该保留哪些文件或文件夹?

vscode.nix:

{ pkgs
, ...
} @ args:

{
  programs.vscode = {
    enable = true;
    package = pkgs.vscode;
    userSettings = {
    
      ##### VsCode Settings #####
      ## Commonly Used
      "files.autoSave" = "onFocusChange";
      "editor.fontSize" = 14;
      "editor.fontFamily" = "'Droid Sans Mono', 'monospace', monospace";
      "editor.tabSize" = 4;
      "editor.renderWhitespace" = "selection";
      "editor.cursorStyle" = "line";
      "editor.multiCursorModifier" = "alt";
      "editor.insertSpaces" = true;
      "editor.wordWrap" = "off";
      "files.exclude" = {
        "**/.git" = true;
        "**/.svn" = true;
        "**/.hg" = true;
        "**/CVS" = true;
        "**/.DS_Store" = true;
        "**/Thumbs.db" = true;
      };
      "files.associations" = { };
      "workbench.editor.enablePreview" = true;

      ## Text Editor


      ## WorkBench
      "workbench.colorTheme" = "Default Dark+";
      "workbench.startupEditor" = "none";

      ## Window
      "window.autoDetectColorScheme" = false;

      ## Features
      #### Explorer
      "explorer.confirmDelete" = false;
      "explorer.confirmDragAndDrop" = false;
      "explorer.enableDragAndDrop" = false;

      ## Application
      #### Update
      "update.mode" = "none";
      "update.showReleaseNotes" = false;

      ## Security
      #### Workspace
      "security.workspace.trust.enabled" = false;
      "security.workspace.trust.startupPrompt" = "never";
      "security.workspace.trust.emptyWindow" = false;
      "security.workspace.trust.untrustedFiles" = "open";
      "security.workspace.trust.banner" = "never";

      ## Extensions
      #### Copilot
      "github.copilot.advanced" = { };
      "github.copilot.editor.enableAutoCompletions" = true;
      "github.copilot.enable" = {
        "*" = true;
        "plaintext" = false;
        "markdown" = false;
        "scminput" = false;
        "yaml" = false;
        "python" = true;
        "javascript" = true;
      };
      #### NixIDE
      "nix.enableLanguageServer" = true;
      "nix.formatterPath" = "nixpkgs-fmt";
      "nix.serverPath" = "nixd";
      "nix.serverSettings" = {
        "nixd" = {
          "eval" = { };
          "formatting" = {
            "command" = "nixpkgs-fmt";
          };
          "options" = {
            "enable" = true;
            "target" = {
              "args" = [ ];
              ## NixOS options
              # "installable" = "<flakeref>#nixosConfigurations.<name>.options";
              ## Flake-parts options
              # "installable" = "<flakeref>#debug.options";
              ## Home-manager options
              # "installable" = "<flakeref>#homeConfigurations.<name>.options";
            };
          };
        };
      };

    };
    extensions = with pkgs.vscode-extensions; [
      # Github Copilot
      github.copilot
      # Nix Language
      jnoortheen.nix-ide
    ];
  };

  home.packages = with pkgs;[
    # Nix Language
    nixd
    nixpkgs-fmt
  ];

  # Impermanence Persistent For VsCode
  home.persistence."/nix/persistent${config.home.homeDirectory}" = {
    directories = [
      ".config/Code/User"
    ];
    files = [

    ];
    allowOther = false;
    removePrefixDirectory = false;
  };

}


对于保存插件登录状态的文件,比如github.copilot,重启后当前配置会失效,需要重新登录。我需要做什么?如何维持这些状态呢?

相关内容