nixos/legacy_modules/apps/vscode.nix

163 lines
4.8 KiB
Nix
Raw Normal View History

2025-02-18 20:17:57 +01:00
{
pkgsUnstable,
pkgs,
inputs,
2025-03-09 19:05:43 +01:00
config,
2025-02-18 20:17:57 +01:00
lib,
...
}: let
2025-05-20 19:25:57 +02:00
vscodePackage = pkgsUnstable.vscode;
2025-04-07 08:56:37 +02:00
2025-03-07 10:12:35 +01:00
vscode-extensions = inputs.nix-vscode-extensions.extensions.${pkgs.system};
vscodePkgs = vscode-extensions.vscode-marketplace // vscode-extensions.vscode-marketplace-release; # Prefer release over pre-release
2025-02-18 20:17:57 +01:00
mkFormatter = formatter: languages: {
"[${lib.concatStringsSep "][" languages}]" = {
2025-02-19 23:42:24 +01:00
"editor.defaultFormatter" = formatter;
2025-02-18 20:17:57 +01:00
};
};
2025-03-07 10:12:35 +01:00
2025-08-21 10:31:50 +02:00
mkMcpStdio = {
name,
command,
env ? {},
}: let
2025-05-21 08:21:28 +02:00
# If any of the envs values starts with ${input:...}, then we should create a new password input
envValues = lib.attrValues env;
inputEnvs = lib.filter (value: lib.hasPrefix "\${input:" value) envValues;
2025-08-21 10:31:50 +02:00
# Get the ids of the inputs
2025-05-21 08:21:28 +02:00
inputEnvsIds = lib.map (value: lib.substring 8 (lib.stringLength value - 9) value) inputEnvs;
in {
mcp = {
2025-08-21 10:31:50 +02:00
inputs =
lib.map (value: {
"type" = "promptString";
"id" = value; # Assigning the name as the id
"description" = "Enter the password for ${value}";
"password" = true;
})
inputEnvsIds;
2025-05-21 08:21:28 +02:00
servers."${name}" = {
"type" = "stdio";
"command" = builtins.elemAt command 0;
"args" = builtins.tail command;
"env" = env;
};
};
};
2025-03-07 10:12:35 +01:00
# I can't get nix-vscode-extensions to respect allowUnfree, so this is a workaround
allowUnfree = ext: ext.override {meta.license = [];};
2025-02-18 20:17:57 +01:00
in {
fireproof.home-manager = {
programs.vscode = {
enable = true;
package = vscodePackage;
2025-05-20 19:25:57 +02:00
profiles.default = {
enableUpdateCheck = true;
enableExtensionUpdateCheck = true;
keybindings = [
{
"key" = "ctrl+shift+p";
"command" = "editor.action.formatDocument";
}
];
userSettings = lib.mkMerge [
{
# General
"extensions.ignoreRecommendations" = true;
"telemetry.telemetryLevel" = "off";
# Editor
"editor.linkedEditing" = true;
"files.exclude" = {
"**/*.egg-info" = true;
"**/__pycache__" = true;
};
2025-05-21 08:21:28 +02:00
"workbench.editor.wrapTabs" = true;
2025-05-20 19:25:57 +02:00
# Files
"files.autoSave" = "afterDelay";
# Remote
"remote.SSH.useLocalServer" = false;
"remote.SSH.remotePlatform" = lib.mapAttrs (_name: _value: "linux") config.fireproof.home-manager.programs.ssh.matchBlocks;
# AI
"github.copilot.enable" = {
"*" = true;
"plaintext" = true;
"markdown" = true;
"scminput" = true;
};
"chat.agent.enabled" = true;
"github.copilot.chat.agent.thinkingTool" = true;
"github.copilot.chat.codesearch.enabled" = true;
"github.copilot.nextEditSuggestions.enabled" = true;
2025-09-15 12:21:26 +02:00
"githubPullRequests.codingAgent.uiIntegration" = true;
2025-05-20 19:25:57 +02:00
# Theme
"workbench.colorTheme" = "Darcula Theme from IntelliJ";
"window.titleBarStyle" = "custom";
"editor.fontFamily" = "'Hack Nerd Font', 'Hack', 'monospace', monospace";
# Keybindings
"workbench.commandPalette.experimental.suggestCommands" = true; # Emulates IntelliJ's "Search Everywhere"
# nix-ide
"nix.enableLanguageServer" = true;
"nix.serverPath" = lib.getExe pkgs.nil;
"nix.serverSettings" = {
nil.formatting.command = ["nix" "fmt" "--" "--"];
};
}
(mkFormatter "esbenp.prettier-vscode" ["json" "jsonc" "markdown" "css" "scss" "typescript" "typescriptreact" "html" "yaml"])
(mkFormatter "charliermarsh.ruff" ["python"])
2025-09-15 12:21:26 +02:00
# TODO: Enable when switching to 25.11
# (mkMcpStdio {
# name = "linear";
# command = ["npx" "mcp-remote" "https://mcp.linear.app/sse"];
# })
# (mkMcpStdio {
# name = "sentry";
# command = ["npx" "mcp-remote" "https://mcp.sentry.dev/sse"];
# })
2025-05-20 19:25:57 +02:00
];
extensions = with vscodePkgs; [
2025-02-18 20:17:57 +01:00
# Remote
2025-05-20 19:25:57 +02:00
(allowUnfree ms-vscode-remote.remote-ssh)
2025-02-18 20:17:57 +01:00
# AI
2025-05-20 19:25:57 +02:00
(allowUnfree github.copilot)
(allowUnfree github.copilot-chat)
# Git(hub)
github.vscode-pull-request-github
# Python
ms-pyright.pyright
ms-python.python
charliermarsh.ruff
# JavaScript
dbaeumer.vscode-eslint
esbenp.prettier-vscode
# Nix
jnoortheen.nix-ide
# Other languages
nefrob.vscode-just-syntax
redhat.vscode-yaml
2025-02-18 20:17:57 +01:00
# Theme
2025-05-20 19:25:57 +02:00
trinm1709.dracula-theme-from-intellij
2025-02-18 20:17:57 +01:00
# Keybindings
2025-05-20 19:25:57 +02:00
k--kato.intellij-idea-keybindings
];
};
2025-02-18 20:17:57 +01:00
};
};
}