/devos-ext-lib

A kick ass library to dominate your Extensions (with DevOS).

Primary LanguageNixMIT LicenseMIT

MIT License NixOS

Introduction

This is a kick ass library to dominate your Extensions (with DevOS).

Currently VS Code extensions and some other package sets are supported. See also flake.nix.

Usage

For now, let's use VS Code as an example.

Within devos itself, you can use as follow:

In flake.nix:

{
  inputs.devos-ext-lib.url = "github:divnix/devos-ext-lib";
  outputs = inputs@{ devos-ext-lib, ... }: digga.lib.mkFlake {
    channels.nixos.overlays = [ devos-ext-lib.overlays.vscode ];
  };
}

In pkgs/default.nix:

final: prev:
let
  sources = callPackage ./_sources/generated.nix { };
in {
  vscode-extensions = final.vscode-extensions-builder sources {
    # a function to merge previous extensions from a publisher
    # with new ones from `sources`
    # note: publisher and extension name are automatically converted
    #       to lower case
    pkgBuilder = final.vscode-utils.pkgBuilder';

    # a function that filters the sources by a prefix
    # and group them by their publishers (i.e. "${publisher}.${extension-name}")
    filterSources = final.lib.vscode-extensions.filterSources';

    # A typical nvfetcher toml:
    # [vscode-extensions-paulmolluzzo-convert-css-in-js]
    # src.manual = "0.3.0"
    # fetch.url = "https://open-vsx.org/api/paulmolluzzo/convert-css-in-js/0.3.0/file/paulmolluzzo.convert-css-in-js-0.3.0.vsix"
    # passthru = { publisher = "paulmolluzzo", name = "convert-css-in-js", description = "Convert kebab-case CSS to camelCase CSS and vice versa", license = "MIT" }
    #
    prefix = "vscode-extensions";
  };
}

It simply map through sources for VS Code extensions with pkgBuilder, and you can override each extensions using //.

You can now refer to them as pkgs.vscode-extensions.${publisher}.${extension-name}, such as pkgs.vscode-extensions.paulmolluzzo.convert-css-in-js.

Metadata

For my personal use case, I use openvsx-updater and more generally danielphan2003/nixpkgs to generate metadata automatically.

It uses GitHub Actions to fetch metadata from OpenVSX, and nvfetcher to get the sources and pass through the metadata for VS Code extensions.

Note that VS Marketplace extensions does not have a clear API for metadata extraction. As a result, only OpenVSX ones are able to do so.

TODOs:

Shoulders

This work does not reinvent the wheel. It stands on the shoulders of the following giants:

🧅 — like the layers of an onion

👪 — like family

❤️