mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2025-04-30 04:43:39 +02:00
split setup script into multiple files
This commit is contained in:
parent
f6e279d9e7
commit
0e97bd2440
7 changed files with 116 additions and 84 deletions
98
setup.rkt
98
setup.rkt
|
@ -3,13 +3,8 @@
|
|||
|
||||
;; Script for setting up the config.
|
||||
|
||||
(require racket/runtime-path)
|
||||
|
||||
;; Default output path
|
||||
(define output-bin-path (make-parameter (build-path (find-system-path 'home-dir) ".local")))
|
||||
|
||||
;; Whether to log calls or not
|
||||
(define log-calls (make-parameter #t))
|
||||
(require racket/runtime-path
|
||||
"setup/common.rkt")
|
||||
|
||||
;; Valid verbs
|
||||
(define verbs '(install-scripts install-lsps-paru setup-nvim-config confgen))
|
||||
|
@ -36,81 +31,16 @@
|
|||
(symbol=? valid-verb verb)))
|
||||
(error "Invalid verb" verb))
|
||||
|
||||
(define (display-function-call func args)
|
||||
(when (log-calls)
|
||||
(printf "(~s ~a)\n" func (apply ~a #:separator " " args))))
|
||||
|
||||
;; Defines an alias to a function which will log it's parameters on invokation.
|
||||
(define-syntax-rule (define-logging name func)
|
||||
(define (name . args)
|
||||
(display-function-call (quote name) args)
|
||||
(apply func args)))
|
||||
|
||||
(define-logging cmd (λ (exe . args) (apply system* (find-executable-path exe) args)))
|
||||
(define-logging rm delete-directory/files)
|
||||
(define-logging copy copy-directory/files)
|
||||
|
||||
(define (cmd/install-scripts)
|
||||
(define-logging mklink
|
||||
(λ (from to)
|
||||
(with-handlers ([exn:fail? (const #f)]) (delete-file to))
|
||||
(make-file-or-directory-link (normalize-path from) to)))
|
||||
|
||||
(define-logging install-zig-script
|
||||
(λ (path)
|
||||
(parameterize ([current-directory path] [log-calls #f])
|
||||
(cmd "zig" "build" "-p" (output-bin-path) "-Doptimize=ReleaseFast"))))
|
||||
|
||||
(mklink "scripts/map-touch-display.rkt" (build-path (output-bin-path) "bin" "map-touch-display"))
|
||||
(mklink "scripts/playvid.rkt" (build-path (output-bin-path) "bin" "playvid"))
|
||||
(mklink "scripts/start-joshuto.sh" (build-path (output-bin-path) "bin" "start-joshuto"))
|
||||
(mklink "scripts/startriver.sh" (build-path (output-bin-path) "bin" "startriver"))
|
||||
(mklink "scripts/update-nvim-plugins.rkt"
|
||||
(build-path (output-bin-path) "bin" "update-nvim-plugins"))
|
||||
(mklink "scripts/withjava.sh" (build-path (output-bin-path) "bin" "withjava"))
|
||||
|
||||
(install-zig-script "scripts/mzteinit")
|
||||
(install-zig-script "scripts/openbrowser")
|
||||
(install-zig-script "scripts/playtwitch")
|
||||
(install-zig-script "scripts/prompt")
|
||||
(install-zig-script "scripts/randomwallpaper")
|
||||
(install-zig-script "scripts/vinput")
|
||||
null)
|
||||
|
||||
(define (cmd/install-lsps-paru)
|
||||
(define lsp-packages
|
||||
(list "elixir-ls-git"
|
||||
"eslint"
|
||||
"jdtls"
|
||||
"lua-language-server"
|
||||
"shellcheck"
|
||||
"shfmt"
|
||||
"taplo-cli"
|
||||
"tidy"
|
||||
"vscode-langservers-extracted"
|
||||
"yaml-language-server"
|
||||
"zls-git"))
|
||||
|
||||
(apply cmd "paru" "-S" "--needed" "--noconfirm" lsp-packages)
|
||||
|
||||
(when (find-executable-path "opam")
|
||||
(cmd "opam" "install" "--yes" "ocaml-lsp-server" "ocamlformat"))
|
||||
null)
|
||||
|
||||
(define (cmd/setup-nvim-config)
|
||||
(define nvim-config-dir (build-path (find-system-path 'home-dir) ".config" "nvim"))
|
||||
(rm nvim-config-dir)
|
||||
(copy "mzte-nv/conf" nvim-config-dir)
|
||||
(cmd "mzte-nv-compile" (path->string nvim-config-dir))
|
||||
null)
|
||||
|
||||
(define (cmd/confgen)
|
||||
(rm "cgout")
|
||||
(cmd "confgen" "confgen.lua" "cgout")
|
||||
null)
|
||||
|
||||
(case verb
|
||||
[(install-scripts) (cmd/install-scripts)]
|
||||
[(install-lsps-paru) (cmd/install-lsps-paru)]
|
||||
[(setup-nvim-config) (cmd/setup-nvim-config)]
|
||||
[(confgen) (cmd/confgen)])
|
||||
[(install-scripts)
|
||||
(local-require "setup/commands/install-scripts.rkt")
|
||||
(run)]
|
||||
[(install-lsps-paru)
|
||||
(local-require "setup/commands/install-lsps-paru.rkt")
|
||||
(run)]
|
||||
[(setup-nvim-config)
|
||||
(local-require "setup/commands/setup-nvim-config.rkt")
|
||||
(run)]
|
||||
[(confgen)
|
||||
(local-require "setup/commands/confgen.rkt")
|
||||
(run)])
|
||||
|
|
1
setup/README.md
Normal file
1
setup/README.md
Normal file
|
@ -0,0 +1 @@
|
|||
Racket code for installing my dotfiles.
|
8
setup/commands/confgen.rkt
Normal file
8
setup/commands/confgen.rkt
Normal file
|
@ -0,0 +1,8 @@
|
|||
#lang racket
|
||||
(require "../common.rkt")
|
||||
(provide run)
|
||||
|
||||
(define (run)
|
||||
(rm "cgout")
|
||||
(cmd "confgen" "confgen.lua" "cgout")
|
||||
null)
|
23
setup/commands/install-lsps-paru.rkt
Normal file
23
setup/commands/install-lsps-paru.rkt
Normal file
|
@ -0,0 +1,23 @@
|
|||
#lang racket
|
||||
(require "../common.rkt")
|
||||
(provide run)
|
||||
|
||||
(define (run)
|
||||
(define lsp-packages
|
||||
(list "elixir-ls-git"
|
||||
"eslint"
|
||||
"jdtls"
|
||||
"lua-language-server"
|
||||
"shellcheck"
|
||||
"shfmt"
|
||||
"taplo-cli"
|
||||
"tidy"
|
||||
"vscode-langservers-extracted"
|
||||
"yaml-language-server"
|
||||
"zls-git"))
|
||||
|
||||
(apply cmd "paru" "-S" "--needed" "--noconfirm" lsp-packages)
|
||||
|
||||
(when (find-executable-path "opam")
|
||||
(cmd "opam" "install" "--yes" "ocaml-lsp-server" "ocamlformat"))
|
||||
null)
|
32
setup/commands/install-scripts.rkt
Normal file
32
setup/commands/install-scripts.rkt
Normal file
|
@ -0,0 +1,32 @@
|
|||
#lang racket
|
||||
(require "../common.rkt")
|
||||
(provide run)
|
||||
|
||||
(define (run)
|
||||
(define-logging mklink
|
||||
(λ (from to)
|
||||
(with-handlers ([exn:fail? (const #f)]) (delete-file to))
|
||||
(make-file-or-directory-link (normalize-path from) to)))
|
||||
|
||||
(define-logging install-zig-script
|
||||
(λ (path)
|
||||
(parameterize ([current-directory path] [log-calls #f])
|
||||
(cmd "zig" "build" "-p" (output-bin-path) "-Doptimize=ReleaseFast"))))
|
||||
|
||||
;; Symlink interpreted scripts
|
||||
(mklink "scripts/map-touch-display.rkt" (build-path (output-bin-path) "bin" "map-touch-display"))
|
||||
(mklink "scripts/playvid.rkt" (build-path (output-bin-path) "bin" "playvid"))
|
||||
(mklink "scripts/start-joshuto.sh" (build-path (output-bin-path) "bin" "start-joshuto"))
|
||||
(mklink "scripts/startriver.sh" (build-path (output-bin-path) "bin" "startriver"))
|
||||
(mklink "scripts/update-nvim-plugins.rkt"
|
||||
(build-path (output-bin-path) "bin" "update-nvim-plugins"))
|
||||
(mklink "scripts/withjava.sh" (build-path (output-bin-path) "bin" "withjava"))
|
||||
|
||||
;; Compile Zig scripts
|
||||
(install-zig-script "scripts/mzteinit")
|
||||
(install-zig-script "scripts/openbrowser")
|
||||
(install-zig-script "scripts/playtwitch")
|
||||
(install-zig-script "scripts/prompt")
|
||||
(install-zig-script "scripts/randomwallpaper")
|
||||
(install-zig-script "scripts/vinput")
|
||||
null)
|
10
setup/commands/setup-nvim-config.rkt
Normal file
10
setup/commands/setup-nvim-config.rkt
Normal file
|
@ -0,0 +1,10 @@
|
|||
#lang racket
|
||||
(require "../common.rkt")
|
||||
(provide run)
|
||||
|
||||
(define (run)
|
||||
(define nvim-config-dir (build-path (find-system-path 'home-dir) ".config" "nvim"))
|
||||
(rm nvim-config-dir)
|
||||
(copy "mzte-nv/conf" nvim-config-dir)
|
||||
(cmd "mzte-nv-compile" (path->string nvim-config-dir))
|
||||
null)
|
28
setup/common.rkt
Normal file
28
setup/common.rkt
Normal file
|
@ -0,0 +1,28 @@
|
|||
#lang racket
|
||||
|
||||
(provide define-logging
|
||||
log-calls
|
||||
output-bin-path
|
||||
cmd
|
||||
rm
|
||||
copy)
|
||||
|
||||
;; Whether to log calls or not
|
||||
(define log-calls (make-parameter #t))
|
||||
|
||||
;; Default output path
|
||||
(define output-bin-path (make-parameter (build-path (find-system-path 'home-dir) ".local")))
|
||||
|
||||
(define (display-function-call func args)
|
||||
(when (log-calls)
|
||||
(printf "(~s ~a)\n" func (apply ~a #:separator " " args))))
|
||||
|
||||
;; Defines an alias to a function which will log it's parameters on invokation.
|
||||
(define-syntax-rule (define-logging name func)
|
||||
(define (name . args)
|
||||
(display-function-call (quote name) args)
|
||||
(apply func args)))
|
||||
|
||||
(define-logging cmd (λ (exe . args) (apply system* (find-executable-path exe) args)))
|
||||
(define-logging rm delete-directory/files)
|
||||
(define-logging copy copy-directory/files)
|
Loading…
Add table
Reference in a new issue