Skip to content

Commit

Permalink
Attempt to support vscode extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
nc6 committed Jun 13, 2024
1 parent dbf49b2 commit 70fc805
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/schema.ncl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
let nix = import "./nix-interop/nix.ncl" in
let filegen = import "files.ncl" in
let vscode = import "vscode.ncl" in
{
OrganistShells = {
dev
Expand Down Expand Up @@ -64,4 +65,5 @@ let filegen = import "files.ncl" in
= {},
}
& filegen.Schema
& vscode.Schema
}
58 changes: 58 additions & 0 deletions lib/vscode.ncl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
let nix = import "./nix-interop/nix.ncl" in
let ExtensionFromMarketplace = {
publisher | String,
name | String,
version | String,
sha256 | String
} in
let VSCodeSchema = {
extensions
| doc "Extensions to install locally in the workspace"
| { _ : ExtensionFromMarketplace }
| default = {}
} in
let BuiltExtensionDetails = {
name | String,
path | Dyn
} in
let buildExtension : String -> ExtensionFromMarketplace -> BuiltExtensionDetails = fun extName efm =>
{ name = extName,
path = nix.derivation.CallNix & { function = m%"
vscode-utils.buildVscodeMarketplaceExtension
{ mktplcRef =
{ publisher = "{publisher}";
name = "{name}";
version = "{version}";
sha256="{sha256}";
};
}
"%,
args = {
publisher = efm.publisher,
name = efm.name,
version = efm.version,
sha256 = efm.sha256
}
}} | BuiltExtensionDetails in
let regenerate-vscode | { _ : ExtensionFromMarketplace} -> nix.derivation.Derivation = fun exts =>
{ name = "regenerate-vscode-exts",
content.text = exts
|> std.record.to_array
|> std.array.map (fun {field = extName, value = ext} => buildExtension extName ext)
|> std.array.fold_left
( fun acc elt =>
nix-s%"
%{acc}
ln -s ".vscode/extensions/%{elt.name}" %{elt.path}
"%)
"",
} | nix.builders.ShellApplication
in {
Schema = {
vscode | doc m%"
VSCode configuration
"% | VSCodeSchema | default
= {},
flake.apps.regenerate-vscode.program = nix-s%"%{regenerate-vscode vscode.extensions}/bin/regenerate-vscode"%,
},
}

0 comments on commit 70fc805

Please sign in to comment.