diff --git a/gchannel/packages/code-server.scm b/gchannel/packages/code-server.scm index f2c8b20..699e670 100644 --- a/gchannel/packages/code-server.scm +++ b/gchannel/packages/code-server.scm @@ -5,10 +5,13 @@ #:use-module (guix download) #:use-module (gnu packages) #:use-module (gnu packages commencement) + #:use-module (gnu packages curl) #:use-module (gnu packages version-control) + #:use-module (gnu packages fontutils) + #:use-module (selected-guix-works packages fonts) #:use-module (guix build-system copy) - #:use-module (guix build copy-build-system) -) + #:use-module (guix build copy-build-system)) + (define-public code-server (package @@ -24,25 +27,60 @@ (inputs (list - gcc-toolchain)) + gcc-toolchain + woff-tools + font-nerd-fonts-jetbrains-mono + )) (arguments (list #:tests? #f ; no check target #:phases #~(modify-phases %standard-phases - (add-after 'install 'wrap - (lambda _ + (add-after 'install 'wrap + (lambda _ (wrap-program (string-append (assoc-ref %outputs "out") "/lib/node") `("LD_LIBRARY_PATH" ":" prefix ( ,(string-append #$(this-package-input "gcc-toolchain") "/lib") ))))) + (add-after 'wrap 'enable-font-magic + (lambda _ + (let ((font-package "font-nerd-fonts-jetbrains-mono") + (font-path "/share/fonts/truetype/") + (font-prefix "JetBrainsMonoNerdFontMono-") + ) + (use-modules (ice-9 ftw) + (srfi srfi-1)) ; For list processing + (define (collect-files-with-prefix directory prefix) + (filter (lambda (str) (string-prefix? prefix str)) (cddr (scandir directory)))) + (map (lambda (entry) + (let* ((source (car entry)) (file (cdr entry))) + (symlink (string-append (assoc-ref %build-inputs source) font-path file) + (string-append (assoc-ref %outputs "out") "/src/browser/pages/" (basename file))) + (system* "sfnt2woff" (string-append (assoc-ref %outputs "out") "/src/browser/pages/" (basename file))) + )) + (append + (map (lambda (file) (cons font-package file)) + (collect-files-with-prefix (string-append (assoc-ref %build-inputs font-package) font-path) font-prefix) + ))) + (let ((font-files (string-join + (map + (lambda (x) + (string-append "url('_static/src/browser/pages/" (substring x 0 (- (string-length x) 4)) ".woff') format('woff')" )) + (collect-files-with-prefix (string-append (assoc-ref %build-inputs font-package) font-path) font-prefix)) + "," + ))) + (system* "sed" "-i" (string-append "s|||g") (string-append #$output "/lib/vscode/out/vs/code/browser/workbench/workbench.html")) + ) +)) + ) (delete 'validate-runpath) ))) (native-inputs - (list git)) + (list git curl)) (synopsis "Soup") (home-page "https://coder.com/") (description "Free open source code server") (license license:agpl3))) - code-server \ No newline at end of file + code-server +