A tool generate nix expression from config.toml. Let's guess we have a config.toml like this:
vscode_version = "1.81.1"
[[extensions]]
publisher_name = "eamodio"
extension_name = "gitlens"
[[extensions]]
publisher_name = "vscodevim"
extension_name = "vim"
then run cargo run -- config.toml
, the a nix expression will be print to stdout just like this:
{ pkgs, lib }:
let
vscode-utils = pkgs.vscode-utils;
in
{
eamodio.gitlens = vscode-utils.extensionFromVscodeMarketplace {
name = "gitlens";
publisher = "eamodio";
version = "2023.9.905";
sha256 = "1mzyc3sinkg4zmbyh2a85iqdqa7wsnh99hqvk6f8m2jcfhpfrwyb";
};
vscodevim.vim = vscode-utils.extensionFromVscodeMarketplace {
name = "vim";
publisher = "vscodevim";
version = "1.26.0";
sha256 = "0hxb58ygjbqk6qmkp1r421zzib2r1vmz7agbi7bcmjxjpr3grw2w";
};
}
Let's guess you store those contents in a file named pkgs.nix
, then you can use it by:
{ pkgs, lib }:
let
plugins = (import ./vscode_plugins.nix) { pkgs = pkgs; lib = lib; };
in
with pkgs;
{
enableExtensionUpdateCheck = false;
enableUpdateCheck = false;
extensions = with vscode-marketplace;[
plugins.vscodevim.vim
]
;
}
For some extensions (such as codelldb), there is only a downloader in vscode markplace, and the real location of the extension is on github. At this time, asset_url is allowed to be redirected:
vscode_version = "1.81.1"
[[extensions]]
publisher_name = "vadimcn"
extension_name = "vscode-lldb"
asset_url = '''
https://github.com/vadimcn/codelldb/releases/download/v{{ extension.version }}/codelldb-{{ system.arch }}-{{ system.ostype }}.vsix
'''
asset_url is a jinja template string.