From 2f3ea1fdc2b73f7c92ffff9d82d6f2c7b87e82b2 Mon Sep 17 00:00:00 2001 From: Fi guadec Date: Sat, 2 Dec 2023 14:59:07 +0000 Subject: [PATCH] nongnu: vscodium: Alter binary wrapping and add configuration home service * nongnu/packages/editors.scm (vscodium): Executable wrapper now wraps /opt/vscodium/bin/codium this was done as the previous executable at /opt/vscodium/codium does not support command line flags this is discussed in their vc site here: https://github.com/VSCodium/vscodium/issues/332 * nongnu/home/services/editors.scm: added , vscodium-service-type added a home service which installs user: extensions, snippets, keybinds, settings --- nongnu/home/services/editors.scm | 115 +++++++++++++++++++++++++++++++ nongnu/packages/editors.scm | 2 +- 2 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 nongnu/home/services/editors.scm diff --git a/nongnu/home/services/editors.scm b/nongnu/home/services/editors.scm new file mode 100644 index 0000000..34042ef --- /dev/null +++ b/nongnu/home/services/editors.scm @@ -0,0 +1,115 @@ +;;; SPDX-License-Identifier: GPL-3.0-or-later +;;; Copyright © 2023 peridot lazuli + +(define-module (nongnu home services editors) + #:use-module (guix gexp) + #:use-module (guix records) + #:use-module (gnu home services) + #:use-module (guix modules) + #:use-module (json) + #:use-module (nongnu packages editors) + + #:export ( vscodium-configuration + make-vscodium-configuration + vscodium-configuration? + this-vscodium-configuration + vscodium-configuration-snippets + vscodium-configuration-keybindings + vscodium-configuration-settings + vscodium-configuration-vsix-extensions + + vscodium-service-type)) + +(define-record-type* vscodium-configuration + make-vscodium-configuration + vscodium-configuration? + this-vscodium-configuration + (snippets vscodium-configuration-snippets + (default (list))) + (keybindings vscodium-configuration-keybindings + (default (vector))) + (settings vscodium-configuration-settings + (default (list))) + (vsix-extensions vscodium-configuration-vsix-extensions + (default (list)))) + +(define vscodium-service-type + (service-type (name 'vscodium) + (extensions (list (service-extension + home-xdg-configuration-files-service-type + (lambda (config) + ;; Install { keybind-(*), setting-(*), snippet.(*)} to $XDG_CONFIG_HOME/VSCodium/User/* + (let ((base "VSCodium/User/")) + `((,(string-append base "keybinds.json") , + (plain-file "vscodium-keybindings" + (scm->json-string (vscodium-configuration-keybindings + config)))) + (,(string-append base "settings.json") , + (plain-file "vscodium-settings" + (scm->json-string (vscodium-configuration-settings + config)))) + ,@(map (lambda (snippetEntry) + (let ((name (car + snippetEntry)) + (data (cdr + snippetEntry))) + (list (string-append base + "snippets/" name + ".code-snippets") + (plain-file (string-append + "vscodium-snippet-" + name) + (scm->json-string + data))))) + (vscodium-configuration-snippets + config)))))) + (service-extension + home-activation-service-type + (lambda (config) + ;; install extension-(*) upon re-configure using `codium --install-extension /gnu/store/ --force` + ;; + ;; a better option i think would be to un-pack each vsix file using `unzip` in a computed-file and then storing those item-(*) in the store + ;; then referencing those from $HOME/.vscode-oss/extensions/extensions.json + ;; the general structure i had going was: ( in the home-files-service-type extension) + ;; map each extension to a list which is passed to scm->json-string to create the extensions.json file + ;; in the mapping function: + ;; create the compute-ed-file which unzip-s the vsix into a store location + ;; contain that in a gexp and pass that to gexp->derivation which is run through the store to build the file + ;; use the reultant store name as well as the original name to create the alist entry for extensions.json + + #~(begin + (define extensionPaths + (list #$@(vscodium-configuration-vsix-extensions + config))) + (for-each (lambda (extensionPath) + (system* (string-append #$vscodium + "/bin/codium") + "--install-extension" + extensionPath "--force")) + extensionPaths)))) + (service-extension home-profile-service-type + (const (list vscodium))))) + (default-value (vscodium-configuration)) + (description + "install vscodium using specified value-(*) for: +snippet-(*) +setting-(*) +keybind-ing-(*) +extent-tion-(*) + +to do this, one can use a record: +snippets + a list of pair-(*) where the car is the name of the snippet and the cdr is an assoc list representing the snippet configuration +keybindings + a vector of keybinding object-(*) in the vscodium \"keybindings.json\" format +settings + a association list in the vscodium \"settings.json\" format +extensions + a list of file like object-(*) which resolve to a vsix extension file + +any { + snippet pair cdr, + keybinding, + setting, +} +must be in a format acceptable by the guile-json module, in other word-(*) vector-(*) must be used, not list-(*)"))) diff --git a/nongnu/packages/editors.scm b/nongnu/packages/editors.scm index 7c4fe60..6c295d8 100644 --- a/nongnu/packages/editors.scm +++ b/nongnu/packages/editors.scm @@ -40,7 +40,7 @@ (let* ((bin (string-append #$output "/bin"))) (delete-file (string-append #$output "/environment-variables")) (mkdir-p bin) - (symlink (string-append #$output "/opt/vscodium/codium") + (symlink (string-append #$output "/opt/vscodium/bin/codium") (string-append bin "/codium"))))) (add-after 'install-entrypoint 'install-resources (lambda _