home/vscode: add timer for extension updates
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.programs.vscode;
|
||||
in
|
||||
{
|
||||
# TODO: add `dirname` to $PATH upstream
|
||||
systemd.user.services.update-vscode-extensions = {
|
||||
Unit = {
|
||||
Description = "Update vscode extensions";
|
||||
};
|
||||
|
||||
Service = {
|
||||
Type = "oneshot";
|
||||
CPUSchedulingPolicy = "idle";
|
||||
IOSchedulingClass = "idle";
|
||||
ExecStart = "${lib.getExe cfg.package} --update-extensions";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.timers.update-vscode-extensions = {
|
||||
Unit = {
|
||||
Description = "Update vscode extensions";
|
||||
};
|
||||
|
||||
Timer = {
|
||||
Unit = "update-vscode-extensions.service";
|
||||
OnCalendar = "daily";
|
||||
Persistent = true;
|
||||
};
|
||||
|
||||
Install = {
|
||||
WantedBy = [ "timers.target" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,380 @@
|
||||
{ pkgs, lib, config, ... }:
|
||||
let
|
||||
cfg = config.programs.vscode;
|
||||
|
||||
mapPrefixToSet = prefix: set:
|
||||
with lib; attrsets.mapAttrs' (k: v: attrsets.nameValuePair ("${prefix}.${k}") v) set;
|
||||
|
||||
configDir = {
|
||||
"vscode" = "Code";
|
||||
"vscode-insiders" = "Code - Insiders";
|
||||
"vscodium" = "VSCodium";
|
||||
}.${cfg.package.pname};
|
||||
userDir = "${config.xdg.configHome}/${configDir}/User";
|
||||
configFilePath = "${userDir}/settings.json";
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./auto-update-extensions.nix
|
||||
# ./extensions
|
||||
];
|
||||
|
||||
home.file.${configFilePath} = {
|
||||
target = "${configFilePath}.ro";
|
||||
onChange = ''install -m660 $(realpath "${configFilePath}.ro") "${configFilePath}"'';
|
||||
};
|
||||
|
||||
programs.vscode ={
|
||||
enable = true;
|
||||
|
||||
package = pkgs.vscode;
|
||||
|
||||
userSettings = let
|
||||
editor = mapPrefixToSet "editor" {
|
||||
fontFamily = "Fira Code";
|
||||
fontLigatures = true;
|
||||
lineNumbers = "relative";
|
||||
mouseWheelZoom = false;
|
||||
fontSize = 14;
|
||||
"minimap.enabled" = false;
|
||||
tabSize = 2;
|
||||
insertSpaces = true;
|
||||
"inlineSuggest.enabled" = true;
|
||||
"inlayHints.enabled" = "offUnlessPressed";
|
||||
detectIndentation = false;
|
||||
tabCompletion = "onlySnippets";
|
||||
snippetSuggestions = "top";
|
||||
cursorBlinking = "smooth";
|
||||
cursorSmoothCaretAnimation = "on";
|
||||
multiCursorModifier = "ctrlCmd";
|
||||
suggestSelection = "first";
|
||||
cursorStyle = "line";
|
||||
wordSeparators = "/\\()\"':,.;<>~!@#$%^&*|+=[]{}`?-";
|
||||
wordWrap = "off";
|
||||
# "bracketPairColorization.enabled" = true;
|
||||
};
|
||||
|
||||
zen = mapPrefixToSet "zenMode" {
|
||||
centerLayout = true;
|
||||
hideStatusBar = false;
|
||||
hideLineNumbers = false;
|
||||
};
|
||||
|
||||
vim = mapPrefixToSet "vim" {
|
||||
useSystemClipboard = true;
|
||||
"statusBarColorControl" = true;
|
||||
"statusBarColors.insert" = "#20ff00";
|
||||
"statusBarColors.normal" = "#1D1E20";
|
||||
"statusBarColors.visual" = "#00ffff";
|
||||
"statusBarColors.replace" = "#ff002b";
|
||||
handleKeys = {
|
||||
"<C-d>" = true;
|
||||
"<C-j>" = false;
|
||||
"<C-b>" = false;
|
||||
"<C-k>" = false;
|
||||
"<C-w>" = false;
|
||||
"<C-n>" = false;
|
||||
"<A-o>" = true;
|
||||
};
|
||||
};
|
||||
|
||||
workbench = mapPrefixToSet "workbench" {
|
||||
"settings.enableNaturalLanguageSearch" = false;
|
||||
enableExperiments = false;
|
||||
iconTheme = "material-icon-theme";
|
||||
colorTheme = "Monokai ST3";
|
||||
colorCustomizations = {
|
||||
"statusBar.background" = "#1D1E20";
|
||||
"statusBar.noFolderBackground" = "#1D1E20";
|
||||
"statusBar.debuggingBackground" = "#1D1E20";
|
||||
"[Monokai ST3]" = {
|
||||
"editor.foreground" = "#ffffff";
|
||||
};
|
||||
};
|
||||
editorAssociations = {
|
||||
"*.pdf" = "default";
|
||||
"*.ipynb" = "jupyter.notebook.ipynb";
|
||||
};
|
||||
};
|
||||
|
||||
python = mapPrefixToSet "python" {
|
||||
"analysis.completeFunctionParens" = true;
|
||||
"formatting.provider" = "yapf";
|
||||
"formatting.yapfArgs" = [
|
||||
"--style={based_on_style: pep8, indent_width: 2}"
|
||||
];
|
||||
"autoComplete.addBrackets" = true;
|
||||
languageServer = "Pylance";
|
||||
};
|
||||
|
||||
svg = mapPrefixToSet "svgviewer" {
|
||||
transparencygrid = true;
|
||||
enableautopreview = true;
|
||||
previewcolumn = "Beside";
|
||||
showzoominout = true;
|
||||
};
|
||||
|
||||
indentRainbow = mapPrefixToSet "indentRainbow" {
|
||||
errorColor= "rgb(255, 0, 0)";
|
||||
colors = [ # http://colrd.com/palette/38436/
|
||||
"rgba(26, 19, 52, 0.1)"
|
||||
"rgba(1, 84, 90, 0.1)"
|
||||
"rgba(3, 195, 131, 0.1)"
|
||||
"rgba(251, 191, 69, 0.1)"
|
||||
"rgba(237, 3, 69, 0.1)"
|
||||
"rgba(113, 1, 98, 0.1)"
|
||||
"rgba(2, 44, 125, 0.1)"
|
||||
"rgba(38, 41, 74, 0.1)"
|
||||
"rgba(1, 115, 81, 0.1)"
|
||||
"rgba(170, 217, 98, 0.1)"
|
||||
"rgba(239, 106, 50, 0.1)"
|
||||
"rgba(161, 42, 94, 0.1)"
|
||||
];
|
||||
ignoreErrorLanguages = [
|
||||
"markdown"
|
||||
"haskell"
|
||||
"elm"
|
||||
"fsharp"
|
||||
"java"
|
||||
];
|
||||
};
|
||||
|
||||
in
|
||||
editor //
|
||||
indentRainbow //
|
||||
python //
|
||||
svg //
|
||||
workbench //
|
||||
vim // # This needs to come after workbench because of setting ordering
|
||||
zen //
|
||||
{
|
||||
"extensions.autoCheckUpdates" = false;
|
||||
"extensions.autoUpdate" = false;
|
||||
"diffEditor.ignoreTrimWhitespace" = false;
|
||||
"diffEditor.hideUnchangedRegions" = "enabled";
|
||||
"emmet.triggerExpansionOnTab" = true;
|
||||
"explorer.confirmDragAndDrop" = false;
|
||||
"git.allowForcePush" = true;
|
||||
"git.autofetch" = true;
|
||||
"telemetry.telemetryLevel" = "off";
|
||||
"terminal.integrated.fontSize" = 14;
|
||||
"vsintellicode.modify.editor.suggestSelection" = "automaticallyOverrodeDefaultValue";
|
||||
"window.zoomLevel" = 1;
|
||||
|
||||
"search.exclude" = {
|
||||
"**/node_modules" = true;
|
||||
"**/bower_components" = true;
|
||||
"**/*.code-search" = true;
|
||||
"**/.direnv/" = true;
|
||||
};
|
||||
|
||||
# This setting does not support language overrides
|
||||
"files.exclude" = {
|
||||
# Java
|
||||
"**/.classpath" = true;
|
||||
"**/.project" = true;
|
||||
"**/.settings" = true;
|
||||
"**/.factorypath" = true;
|
||||
};
|
||||
|
||||
# Extensions
|
||||
|
||||
"bracket-pair-colorizer-2.colorMode" = "Consecutive";
|
||||
"bracket-pair-colorizer-2.forceIterationColorCycle" = true;
|
||||
"bracket-pair-colorizer-2.colors" = [
|
||||
"#fff200"
|
||||
"#3d33ff"
|
||||
"#ff57d5"
|
||||
"#00ff11"
|
||||
"#ff8400"
|
||||
"#ff0030"
|
||||
];
|
||||
|
||||
"errorLens.errorBackground" = "rgba(240,0,0,0.1)";
|
||||
"errorLens.warningBackground" = "rgba(180,180,0,0.1)";
|
||||
|
||||
"keyboard-quickfix.showActionNotification" = false;
|
||||
|
||||
"liveshare.presence" = true;
|
||||
"liveshare.showInStatusBar" = "whileCollaborating";
|
||||
|
||||
"liveServer.settings.port" = 5500;
|
||||
|
||||
"material-icon-theme.folders.associations" = {
|
||||
ui = "layout";
|
||||
bloc = "controller";
|
||||
};
|
||||
|
||||
"redhat.telemetry.enabled" = false;
|
||||
|
||||
"[html]" = {
|
||||
"editor.formatOnSave" = false;
|
||||
"editor.defaultFormatter" = "vscode.html-language-features";
|
||||
};
|
||||
|
||||
"[javascript]" = {
|
||||
"editor.formatOnSave" = false;
|
||||
"editor.defaultFormatter" = "vscode.typescript-language-features";
|
||||
};
|
||||
|
||||
"[json]" = {
|
||||
"editor.formatOnSave" = true;
|
||||
"editor.defaultFormatter" = "vscode.json-language-features";
|
||||
};
|
||||
|
||||
"[jsonc]" = {
|
||||
"editor.defaultFormatter" = "vscode.json-language-features";
|
||||
};
|
||||
};
|
||||
|
||||
keybindings = [
|
||||
{
|
||||
key = "ctrl+[Period]";
|
||||
command = "keyboard-quickfix.openQuickFix";
|
||||
when = "editorHasCodeActionsProvider && editorTextFocus && !editorReadonly";
|
||||
}
|
||||
|
||||
{
|
||||
key = "alt+k";
|
||||
command = "selectPrevSuggestion";
|
||||
when = "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus";
|
||||
}
|
||||
|
||||
{
|
||||
key = "alt+j";
|
||||
command = "selectNextSuggestion";
|
||||
when = "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus";
|
||||
}
|
||||
|
||||
{
|
||||
key = "alt+k";
|
||||
command = "editor.action.moveLinesUpAction";
|
||||
when = "editorTextFocus && !editorReadonly && !suggestWidgetVisible";
|
||||
}
|
||||
|
||||
{
|
||||
key = "alt+j";
|
||||
command = "editor.action.moveLinesDownAction";
|
||||
when = "editorTextFocus && !editorReadonly && !suggestWidgetVisible";
|
||||
}
|
||||
|
||||
{
|
||||
key = "alt+j";
|
||||
command = "workbench.action.quickOpenNavigateNext";
|
||||
when = "inQuickOpen";
|
||||
}
|
||||
|
||||
{
|
||||
key = "alt+k";
|
||||
command = "workbench.action.quickOpenNavigatePrevious";
|
||||
when = "inQuickOpen";
|
||||
}
|
||||
|
||||
{
|
||||
key = "alt+f";
|
||||
command = "editor.action.formatDocument";
|
||||
when = "editorTextFocus && !editorReadonly";
|
||||
}
|
||||
|
||||
{
|
||||
key = "alt+o";
|
||||
command = "editor.action.insertLineAfter";
|
||||
when = "textInputFocus && !editorReadonly";
|
||||
}
|
||||
|
||||
{
|
||||
key = "alt+shift+o";
|
||||
command = "editor.action.insertLineBefore";
|
||||
when = "textInputFocus && !editorReadonly";
|
||||
}
|
||||
];
|
||||
|
||||
extensions = with pkgs.vscode-extensions; [
|
||||
# WakaTime.vscode-wakatime
|
||||
# dotjoshjohnson.xml
|
||||
# eamodio.gitlens
|
||||
# jock.svg
|
||||
# ms-azuretools.vscode-docker
|
||||
# ms-toolsai.jupyter
|
||||
ms-vscode-remote.remote-ssh
|
||||
# ms-vsliveshare.vsliveshare
|
||||
bbenoist.nix
|
||||
christian-kohler.path-intellisense
|
||||
# coenraads.bracket-pair-colorizer-2
|
||||
haskell.haskell
|
||||
justusadam.language-haskell
|
||||
justusadam.language-haskell
|
||||
mechatroner.rainbow-csv
|
||||
mhutchie.git-graph
|
||||
ms-python.python
|
||||
ms-python.vscode-pylance
|
||||
ms-vscode-remote.remote-ssh
|
||||
naumovs.color-highlight
|
||||
oderwat.indent-rainbow
|
||||
pkief.material-icon-theme
|
||||
redhat.vscode-yaml
|
||||
shardulm94.trailing-spaces
|
||||
usernamehw.errorlens
|
||||
rust-lang.rust-analyzer
|
||||
mkhl.direnv
|
||||
waderyan.gitblame
|
||||
# vs-liveshare
|
||||
vscodevim.vim
|
||||
] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [
|
||||
{
|
||||
name = "monokai-st3";
|
||||
publisher = "AndreyVolosovich";
|
||||
version = "0.2.0";
|
||||
sha256 = "1rvz5hlrfshy9laybxzvrdklx328s13j0lb8ljbda9zkadi3wcad";
|
||||
}
|
||||
{
|
||||
name = "vscode-svgviewer";
|
||||
publisher = "cssho";
|
||||
version = "2.0.0";
|
||||
sha256 = "06swlqiv3gc7plcbmzz795y6zwpxsdhg79k1n3jj6qngfwnv2p6z";
|
||||
}
|
||||
{
|
||||
name = "comment-anchors";
|
||||
publisher = "ExodiusStudios";
|
||||
version = "1.10.3";
|
||||
sha256 = "sha256-IyiiS4jpcghwKI0j8s69uGNZlKnZ0o78ZCT0oZeJER0=";
|
||||
}
|
||||
{
|
||||
name = "vscode-test-explorer";
|
||||
publisher = "hbenl";
|
||||
version = "2.21.1";
|
||||
sha256 = "022lnkq278ic0h9ggpqcwb3x3ivpcqjimhgirixznq0zvwyrwz3w";
|
||||
}
|
||||
{
|
||||
name = "vscode-gutter-preview";
|
||||
publisher = "kisstkondoros";
|
||||
version = "0.29.0";
|
||||
sha256 = "00vibv9xmhwaqiqzp0y2c246pqiqfjsw4bqx4vcdd67pz1wnqhg1";
|
||||
}
|
||||
{
|
||||
name = "test-adapter-converter";
|
||||
publisher = "ms-vscode";
|
||||
version = "0.1.9";
|
||||
sha256 = "sha256-M53jhAVawk2yCeSrLkWrUit3xbDc0zgCK2snbK+BaSs=";
|
||||
}
|
||||
# {
|
||||
# name = "indent-rainbow";
|
||||
# publisher = "oderwat";
|
||||
# version = "8.2.2";
|
||||
# sha256 = "1xxljwh66f21fzmhw8icrmxxmfww1s67kf5ja65a8qb1x1rhjjgf";
|
||||
# }
|
||||
{
|
||||
name = "vscodeintellicode";
|
||||
publisher = "VisualStudioExptTeam";
|
||||
version = "1.2.30";
|
||||
sha256 = "sha256-f2Gn+W0QHN8jD5aCG+P93Y+JDr/vs2ldGL7uQwBK4lE=";
|
||||
}
|
||||
{
|
||||
name = "keyboard-quickfix";
|
||||
publisher = "pascalsenn";
|
||||
version = "0.0.6";
|
||||
sha256 = "BK7ND6gtRVEitxaokJHmQ5rvSOgssVz+s9dktGQnY6M=";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
void syslog(int priority, const char *format, ...) { }
|
||||
@@ -0,0 +1,117 @@
|
||||
# Based on previous attempts:
|
||||
# - <https://github.com/msteen/nixos-vsliveshare/blob/master/pkgs/vsliveshare/default.nix>
|
||||
# - <https://github.com/NixOS/nixpkgs/issues/41189>
|
||||
{ lib, gccStdenv, vscode-utils
|
||||
, jq, autoPatchelfHook, bash, makeWrapper
|
||||
, dotnet-sdk_3, curl, gcc, icu, libkrb5, libsecret, libunwind, libX11, lttng-ust, openssl, util-linux, zlib
|
||||
, desktop-file-utils, xprop, xsel
|
||||
}:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
# https://docs.microsoft.com/en-us/visualstudio/liveshare/reference/linux#install-prerequisites-manually
|
||||
libs = [
|
||||
# .NET Core
|
||||
openssl
|
||||
libkrb5
|
||||
zlib
|
||||
icu
|
||||
|
||||
# Credential Storage
|
||||
libsecret
|
||||
|
||||
# NodeJS
|
||||
libX11
|
||||
|
||||
# https://github.com/flathub/com.visualstudio.code.oss/issues/11#issuecomment-392709170
|
||||
libunwind
|
||||
lttng-ust
|
||||
curl
|
||||
|
||||
# General
|
||||
gcc.cc.lib
|
||||
util-linux # libuuid
|
||||
];
|
||||
|
||||
in ((vscode-utils.override { stdenv = gccStdenv; }).buildVscodeMarketplaceExtension {
|
||||
mktplcRef = {
|
||||
name = "vsliveshare";
|
||||
publisher = "ms-vsliveshare";
|
||||
version = "1.0.5449";
|
||||
sha256 = "QKRWfzEdjY7S3d3RPczBvXnhxmfpJZ2bwzcIDbaw+MQ=";
|
||||
};
|
||||
}).overrideAttrs({ nativeBuildInputs ? [], buildInputs ? [], ... }: {
|
||||
nativeBuildInputs = nativeBuildInputs ++ [
|
||||
bash
|
||||
jq
|
||||
autoPatchelfHook
|
||||
makeWrapper
|
||||
];
|
||||
buildInputs = buildInputs ++ libs;
|
||||
|
||||
# Using a patch file won't work, because the file changes too often, causing the patch to fail on most updates.
|
||||
# Rather than patching the calls to functions, we modify the functions to return what we want,
|
||||
# which is less likely to break in the future.
|
||||
postPatch = ''
|
||||
sed -i \
|
||||
-e 's/updateExecutablePermissionsAsync() {/& return;/' \
|
||||
-e 's/isInstallCorrupt(traceSource, manifest) {/& return false;/' \
|
||||
out/prod/extension-prod.js
|
||||
declare ext_unique_id
|
||||
ext_unique_id="$(basename "$out")"
|
||||
# Fix extension attempting to write to 'modifiedInternalSettings.json'.
|
||||
# Move this write to the tmp directory indexed by the nix store basename.
|
||||
substituteInPlace out/prod/extension-prod.js \
|
||||
--replace "path.resolve(constants_1.EXTENSION_ROOT_PATH, './modifiedInternalSettings.json')" \
|
||||
"path.join(os.tmpdir(), '$ext_unique_id-modifiedInternalSettings.json')"
|
||||
# Fix extension attempting to write to 'vsls-agent.lock'.
|
||||
# Move this write to the tmp directory indexed by the nix store basename.
|
||||
substituteInPlace out/prod/extension-prod.js \
|
||||
--replace "path + '.lock'" \
|
||||
"__webpack_require__('path').join(__webpack_require__('os').tmpdir(), '$ext_unique_id-vsls-agent.lock')"
|
||||
# Hardcode executable paths
|
||||
substituteInPlace out/prod/extension-prod.js \
|
||||
--replace xprop ${xprop}/bin/xprop \
|
||||
--replace "'xsel'" "'${xsel}/bin/xsel'"
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
cd $out/share/vscode/extensions/ms-vsliveshare.vsliveshare
|
||||
bash -s <<ENDSUBSHELL
|
||||
shopt -s extglob
|
||||
# A workaround to prevent the journal filling up due to diagnostic logging.
|
||||
# See: https://github.com/MicrosoftDocs/live-share/issues/1272
|
||||
# See: https://unix.stackexchange.com/questions/481799/how-to-prevent-a-process-from-writing-to-the-systemd-journal
|
||||
gcc -fPIC -shared -ldl -o dotnet_modules/noop-syslog.so ${./noop-syslog.c}
|
||||
# Normally the copying of the right executables is done externally at a later time,
|
||||
# but we want it done at installation time.
|
||||
cp dotnet_modules/exes/linux-x64/* dotnet_modules
|
||||
# The required executables are already copied over,
|
||||
# and the other runtimes won't be used and thus are just a waste of space.
|
||||
rm -r dotnet_modules/exes dotnet_modules/runtimes/!(linux-x64|unix)
|
||||
# Not all executables and libraries are executable, so make sure that they are.
|
||||
jq <package.json '.executables.linux[]' -r | xargs chmod +x
|
||||
# Lock the extension downloader.
|
||||
touch install-linux.Lock externalDeps-linux.Lock
|
||||
ENDSUBSHELL
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
# We cannot use `wrapProgram`, because it will generate a relative path,
|
||||
# which will break when copying over the files.
|
||||
mv dotnet_modules/vsls-agent{,-wrapped}
|
||||
makeWrapper $PWD/dotnet_modules/vsls-agent{-wrapped,} \
|
||||
--prefix LD_LIBRARY_PATH : "${makeLibraryPath libs}" \
|
||||
--set LD_PRELOAD $PWD/dotnet_modules/noop-syslog.so \
|
||||
--set DOTNET_ROOT ${dotnet-sdk_3}
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Live Share lets you achieve greater confidence at speed by streamlining collaborative editing, debugging, and more in real-time during development";
|
||||
homepage = "https://aka.ms/vsls-docs";
|
||||
license = licenses.unfree;
|
||||
maintainers = with maintainers; [ jraygauthier V ];
|
||||
platforms = [ "x86_64-linux" ];
|
||||
};
|
||||
})
|
||||
Reference in New Issue
Block a user