add vscode update script and update extensions

This commit is contained in:
Leon Vatthauer 2025-01-13 14:29:00 +01:00
parent a0c487d602
commit 0d6f9adacc
Signed by: leonv
SSH key fingerprint: SHA256:G4+ddwoZmhLPRB1agvXzZMXIzkVJ36dUYZXf5NxT+u8
2 changed files with 208 additions and 67 deletions

View file

@ -3,71 +3,120 @@
programs.vscode = {
enable = true;
package = pkgs.vscodium;
extensions = with pkgs.vscode-extensions; [
bbenoist.nix
yzhang.markdown-all-in-one
haskell.haskell
justusadam.language-haskell
maximedenes.vscoq
james-yu.latex-workshop
mkhl.direnv
catppuccin.catppuccin-vsc
valentjn.vscode-ltex
ms-vscode.cpptools
] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [
{
name = "doxdocgen";
publisher = "cschlosser";
version = "1.4.0";
sha256 = "sha256-InEfF1X7AgtsV47h8WWq5DZh6k/wxYhl2r/pLZz9JbU=";
}
extensions = pkgs.vscode-utils.extensionsFromVscodeMarketplace [
{
name = "vsc-prolog";
publisher = "arthurwang";
version = "0.8.23";
sha256 = "sha256-Da2dCpruVqzP3g1hH0+TyvvEa1wEwGXgvcmIq9B/2cQ=";
}
{
name = "better-cpp-syntax";
publisher = "jeff-hykin";
version = "1.27.1";
sha256 = "sha256-GO/ooq50KLFsiEuimqTbD/mauQYcD/p2keHYo/6L9gw=";
}
{
name = "c-cpp-flylint";
publisher = "jbenden";
version = "1.15.0";
sha256 = "sha256-k6sH0Rx4VjGmKjvCR9x/OWrxmo7+S2bvRlZi3Z9PNPw=";
sha256 = "1i6rgz8ap269pph6bh04bimw9yyajd7iyq8dvv7sqmpfk859vb8d";
}
{
name = "agda-mode";
publisher = "banacorn";
version = "0.4.7";
sha256 = "sha256-gNa3n16lP3ooBRvGaugTua4IXcIzpMk7jBYMJDQsY00=";
version = "0.5.1";
sha256 = "02r28a8y6pdjhad76z193xrlc4yk4fsynn064w7cff56gdc31bd5";
}
{
name = "yuck";
publisher = "eww-yuck";
version = "0.0.3";
sha256 = "sha256-DITgLedaO0Ifrttu+ZXkiaVA7Ua5RXc4jXQHPYLqrcM=";
name = "nix";
publisher = "bbenoist";
version = "1.0.1";
sha256 = "0zd0n9f5z1f0ckzfjr38xw2zzmcxg1gjrava7yahg5cvdcw6l35b";
}
{
name = "catppuccin-vsc";
publisher = "catppuccin";
version = "3.16.0";
sha256 = "1g4021qrsy67fw2b1lvazn58nvr64dkvpywqanbpz24dlgk2573r";
}
{
name = "doxdocgen";
publisher = "cschlosser";
version = "1.4.0";
sha256 = "1d95znf2vsdzv9jqiigh9zm62dp4m9jz3qcfaxn0n0pvalbiyw92";
}
{
name = "simple-alignment";
publisher = "earshinov";
version = "1.0.1";
sha256 = "sha256-Lqg5wVGj6VulEJHVv7CS6aci7Ze2KEqXMu10vlrYYao=";
sha256 = "1ak1v1dbwx7d6ablla5njznj59z9jaqbzmci22jmpsd3a70kka1f";
}
{
name = "yuck";
publisher = "eww-yuck";
version = "0.0.3";
sha256 = "1hxdxa13s1vlilw7fidr8vnl19c9wjazjvnvmqgl4fsswwny110c";
}
{
name = "todo-tree";
publisher = "Gruntfuggly";
publisher = "gruntfuggly";
version = "0.0.226";
sha256 = "sha256-Fj9cw+VJ2jkTGUclB1TLvURhzQsaryFQs/+f2RZOLHs=";
sha256 = "0yrc9qbdk7zznd823bqs1g6n2i5xrda0f9a7349kknj9wp1mqgqn";
}
{
name = "haskell";
publisher = "haskell";
version = "2.5.3";
sha256 = "13s39fvb6kwxklcfsa5xh4z7y8y3y0h6jv39ljrgl24qkwgx8xnw";
}
{
name = "latex-workshop";
publisher = "james-yu";
version = "10.7.5";
sha256 = "0habsbk0w2g8vcxqzdbnwy6f0x0ghvcx1f9szd4p1pwjfij2vnax";
}
{
name = "c-cpp-flylint";
publisher = "jbenden";
version = "1.15.0";
sha256 = "1z1l9ygxsqjn8vpncjzyisdg2sirgzf4ghiv5ak32mkq3k8hgawk";
}
{
name = "better-cpp-syntax";
publisher = "jeff-hykin";
version = "1.27.1";
sha256 = "037nigza7n71j5vgl3qw0swrmy8gvfj9m8jbi1nb2a3lmsifivqq";
}
{
name = "language-haskell";
publisher = "justusadam";
version = "3.6.0";
sha256 = "115y86w6n2bi33g1xh6ipz92jz5797d3d00mr4k8dv5fz76d35dd";
}
{
name = "lean4";
publisher = "leanprover";
version = "0.0.133";
sha256 = "sha256-tjBTOkh4UeEmOo/ZbadpeyW07QiPcUO4aI2NWdtTxrE=";
version = "0.0.187";
sha256 = "04pyq6v0s5dy6b8bpjakp33dff4plxxa100x8gvbw36v6ddpsx7d";
}
{
name = "vscoq";
publisher = "maximedenes";
version = "2.2.1";
sha256 = "04m1dby6zfzg5nahnricjax28g47mgnja7d9cbll270i7ahnyncm";
}
{
name = "direnv";
publisher = "mkhl";
version = "0.17.0";
sha256 = "1n2qdd1rspy6ar03yw7g7zy3yjg9j1xb5xa4v2q12b0y6dymrhgn";
}
{
name = "cpptools";
publisher = "ms-vscode";
version = "1.23.3";
sha256 = "03gwyrrcc4kw84ss7mh8ksfib1bvmhmr1pa5sg11nzj2hzxnikgd";
}
{
name = "vscode-ltex";
publisher = "valentjn";
version = "13.1.0";
sha256 = "15qm97i9l65v3x0zxl1895ilazz2jk2wmizbj7kmds613jz7d46c";
}
{
name = "markdown-all-in-one";
publisher = "yzhang";
version = "3.6.2";
sha256 = "1n9d3qh7vypcsfygfr5rif9krhykbmbcgf41mcjwgjrf899f11h4";
}
];
userSettings = {

92
update_installed_exts.sh Executable file
View file

@ -0,0 +1,92 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p cacert curl jq unzip
# shellcheck shell=bash
set -eu -o pipefail
# SOURCE: https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vscode/extensions/update_installed_exts.sh
# can be added to your configuration with the following command and snippet:
# $ ./pkgs/applications/editors/vscode/extensions/update_installed_exts.sh > extensions.nix
#
# packages = with pkgs;
# (vscode-with-extensions.override {
# vscodeExtensions = map
# (extension: vscode-utils.buildVscodeMarketplaceExtension {
# mktplcRef = {
# inherit (extension) name publisher version sha256;
# };
# })
# (import ./extensions.nix).extensions;
# })
# ]
# Helper to just fail with a message and non-zero exit code.
function fail() {
echo "$1" >&2
exit 1
}
# Helper to clean up after ourselves if we're killed by SIGINT.
function clean_up() {
TDIR="${TMPDIR:-/tmp}"
echo "Script killed, cleaning up tmpdirs: $TDIR/vscode_exts_*" >&2
rm -Rf "$TDIR/vscode_exts_*"
}
function get_vsixpkg() {
N="$1.$2"
# Create a tempdir for the extension download.
EXTTMP=$(mktemp -d -t vscode_exts_XXXXXXXX)
URL="https://$1.gallery.vsassets.io/_apis/public/gallery/publisher/$1/extension/$2/latest/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage"
# Quietly but delicately curl down the file, blowing up at the first sign of trouble.
curl --silent --show-error --retry 3 --fail -X GET -o "$EXTTMP/$N.zip" "$URL"
# Unpack the file we need to stdout then pull out the version
VER=$(jq -r '.version' <(unzip -qc "$EXTTMP/$N.zip" "extension/package.json"))
# Calculate the SHA
SHA=$(nix-hash --flat --base32 --type sha256 "$EXTTMP/$N.zip")
# Clean up.
rm -Rf "$EXTTMP"
# I don't like 'rm -Rf' lurking in my scripts but this seems appropriate.
cat <<-EOF
{
name = "$2";
publisher = "$1";
version = "$VER";
sha256 = "$SHA";
}
EOF
}
# See if we can find our `code` binary somewhere.
if [ $# -ne 0 ]; then
CODE=$1
else
CODE=$(command -v code || command -v codium)
fi
if [ -z "$CODE" ]; then
# Not much point continuing.
fail "VSCode executable not found"
fi
# Try to be a good citizen and clean up after ourselves if we're killed.
trap clean_up SIGINT
# Begin the printing of the nix expression that will house the list of extensions.
printf '{ extensions = [\n'
# Note that we are only looking to update extensions that are already installed.
for i in $($CODE --list-extensions)
do
OWNER=$(echo "$i" | cut -d. -f1)
EXT=$(echo "$i" | cut -d. -f2)
get_vsixpkg "$OWNER" "$EXT"
done
# Close off the nix expression.
printf '];\n}'