Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(apps/vscode)!: install extensions from nixpkgs #6

Merged
merged 6 commits into from
Jun 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 58 additions & 113 deletions home/apps/vscode/default.nix
Original file line number Diff line number Diff line change
@@ -1,131 +1,76 @@
{
pkgs,
lib,
config,
...
}: let
extensions = [
"astro-build.astro-vscode"
"bierner.comment-tagged-templates"
"bierner.emojisense"
"bierner.github-markdown-preview"
"bierner.markdown-checkbox"
"bierner.markdown-emoji"
"bierner.markdown-footnotes"
"bierner.markdown-mermaid"
"bierner.markdown-preview-github-styles"
"bierner.markdown-yaml-preamble"
"biomejs.biome"
"bmalehorn.vscode-fish"
"bradlc.vscode-tailwindcss"
"catppuccin.catppuccin-vsc"
"catppuccin.catppuccin-vsc-icons"
"charliermarsh.ruff"
"dbaeumer.vscode-eslint"
"denoland.vscode-deno"
"eamodio.gitlens"
"editorconfig.editorconfig"
"esbenp.prettier-vscode"
"fabiospampinato.vscode-open-in-finder"
"fabiospampinato.vscode-open-in-github"
"fabiospampinato.vscode-open-in-npm"
"fortran-lang.linter-gfortran"
"ginfuru.better-nunjucks"
"github.vscode-github-actions"
"golang.go"
"graphql.vscode-graphql-syntax"
"griimick.vhs"
"hyoban.tailwindcss-classname-highlight"
"jnoortheen.nix-ide"
"johnnymorganz.stylua"
"kamadorueda.alejandra"
"kravets.vscode-publint"
"leonardssh.vscord"
"mechatroner.rainbow-csv"
"meganrogge.template-string-converter"
"mrmlnc.vscode-scss"
"ms-python.debugpy"
"ms-python.python"
"ms-vscode-remote.remote-wsl"
"ms-vscode.cpptools"
"njpwerner.autodocstring"
"oscarotero.vento-syntax"
"oven.bun-vscode"
"ph0enixkm.amber-language"
"redhat.vscode-yaml"
"rust-lang.rust-analyzer"
"sclu1034.justfile"
"svelte.svelte-vscode"
"tamasfe.even-better-toml"
"tauri-apps.tauri-vscode"
"timonwong.shellcheck"
"unifiedjs.vscode-mdx"
"usernamehw.errorlens"
"visualstudioexptteam.intellicode-api-usage-examples"
"visualstudioexptteam.vscodeintellicode"
"vitaliymaz.vscode-svg-previewer"
"vue.volar"
"wakatime.vscode-wakatime"
"yahyabatulu.vscode-markdown-alert"
"yoavbls.pretty-ts-errors"
"yzhang.markdown-all-in-one"
"zguolee.tabler-icons"
];

mkLink = config.lib.file.mkOutOfStoreSymlink;

settingsFile = mkLink "/Users/uncenter/.config/flake/home/apps/vscode/settings.json";
in {
programs.vscode = {
enable = true;
package = pkgs.stdenv.mkDerivation {
pname = "vscode";
version = "1.88.1";
dontUnpack = true;
installPhase = ''
mkdir -p $out
'';
};

extensions = [];
mutableExtensionsDir = true;
};

# Originally from https://github.com/ryanccn/flake/blob/3861c0442b808dc44694ce783e77f4abdcbd087b/home/apps/vscode.nix#L207-L241.
home.activation = {
vscodeExtensions = lib.hm.dag.entryAfter ["writeBoundary"] ''
code_bin="/usr/local/bin/code"
package = pkgs.vscode;

if ! command -v "$code_bin" &> /dev/null; then
echo "code CLI is not available"
exit 0
fi
extensions = with pkgs.vscode-extensions; [
# Appearance
catppuccin.catppuccin-vsc
catppuccin.catppuccin-vsc-icons
zguolee.tabler-icons

declare -A currentExtensions
for extension in $("$code_bin" --list-extensions); do
currentExtensions["$extension"]=1;
done
# Markdown
bierner.emojisense
bierner.github-markdown-preview
bierner.markdown-checkbox
bierner.markdown-emoji
bierner.markdown-footnotes
bierner.markdown-mermaid
bierner.markdown-preview-github-styles
yzhang.markdown-all-in-one

${builtins.concatStringsSep
"\n"
(
builtins.map
(ext: ''
if [[ -z "''${currentExtensions[${ext}]+unset}" ]]; then
echo "installing ${ext}"
$DRY_RUN_CMD "$code_bin" --install-extension ${ext} &> /dev/null
fi
unset 'currentExtensions[${ext}]'
'')
extensions
)}
# Language/Tool Support
astro-build.astro-vscode
biomejs.biome
bmalehorn.vscode-fish
bradlc.vscode-tailwindcss
charliermarsh.ruff
dbaeumer.vscode-eslint
denoland.vscode-deno
eamodio.gitlens
editorconfig.editorconfig
esbenp.prettier-vscode
fortran-lang.linter-gfortran
github.vscode-github-actions
golang.go
graphql.vscode-graphql-syntax
griimick.vhs
jnoortheen.nix-ide
mechatroner.rainbow-csv
ms-python.debugpy
ms-python.python
redhat.vscode-yaml
rust-lang.rust-analyzer
nefrob.vscode-just-syntax
svelte.svelte-vscode
tamasfe.even-better-toml
timonwong.shellcheck
unifiedjs.vscode-mdx
visualstudioexptteam.intellicode-api-usage-examples
visualstudioexptteam.vscodeintellicode
vue.volar
yoavbls.pretty-ts-errors

for ext in "''${!currentExtensions[@]}"; do
echo "uninstalling $ext"
$DRY_RUN_CMD "$code_bin" --uninstall-extension $ext &> /dev/null
unset 'currentExtensions[$ext]'
done
'';
# Utilities
bierner.comment-tagged-templates
wakatime.vscode-wakatime
vitaliymaz.vscode-svg-previewer
usernamehw.errorlens
meganrogge.template-string-converter
fabiospampinato.vscode-open-in-github
kravets.vscode-publint
njpwerner.autodocstring
ms-vscode-remote.remote-wsl
];
mutableExtensionsDir = true;
};

home.file."Library/Application Support/Code/User/settings.json".source = settingsFile;
Expand Down