1
0
Fork 0
mirror of https://github.com/ryanccn/flake.git synced 2025-12-06 08:10:43 +01:00

fix(vscode): un-manage the app itself

This commit is contained in:
Ryan Cao 2023-09-04 22:38:33 +08:00
parent 5cf5ed65b7
commit c7fbe30750
Signed by: ryanccn
SSH key fingerprint: SHA256:NtP/BlVhoQq4xU6BEcZeT8nIPvHntkJ3lIc2yB+F09E

View file

@ -49,6 +49,14 @@
in { in {
programs.vscode = { programs.vscode = {
enable = true; enable = true;
package = pkgs.stdenv.mkDerivation {
pname = "vscode";
version = "1.81.1";
src = pkgs.emptyDirectory;
installPhase = ''
mkdir -p $out
'';
};
extensions = []; extensions = [];
mutableExtensionsDir = true; mutableExtensionsDir = true;
@ -173,8 +181,13 @@ in {
home.activation = { home.activation = {
vscodeExtensions = lib.hm.dag.entryAfter ["writeBoundary"] '' vscodeExtensions = lib.hm.dag.entryAfter ["writeBoundary"] ''
if ! command -v "code" &> /dev/null; then
echo "code CLI is not available"
exit 0
fi
declare -A currentExtensions declare -A currentExtensions
for extension in $(${pkgs.vscode}/bin/code --list-extensions); do for extension in $(code --list-extensions); do
currentExtensions["$extension"]=1; currentExtensions["$extension"]=1;
done done
@ -185,7 +198,7 @@ in {
(ext: '' (ext: ''
if [[ -z "''${currentExtensions[${ext}]+unset}" ]]; then if [[ -z "''${currentExtensions[${ext}]+unset}" ]]; then
echo "installing ${ext}" echo "installing ${ext}"
${pkgs.vscode}/bin/code --install-extension ${ext} &> /dev/null code --install-extension ${ext} &> /dev/null
fi fi
unset 'currentExtensions[${ext}]' unset 'currentExtensions[${ext}]'
'') '')
@ -194,7 +207,7 @@ in {
for ext in "''${!currentExtensions[@]}"; do for ext in "''${!currentExtensions[@]}"; do
echo "uninstalling $ext" echo "uninstalling $ext"
${pkgs.vscode}/bin/code --uninstall-extension $ext &> /dev/null code --uninstall-extension $ext &> /dev/null
currentExtensions[$ext]= currentExtensions[$ext]=
done done
''; '';