forked from FG42/FG42
Revert fpkg to use package.el temporary until we finish Enma
This commit is contained in:
parent
2c1b503a8f
commit
a5f30d0ecc
84
lib/fpkg.el
84
lib/fpkg.el
|
@ -39,39 +39,59 @@
|
||||||
(source 'elpa))
|
(source 'elpa))
|
||||||
|
|
||||||
|
|
||||||
(defvar bootstrap-version nil
|
|
||||||
"Bootstrap version of straight. This var is used in straight's installer.")
|
|
||||||
|
|
||||||
|
|
||||||
(defvar fpkg-packages-path
|
|
||||||
(expand-file-name ".fpkg/" fg42-home)
|
|
||||||
"The path to the directory which FPKG will use to store that packages.")
|
|
||||||
|
|
||||||
(defvar fpkg-initilized-p nil
|
(defvar fpkg-initilized-p nil
|
||||||
"A boolean flag that indicates whether FPKG is initialized or not.")
|
"A boolean flag that indicates whether FPKG is initialized or not.")
|
||||||
|
|
||||||
|
|
||||||
(defvar required-packages (make-hash-table)
|
(defvar required-packages (make-hash-table)
|
||||||
"A hash of `fg42-package structure representing required packages.")
|
"A hash of `fg42-package structure representing required packages.")
|
||||||
|
|
||||||
|
|
||||||
;; Functions ----------------------------------
|
;; Functions ----------------------------------
|
||||||
(defun fpkg-initialize ()
|
(defun all-dependencies-installed? ()
|
||||||
"Initilize the straight.e package manager and setup necessary hooks."
|
"Return t if all the dependencies installed."
|
||||||
(let ((bootstrap-file (concat fpkg-packages-path
|
(let ((result t))
|
||||||
"straight/repos/straight.el/bootstrap.el"))
|
(dolist (pkg (hash-table-keys required-packages))
|
||||||
(bootstrap-version 5))
|
(when (not (package-installed-p pkg))
|
||||||
|
(message "'%s' package is not installed" pkg)
|
||||||
|
(setq result nil)))
|
||||||
|
result))
|
||||||
|
|
||||||
(make-directory fpkg-packages-path t)
|
|
||||||
(setq straight-base-dir fpkg-packages-path)
|
(defun install--package (pkg)
|
||||||
(setq straight-use-package-by-default t)
|
"Intall the package PKG via its propreate source."
|
||||||
(if (not (file-exists-p bootstrap-file))
|
(let* ((source (fpkg-dependency-source pkg))
|
||||||
(with-current-buffer
|
(func-name (concat "install-package-via-" (symbol-name source)))
|
||||||
(url-retrieve-synchronously
|
(install-func (symbol-function (intern func-name))))
|
||||||
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
|
(funcall install-func pkg)))
|
||||||
'silent 'inhibit-cookies)
|
|
||||||
(goto-char (point-max))
|
|
||||||
(eval-print-last-sexp))
|
(defun fpkg-initialize ()
|
||||||
(load bootstrap-file nil 'nomessage))))
|
"Initilize the `package.el' and related stuff to be used in FG42."
|
||||||
|
(let ((packages (hash-table-values required-packages)))
|
||||||
|
|
||||||
|
(require 'package)
|
||||||
|
|
||||||
|
(add-to-list 'package-archives
|
||||||
|
'("melpa" . "http://melpa.org/packages/") t)
|
||||||
|
(when (< emacs-major-version 24)
|
||||||
|
;; For important compatibility libraries like cl-lib
|
||||||
|
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
|
||||||
|
|
||||||
|
;; Initialize package.el
|
||||||
|
(package-initialize)
|
||||||
|
|
||||||
|
(setq url-http-attempt-keepalives nil)
|
||||||
|
|
||||||
|
(unless (all-dependencies-installed?)
|
||||||
|
;; check for new packages (package versions)
|
||||||
|
(message "%s" "Refreshing package database...")
|
||||||
|
(package-refresh-contents)
|
||||||
|
|
||||||
|
;; install the missing packages
|
||||||
|
(dolist (pkg packages)
|
||||||
|
(when (not (package-installed-p (fpkg-dependency-name pkg)))
|
||||||
|
(install--package pkg))))))
|
||||||
|
|
||||||
|
|
||||||
(defun fpkg-initialize-once ()
|
(defun fpkg-initialize-once ()
|
||||||
|
@ -105,18 +125,10 @@
|
||||||
`(fg42-install-extension ,(eval pkgname))
|
`(fg42-install-extension ,(eval pkgname))
|
||||||
`(use-package ,(eval pkgname) ,@details)))
|
`(use-package ,(eval pkgname) ,@details)))
|
||||||
|
|
||||||
(comment
|
(defun depends-on (pkgname &rest args)
|
||||||
;; depends on now is a wrapper around use-package
|
"Install the package PKGNAME with respect to the ARGS."
|
||||||
(macroexpand-1 '(depends-on 'exwm))
|
(let ((pkg (apply 'make-fpkg-dependency :name pkgname args)))
|
||||||
(macroexpand-1 '(depends-on 'go-mode :mode "\\.go\\'"))
|
(puthash pkgname pkg required-packages)))
|
||||||
(macroexpand-1 '(depends-on 'devops-extension))
|
|
||||||
(macroexpand-1 '(fg42-install-extension devops-extension))
|
|
||||||
;; compatible with old calls
|
|
||||||
(macroexpand-1 '(depends-on 'cyberpunk-theme))
|
|
||||||
;; official extension
|
|
||||||
(depends-on 'devops-extension)
|
|
||||||
;; 3rd party extension
|
|
||||||
(depends-on 'go-extension :straight (go-extension :host gitlab :repo "amirrezaask/go-extension")))
|
|
||||||
|
|
||||||
|
|
||||||
(provide 'fpkg)
|
(provide 'fpkg)
|
||||||
|
|
Loading…
Reference in New Issue