Fix several discrepancies on dependencies

This commit is contained in:
Sameer Rahmani 2024-02-18 15:50:18 +00:00
parent 337ee36a1a
commit ffe7686470
Signed by: lxsameer
GPG Key ID: B0A4AF28AB9FD90B
8 changed files with 90 additions and 65 deletions

View File

@ -51,7 +51,5 @@
:after projectile)))
(provide 'cubes/project)
;;; project.el ends here

View File

@ -90,7 +90,6 @@ interactive `pyvenv-workon' function before `lsp'"
:flag-default t
(fpkg/use lsp-pyright
:ensure t
:after (python lsp-mode)
:hook
(python-mode . (lambda ()
@ -129,7 +128,6 @@ interactive `pyvenv-workon' function before `lsp'"
(pyvenv-post-deactivate-hooks . pyvenv-restart-python)))
(fpkg/use pyenv-mode
:ensure t
:after python
:hook
(python-mode-hook . pyenv-mode))

View File

@ -24,36 +24,46 @@
;; Simple package manager for FG42
;;
;;; Code:
;;(require 'use-package)
(require 'map)
(defvar package-names ())
(eval-when-compile
(defvar fg42-use-nix)) ;; defined in fg42-config.el
(defun inject-straight (args)
"Inject `:straight t' to ARGS it the key was missing."
(if (member :straight args)
args
(append args '(:straight t))))
(if fg42-use-nix
;; We don't use straight with nix
(map-delete args :straight)
(if (member :straight args)
args
(append args '(:straight t)))))
(defun inject-defer (args)
"Inject `:defer t' to ARGS it the key was missing."
(if (member :defer args)
args
(append args '(:defer t))))
(defun inject-params (args)
"Inject required `use-package' params to ARGS if the key is missing."
(if fg42-use-nix
(append '(:ensure nil) args)
;; (if (member :defer args)
;; args
;; (append args '(:defer t)))
args))
(defmacro fpkg/use (pkg &rest details)
"Install the given package DETAILS PKG via use-package and straight."
"Install the given package DETAILS PKG via `use-package' and straight."
(declare (indent defun))
(if (and (listp details) (< 0 (length details)))
(let ((params (inject-straight (inject-defer details))))
(progn
(add-to-list 'package-names pkg)
`(use-package ,pkg ,@params)))
(progn
(add-to-list 'package-names pkg)
`(use-package ,pkg :straight t :defer t))))
(let ((params (inject-straight (inject-params details))))
`(progn
(require ,pkg)
(use-package ,pkg ,@params)))
`(progn
(require ,pkg)
(use-package ,pkg :defer t :ensure nil))))
(defmacro fpkg/require (pkg)

View File

@ -36,28 +36,34 @@
(defun fpkg/install-and-load-use-package ()
"Install and load the use-package in compile time."
"Install and load the `use-package' in compile time."
;; TODO Enable use-package on compile time
;;(eval-when-compile)
(straight-use-package 'use-package)
(setq use-package-always-ensure t)
(if fg42-use-nix
(setq use-package-always-ensure nil)
(progn
(setq use-package-always-ensure t)
(straight-use-package 'use-package)))
(require 'use-package))
(defun fpkg/initialize ()
"Initialize FPKG."
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)))
(if (null fg42-use-nix)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage)
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage)
(fpkg/install-and-load-use-package))
(fpkg/install-and-load-use-package)))

View File

@ -71,18 +71,14 @@
poetry
lsp-pyright
python-black
lsp-java
flycheck-gradle
gradle-mode
groovy-mode
use-package
vterm
projectile-ripgrep
go-mode
company-box
company
lsp-ui

View File

@ -22,12 +22,21 @@
;;; Commentary:
;;; Code:
(setq debug-on-error t)
(defvar fg42-v3 "true")
(eval-when-compile
(defvar package-archives)
(defvar use-package-ensure-function))
(defvar fg42-use-nix (or (getenv "FG42_USE_NIX") nil))
(add-to-list 'load-path (concat (getenv "FG42_HOME") "/core"))
;; Prevent package.el to install anything at startup
(setq package-enable-at-startup nil)
(setq package-archives nil)
(when fg42-use-nix
(setq use-package-ensure-function 'ignore))
(setq tab-width 2)

View File

@ -26,6 +26,12 @@
inherit system;
overlays = [ inputs.emacs-overlay.overlays.package ];
};
lemacs = pkgs.emacs29.override {
withGTK3 = false;
toolkit = "lucid";
};
elispDepsFile = ./deps.el;
elispPkgs = pkgs.callPackage ./nix/deps.nix {
@ -37,18 +43,23 @@
fg42 = pkgs.callPackage ./nix/fg42.nix {
inherit elispPkgs ourPackages;
srcDir = ./.;
emacs = lemacs;
};
in {
inherit pkgs;
packages.emacs = fg42.emacsInUse;
packages.default = pkgs.writeScriptBin "fg42" ''
#!${pkgs.stdenv.shell}
export FG42_HOME=${fg42}/fg42
LIBRARY_PATH="$(cc -print-file-name=libgccjit.so):$LIBRARY_PATH" FG42_WM=false emacs \
export FG42_USE_NIX=true;
LIBRARY_PATH="$(cc -print-file-name=libgccjit.so):$LIBRARY_PATH" \
FG42_WM=false ${fg42.emacsInUse}/bin/emacs \
--name FG42 \
--no-site-file --no-site-lisp \
-q \
--no-splash --title FG42 \
-l $FG42_HOME/fg42-config.el "$@"
'';
@ -74,8 +85,10 @@
#export QT_IM_MODULE=xim
#export CLUTTER_IM_MODULE=xim
export FG42_USE_NIX=true;
export FG42_HOME=${fg42}/fg42
LIBRARY_PATH=$(cc -print-file-name=libgccjit.so):$LIBRARY_PATH FG42_WM=true emacs \
LIBRARY_PATH=$(cc -print-file-name=libgccjit.so):$LIBRARY_PATH \
FG42_WM=true ${fg42.emacsInUse}/bin/emacs \
--name FG42 \
--no-site-file --no-site-lisp \
--no-splash --title FG42 \

View File

@ -17,6 +17,7 @@
stdenv,
elispPkgs,
srcDir,
emacsPackagesFor,
emacsPackages,
ourPackages,
writeScriptBin,
@ -33,11 +34,16 @@
}:
with builtins;
let
getEpkg = (x: if hasAttr x emacsPackages
then getAttr x emacsPackages
else getAttr x ourPackages);
getEpkg = epkgs: x:
if hasAttr x epkgs
then getAttr x epkgs
else getAttr x ourPackages;
epkgs = (map getEpkg elispPkgs);
epkgSet = emacsPackagesFor emacs;
#epkgs = (map getEpkg elispPkgs);
emacsBundle = epkgSet.emacsWithPackages (epkgs:
(map (getEpkg epkgs) elispPkgs)
);
in stdenv.mkDerivation (final: rec{
pname = "fg42";
@ -46,8 +52,6 @@ in stdenv.mkDerivation (final: rec{
src = srcDir;
outputs = [ "out" ];
FG42_USE_NIX = true;
buildPhase = ''
mkdir -p $out/fg42
mkdir -p $out/bin/
@ -64,6 +68,7 @@ in stdenv.mkDerivation (final: rec{
runHook postBuild
'';
installPhase = ''
runHook preInstall
@ -75,26 +80,16 @@ in stdenv.mkDerivation (final: rec{
runHook postInstall
'';
# scripts = symlinkJoin {
# name = "fg42_scripts";
# paths = [
# editor
# wm
# ];
# };
#nativeBuildInputs = deps;
buildInputs = epkgs ++ [
propagatedUserEnvPkgs = [
emacsBundle
ripgrep
git
texinfo
vazir-fonts
fira-code
nerdfonts
#scripts
];
# depsTargetTarget = [
# pkgs.emacs
# ];
buildInputs = propagatedUserEnvPkgs;
emacsInUse = emacsBundle;
})