Finish up the first working flake to build FG42

This commit is contained in:
Sameer Rahmani 2024-02-20 14:53:50 +00:00
parent 6893e2d991
commit 82b377f00e
Signed by: lxsameer
GPG Key ID: B0A4AF28AB9FD90B
27 changed files with 205 additions and 360 deletions

3
.gitignore vendored
View File

@ -39,4 +39,5 @@ emacs.d/
docs/site/orgs/cubes/ docs/site/orgs/cubes/
**/*/sitemap.inc **/*/sitemap.inc
result result
v4/

71
dev.org
View File

@ -1,71 +0,0 @@
#+TITLE: FG42 Development
#+AUTHOR: Sameer Rahmani
#+SEQ_TODO: TODO(t/!) NEXT(n/!) BLOCKED(b@/!) | DONE(d%) WONT_DO(c@/!) FAILED(f@/!)
#+TAGS: DOCS(d) EXAMPLES(e) Misc(m) Lib(l)
#+STARTUP: logdrawer logdone logreschedule indent content align constSI entitiespretty nolatexpreview
#+OPTIONS: tex:t
#+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Eule
#+LATEX_CLASS: article
#+LATEX_CLASS_OPTIONS: [a4paper]
#+LATEX_HEADER: \usepackage{tcolorbox}
#+LATEX_HEADER: \usepackage{mathabx}
#+LATEX_HEADER: \newtcolorbox{infobox}[2][]{colback=cyan!5!white,before skip=14pt,after skip=8pt,colframe=cyan!75!black,sharp corners,title={#2},#1}
This document is dedicated to the resources, TODOs, research summary, ideas and whatever that is
part of the development process.
* Development Goals
In the past we tried many different ideas and features but since we didn't have a clear goal set,
we couldn't really make it work and differentiate good ideas from bad ones.
** Who are the target audience?
On the first level, I should feel comfortable with it.
** What set of features are important to us?
* Tools
** Straight
We gave it a shot before and it didn't work out but our requirements were different back then.
We should give it a shot again
* Libraries
** Midnight mode
It's a cool library that run some action every midnight, we can use it to clean up old buffers
or other maintenance jobs
* Tasks
** TODO =fpkg/use= doesn't work with =:init=
** TODO Add a =:default= key to the cube indicating whether it should be enabled by default or not
** TODO Reformat the modeline
** TODO Create a macro similar to =with-ability= to run a block of code only if the given cube was active
** TODO Enable =straight= and =use-package= integration on compile time. Checout out =fpkg/core.el=
** TODO Check the =dracula= theme settings and configurations
** TODO Add support for MacOS by create a cube with the following content
#+BEGIN_SRC elisp
(package-install 'exec-path-from-shell)
(exec-path-from-shell-initialize)
#+END_SRC
** TODO Integrate window-purpose mode
** TODO Turn on yasnippet mode for Go mode
* Things that didn't work out
- rbenv
- helm
- linum
- tabbar
- ido
- ivy
- spaceline
- doom-modeline
- smart-mode-line
- desktop-mode
- jedi
- file-browser
- dired+
- guru
- emoji
- elpy
- github
- versioned-backup

View File

@ -28,11 +28,12 @@
}; };
lemacs = pkgs.emacs29.override { lemacs = pkgs.emacs29.override {
# Gtk causes a flickering issue on WM mode
withGTK3 = false; withGTK3 = false;
toolkit = "lucid"; toolkit = "lucid";
}; };
elispDepsFile = ./deps.el; elispDepsFile = ./lisp/fg42/deps.el;
elispPkgs = pkgs.callPackage ./nix/deps.nix { elispPkgs = pkgs.callPackage ./nix/deps.nix {
inherit elispDepsFile; inherit elispDepsFile;
@ -41,7 +42,7 @@
ourPackages = pkgs.callPackage ./nix/packages.nix {}; ourPackages = pkgs.callPackage ./nix/packages.nix {};
fg42 = pkgs.callPackage ./nix/fg42.nix { fg42 = pkgs.callPackage ./nix/fg42.nix {
inherit elispPkgs ourPackages; inherit elispPkgs ourPackages nixpkgs;
srcDir = ./.; srcDir = ./.;
emacs = lemacs; emacs = lemacs;
}; };
@ -49,58 +50,15 @@
in { in {
inherit pkgs; inherit pkgs;
packages.emacs = fg42.emacsInUse; packages.default = fg42;
packages.default = pkgs.writeScriptBin "fg42" ''
#!${pkgs.stdenv.shell}
export FG42_HOME=${fg42}/fg42 devShells.default = pkgs.mkShell {
export FG42_USE_NIX=true; nativeBuildInputs = [ fg42 pkgs.fish ];
buildInputs = [ fg42 ];
LIBRARY_PATH="$(cc -print-file-name=libgccjit.so):$LIBRARY_PATH" \ shellHook = ''
FG42_WM=false ${fg42.emacsInUse}/bin/emacs \ fish && exit
--name FG42 \ '';
-q \ };
--no-splash --title FG42 \
-l $FG42_HOME/fg42-config.el "$@"
'';
packages.wm = pkgs.writeScriptBin "fg42-wm" ''
#!${pkgs.stdenv.shell}
# Disable access control for the current user.
xhost +SI:localuser:$USER
# Make Java applications aware this is a non-reparenting window manager.
export _JAVA_AWT_WM_NONREPARENTING=1
# Set default cursor.
xsetroot -cursor_name left_ptr
# Set keyboard repeat rate.
xset r rate 400 30
# Uncomment the following block to use the exwm-xim module.
#export XMODIFIERS=@im=exwm-xim
#export GTK_IM_MODULE=xim
#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 ${fg42.emacsInUse}/bin/emacs \
--name FG42 \
--no-site-file --no-site-lisp \
--no-splash --title FG42 \
-l $FG42_HOME/fg42-config.el "$@"
'';
# devShells.default = pkgs.mkShell {
# nativeBuildInputs = deps ++ [ pkgs.fish ];
# shellHook = ''
# fish && exit
# '';
# };
} }
); );
} }

View File

@ -47,9 +47,11 @@
;; (fg42/-startup-optimization) ;; (fg42/-startup-optimization)
(require 'fpkg/core) (require 'fpkg/core)
(fpkg/initialize) (fpkg/initialize)
(when (file-exists-p user-init-file) (when (file-exists-p user-init-file)
(require 'fg42/cube) (require 'fg42/cube)
(load user-init-file)) (load user-init-file))
(add-hook 'emacs-startup-hook (add-hook 'emacs-startup-hook
(lambda () (lambda ()
(run-hooks 'fg42/-cubes-body-hook) (run-hooks 'fg42/-cubes-body-hook)

View File

@ -31,11 +31,14 @@
(defvar fg42/debug-p nil (defvar fg42/debug-p nil
"The hook tha runs when FG42 finished running the user configuration.") "The hook tha runs when FG42 finished running the user configuration.")
(defvar fg42-config-dir (or (getenv "FG42_CONFIG_DIR") "~/.fg42")
"Where to store installation specific data.")
(defvar fg42-home (getenv "FG42_HOME") (defvar fg42-home (getenv "FG42_HOME")
"The pass to fg42-home.") "The pass to fg42-home.")
(defvar fg42-tmp (concat fg42-home "/tmp")) (defvar fg42-tmp (concat fg42-config-dir "/tmp"))
(provide 'fg42/core) (provide 'fg42/core)

View File

@ -32,6 +32,7 @@
(fpkg/use flycheck (fpkg/use flycheck
:defer () :defer ()
:init :init
(require 'flycheck)
(global-flycheck-mode))) (global-flycheck-mode)))

View File

@ -44,6 +44,7 @@
(eval (eval
`(fpkg/use bm `(fpkg/use bm
:init :init
(require 'bm)
;; restore on load (even before you require bm) ;; restore on load (even before you require bm)
(setq bm-restore-repository-on-load t) (setq bm-restore-repository-on-load t)

View File

@ -58,6 +58,7 @@ It not only gives Dired an appealing and highly customizable user interface,
but also comes together with almost all possible parts required for full usability but also comes together with almost all possible parts required for full usability
as a modern file manager." as a modern file manager."
:init :init
(require 'dirvish)
(dirvish-override-dired-mode)) (dirvish-override-dired-mode))
@ -96,6 +97,7 @@ contextual information."
(fpkg/use pinentry (fpkg/use pinentry
:init :init
(progn (progn
(require 'pinentry)
(setq epa-pinentry-mode 'loopback) (setq epa-pinentry-mode 'loopback)
(pinentry-start)))) (pinentry-start))))
@ -278,12 +280,14 @@ https://emacsthemes.com/themes/badwolf-theme.html"
(fpkg/use selectrum (fpkg/use selectrum
:defer nil :defer nil
:init :init
(require 'selectrum)
(selectrum-mode +1)) (selectrum-mode +1))
(fpkg/use selectrum-prescient (fpkg/use selectrum-prescient
:defer t :defer t
:init :init
(progn (progn
(require 'selectrum-prescient)
(setq prescient-filter-method '(literal fuzzy regexp initialism)) (setq prescient-filter-method '(literal fuzzy regexp initialism))
(selectrum-prescient-mode +1) (selectrum-prescient-mode +1)
(prescient-persist-mode +1))) (prescient-persist-mode +1)))
@ -292,6 +296,7 @@ https://emacsthemes.com/themes/badwolf-theme.html"
(fpkg/use ctrlf (fpkg/use ctrlf
:defer t :defer t
:init :init
(require 'ctrlf)
(ctrlf-mode +1))) (ctrlf-mode +1)))

View File

@ -36,6 +36,7 @@
(fpkg/use eros (fpkg/use eros
:init :init
(require 'eros)
(eros-mode)) (eros-mode))
(add-hook 'emacs-lisp-mode-hook #'rainbow-delimiters-mode)) (add-hook 'emacs-lisp-mode-hook #'rainbow-delimiters-mode))

View File

@ -43,6 +43,7 @@ For more info check out [[https://github.com/dgutov/diff-hl][diff-hl]] 's page."
(fpkg/use diff-hl (fpkg/use diff-hl
:init :init
(progn (progn
(require 'diff-hl)
(when-flag git (when-flag git
(add-hook 'magit-pre-refresh-hook 'diff-hl-magit-pre-refresh) (add-hook 'magit-pre-refresh-hook 'diff-hl-magit-pre-refresh)
(add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)) (add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh))

View File

@ -37,5 +37,5 @@ package."
:if (display-graphic-p))) :if (display-graphic-p)))
(provide 'fg42/cubes/icons) (provide 'fg42/cubes/iconspack)
;;; icons.el ends here ;;; iconspack.el ends here

View File

@ -23,7 +23,7 @@
;;; Code: ;;; Code:
(require 'fpkg) (require 'fpkg)
(require 'fg42/cube) (require 'fg42/cube)
(require 'fg42/cubes/icons) (require 'fg42/cubes/iconspack)
(autoload-cube 'fg42/statusbar-default (autoload-cube 'fg42/statusbar-default
"modeline/statusbar-default.el" "modeline/statusbar-default.el"
@ -68,6 +68,7 @@ to Emacs modeline."
:defer nil :defer nil
:init :init
(progn (progn
(require 'smart-mode-line)
(setq sml/theme 'respectful) (setq sml/theme 'respectful)
(setq sml/no-confirm-load-theme t) (setq sml/no-confirm-load-theme t)
(sml/setup)))) (sml/setup))))
@ -110,6 +111,7 @@ to Emacs modeline."
:after smart-mode-line :after smart-mode-line
:init :init
(progn (progn
(require 'smart-mode-line)
(setq mini-modeline-enhance-visual nil) (setq mini-modeline-enhance-visual nil)
(setq fg42/modeline-setter #'fg42/mini-modeline-setter)) (setq fg42/modeline-setter #'fg42/mini-modeline-setter))
:defer nil :defer nil

View File

@ -23,17 +23,17 @@
;;; Code: ;;; Code:
(require 'fpkg) (require 'fpkg)
(require 'fg42/cube) (require 'fg42/cube)
(require 'fg42/cubes/icons) (require 'fg42/cubes/iconspack)
(->cube noether-mode (->cube noether
"Smart mode line is a pretty simple yet fantastic alternative "Smart mode line is a pretty simple yet fantastic alternative
to Emacs modeline." to Emacs modeline."
:straight (noether-mode :repo "https://devheroes.codes/lxsameer/noether.git") :straight (noether :repo "https://devheroes.codes/lxsameer/noether.git")
:init :init
(require 'noether) (require 'noether)
(require 'noether-views) (require 'noether-views)
(let ((views (or (plist-get fg42/noether-mode-cube-params :views) (let ((views (or (plist-get fg42/noether-cube-params :views)
(list (list
noether-minimal-mode-line noether-minimal-mode-line
noether-minimal-location noether-minimal-location

View File

@ -83,6 +83,7 @@ For more information checkout [[https://github.com/alphapapa/org-super-agenda]]"
:after org-agenda :after org-agenda
:init :init
(progn (progn
(require 'org-super-agenda)
(setq org-agenda-skip-scheduled-if-done (or (plist-get params :skip-scheduled-if-done) t) (setq org-agenda-skip-scheduled-if-done (or (plist-get params :skip-scheduled-if-done) t)
org-agenda-skip-deadline-if-done (or (plist-get params :skip-deadline-if-done) t) org-agenda-skip-deadline-if-done (or (plist-get params :skip-deadline-if-done) t)
org-agenda-include-deadlines (or (plist-get params :include-deadline) t) org-agenda-include-deadlines (or (plist-get params :include-deadline) t)
@ -127,6 +128,7 @@ shows items in the narrowed portion; this allows seeing an overview of tasks in
(if-flag org-ql (if-flag org-ql
(fpkg/use org-sidebar (fpkg/use org-sidebar
:init :init
(require 'org-sidebar)
(setq org-sidebar-default-fns fns) (setq org-sidebar-default-fns fns)
:bind :bind
(("<f9>" . fg42/org-sidebar-toggle-sidebar-default))) (("<f9>" . fg42/org-sidebar-toggle-sidebar-default)))
@ -178,6 +180,7 @@ For more info on ~org-mode~ check out [[https://orgmode.org/]]"
(fpkg/use org-journal (fpkg/use org-journal
:defer t :defer t
:init :init
(require 'org-journal)
;; Change default prefix key; needs to be set before loading org-journal ;; Change default prefix key; needs to be set before loading org-journal
(setq org-journal-prefix-key "C-c j ") (setq org-journal-prefix-key "C-c j ")
:config :config
@ -187,9 +190,10 @@ For more info on ~org-mode~ check out [[https://orgmode.org/]]"
org-journal-date-format "%Y-%m-%d (%A): "))) org-journal-date-format "%Y-%m-%d (%A): ")))
(fpkg/use org-mode (fpkg/use org
:init :init
(progn (progn
(require 'org)
(require 'org-capture) (require 'org-capture)
(global-set-key capture-key 'org-capture) (global-set-key capture-key 'org-capture)
(setq org-tag-alist global-tags) (setq org-tag-alist global-tags)

View File

@ -25,7 +25,6 @@
(require 'fg42/cube) (require 'fg42/cube)
(defcube fg42/projectile-cube (defcube fg42/projectile-cube
"Projectile Cube" "Projectile Cube"
:title "fg42/cubes/fg42/projectile-cube.org" :title "fg42/cubes/fg42/projectile-cube.org"
@ -36,6 +35,7 @@
()))) ())))
(fpkg/use projectile (fpkg/use projectile
:init :init
(require 'projectile)
(projectile-mode +1) (projectile-mode +1)
:config :config
(progn (progn

View File

@ -34,9 +34,11 @@
(fpkg/use yasnippet (fpkg/use yasnippet
:init :init
(require 'yasnippet)
(let* ((snippet-home (expand-file-name "snippets" (let* ((snippet-home (expand-file-name "snippets"
(file-name-directory (locate-library "yasnippet-snippets")))) (file-name-directory (locate-library "yasnippet-snippets"))))
(local-snippet (expand-file-name "core/fg42/cubes/snippets" fg42-home)) (local-snippet (expand-file-name
"lisp/fg42/cubes/snippets" fg42-home))
(user-snippets (or (plist-get fg42/yasnippet-cube-params :snippets-dir) (user-snippets (or (plist-get fg42/yasnippet-cube-params :snippets-dir)
;; Just to make sure that we don't return nil. Since ;; Just to make sure that we don't return nil. Since
;; yas-snippet-dirs shoud not contain nil value ;; yas-snippet-dirs shoud not contain nil value

View File

@ -33,6 +33,7 @@
(fpkg/use vterm (fpkg/use vterm
:init :init
(progn (progn
(require 'vterm)
(setq vterm-shell _shell))))) (setq vterm-shell _shell)))))

View File

@ -36,6 +36,7 @@
(fpkg/use dracula-theme (fpkg/use dracula-theme
:init :init
(fg42/setup-theme (fg42/setup-theme
(require 'dracula-theme)
(load-theme 'dracula t) (load-theme 'dracula t)
(custom-theme-set-faces (custom-theme-set-faces
'dracula 'dracula

View File

@ -118,4 +118,5 @@
all-the-icons all-the-icons
) )
(provide 'fg42/deps)
;;; deps.el ends here ;;; deps.el ends here

View File

@ -20,8 +20,10 @@
;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;; ;;
;;; Commentary: ;;; Commentary:
;; This is the very first file that Emacs will load to setup FG42
;;; Code: ;;; Code:
(setq debug-on-error t) (when (string= (getenv "FG42_DEBUG") "1")
(setq debug-on-error t))
(eval-when-compile (eval-when-compile
(defvar package-archives) (defvar package-archives)
@ -29,7 +31,9 @@
(defvar fg42-use-nix (or (getenv "FG42_USE_NIX") nil)) (defvar fg42-use-nix (or (getenv "FG42_USE_NIX") nil))
(add-to-list 'load-path (concat (getenv "FG42_HOME") "/core")) ;; (when fg42-use-nix
;; (require 'site-start))
(add-to-list 'load-path (concat (getenv "FG42_HOME") "/lisp"))
;; Prevent package.el to install anything at startup ;; Prevent package.el to install anything at startup
(setq package-enable-at-startup nil) (setq package-enable-at-startup nil)
@ -40,7 +44,7 @@
(setq tab-width 2) (setq tab-width 2)
(let ((emacsd (or (getenv "FG42_EMACSD") "~/.fg42/emacs.d"))) (let ((emacsd (or (getenv "FG42_EMACSD") (format "%s/emacs.d" (getenv "FG42_HOME")))))
(setq custom-file (format "%s/.fg42.custom.el" emacsd)) (setq custom-file (format "%s/.fg42.custom.el" emacsd))
(setq user-emacs-directory emacsd) (setq user-emacs-directory emacsd)
(setq user-init-file (setq user-init-file
@ -48,7 +52,6 @@
(format "%s/.fg42.el" (format "%s/.fg42.el"
(getenv "HOME"))))) (getenv "HOME")))))
;; Load the customization file. In FG42 it is different than ;; Load the customization file. In FG42 it is different than
;; the default `user-init-file' ;; the default `user-init-file'
(if (file-exists-p custom-file) (if (file-exists-p custom-file)
@ -57,5 +60,5 @@
(require 'fg42) (require 'fg42)
(fg42/initialize) (fg42/initialize)
(provide 'fg42-config) (provide 'fg42/init)
;;; fg42-config.el ends here ;;; init.el ends here

View File

@ -27,7 +27,7 @@
(require 'fpkg) (require 'fpkg)
(require 'fg42/flags) (require 'fg42/flags)
(fpkg/require 'projectile) ;;(fpkg/require 'projectile)
(fpkg/require 'f) (fpkg/require 'f)
(defflag fg42-project (defflag fg42-project

View File

@ -56,22 +56,22 @@
"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)) (declare (indent defun))
(if (and (listp details) (< 0 (length details))) (if (and (listp details) (< 0 (length details)))
(let ((params (inject-straight (inject-params details)))) (let ((p (inject-straight (inject-params details))))
`(progn
`(progn (use-package ,pkg ,@p)))
(require ,pkg)
(use-package ,pkg ,@params)))
`(progn `(progn
(require ,pkg) (use-package ,pkg :defer t :ensure nil))))
(use-package ,pkg :defer t :ensure nil))))
(defmacro fpkg/require (pkg) (defmacro fpkg/require (pkg)
"Work like require but make sure that PKG is installed first." "Work like require but make sure that PKG is installed first."
(let ((pkg-name (intern (symbol-name `,(cadr pkg))))) (let ((pkg-name (intern (symbol-name `,(cadr pkg)))))
`(fpkg/use ,pkg-name (if fg42-use-nix
:init `(require ,pkg)
(require ,pkg)))) `(fpkg/use ,pkg-name
:init
(require ,pkg)))))
(provide 'fpkg) (provide 'fpkg)
;;; fpkg.el ends here ;;; fpkg.el ends here

View File

@ -29,11 +29,6 @@
(defvar bootstrap-version 5) (defvar bootstrap-version 5)
(defcustom fpkg-package-directory (concat fg42-home "/.fpkg")
"Specify the directory to store all the dependencies."
:group 'fpkg
:type 'string)
(defun fpkg/install-and-load-use-package () (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."

View File

@ -14,13 +14,14 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
{ {
lib,
nixpkgs,
stdenv, stdenv,
elispPkgs, elispPkgs,
srcDir, srcDir,
emacsPackagesFor, emacsPackagesFor,
emacsPackages,
ourPackages, ourPackages,
writeScriptBin, writeText,
symlinkJoin, symlinkJoin,
# This is a set of system tools required for FG42 # This is a set of system tools required for FG42
# to work. # to work.
@ -31,65 +32,138 @@
vazir-fonts, vazir-fonts,
fira-code, fira-code,
nerdfonts, nerdfonts,
gcc,
ltex-ls,
}: }:
with builtins; with builtins;
let
getEpkg = epkgs: x:
if hasAttr x epkgs
then getAttr x epkgs
else getAttr x ourPackages;
epkgSet = emacsPackagesFor emacs; stdenv.mkDerivation (final:
#epkgs = (map getEpkg elispPkgs); let
emacsBundle = epkgSet.emacsWithPackages (epkgs: getPkg = epkgs: pkg:
(map (getEpkg epkgs) elispPkgs) if hasAttr pkg epkgs
); then getAttr pkg epkgs
else getAttr pkg ourPackages;
in stdenv.mkDerivation (final: rec{ emacsBundle = (emacsPackagesFor emacs).withPackages (epkgs:
pname = "fg42"; (map (x: getPkg epkgs x) elispPkgs)
version = "4.0.0"; );
src = srcDir; maintainers = import ./maintainers.nix;
outputs = [ "out" ];
buildPhase = '' in rec{
mkdir -p $out/fg42 pname = "fg42";
mkdir -p $out/bin/ version = "4.0.0";
cp -rv ${src}/core $out/fg42/ src = srcDir;
cp -rv ${src}/share $out/ outputs = [ "out" ];
runHook preBuild buildPhase = ''
cd $out/fg42 LISPDIR=$out/share/fg42/
emacs -L . --batch -f batch-byte-compile *.el mkdir -p $out/bin
cd - install -d $LISPDIR
cp -v ${src}/fg42-config.el $out/fg42/ cp -rv ${src}/lisp/ $LISPDIR
cp -rv ${src}/share $out/
runHook postBuild runHook preBuild
''; cd $LISPDIR
emacs -L . --batch -f batch-byte-compile *.el
cd -
installPhase = '' cat >> $out/bin/fg42 << EOF
runHook preInstall #!${stdenv.shell}
# LISPDIR=$out/share/emacs/site-lisp export FG42_HOME=${placeholder "out"}/share/fg42/
# install -d $LISPDIR export FG42_EMACSD=~/.fg42/v4/emacs.d
# install *.el *.elc $LISPDIR export FG42_USE_NIX=true;
emacs --batch -l package --eval "(package-generate-autoloads \"${pname}\" \"$out/fg42\")"
runHook postInstall LIBRARY_PATH="\$(cc -print-file-name=libgccjit.so):\$LIBRARY_PATH" \
''; FG42_WM=false ${emacsBundle}/bin/emacs \
--name FG42 \
-q --no-splash --title FG42 \
-l \$FG42_HOME/lisp/fg42/init.el "\$@"
EOF
chmod +x $out/bin/fg42
propagatedUserEnvPkgs = [ cat >> $out/bin/fg42-wm << EOF
emacsBundle #!${stdenv.shell}
ripgrep
git
texinfo
vazir-fonts
fira-code
nerdfonts
];
buildInputs = propagatedUserEnvPkgs;
emacsInUse = emacsBundle; export FG42_HOME=${placeholder "out"}/share/fg42/
}) export FG42_EMACSD=~/.fg42/v4/emacs.d
export FG42_USE_NIX=true;
# Disable access control for the current user.
xhost +SI:localuser:$USER
# Make Java applications aware this is a non-reparenting window manager.
export _JAVA_AWT_WM_NONREPARENTING=1
# Set default cursor.
xsetroot -cursor_name left_ptr
# Set keyboard repeat rate.
xset r rate 400 30
# Uncomment the following block to use the exwm-xim module.
# export XMODIFIERS=@im=exwm-xim
# export GTK_IM_MODULE=xim
# export QT_IM_MODULE=xim
# export CLUTTER_IM_MODULE=xim
LIBRARY_PATH="\$(cc -print-file-name=libgccjit.so):\$LIBRARY_PATH" \
FG42_WM=true ${emacsBundle}/bin/emacs \
--name FG42 \
-q --no-splash --title FG42 \
-l \$FG42_HOME/lisp/fg42/init.el "\$@"
EOF
chmod +x $out/bin/fg42-wm
runHook postBuild
'';
installPhase = ''
runHook preInstall
#LISPDIR=$out/share/fg42/lisp/
#emacs --batch -l package --eval "(package-generate-autoloads \"${pname}\" \"$LISPDIR\")"
runHook postInstall
'';
buildInputs = [
gcc
emacs
texinfo
emacsBundle
ripgrep
git
texinfo
vazir-fonts
fira-code
nerdfonts
gcc
ltex-ls
];
addEmacsNativeLoadPath = true;
meta = {
broken = false;
platforms = emacs.meta.platforms;
homepage = "https://fg42.org/";
maintainers = [ maintainers.lxsameer ];
description = "The mighty editor for the emacsians";
longDescription = ''
FG42 is a framework to create and editor and window manager based on GNU/Emacs.
It has a pre-defined setup as well which can be installed out of the box. But the
goal of this project is to provide the API necessary to create an integrated editor.
So you need to know about Emacs in advance.
'';
license = lib.licenses.gpl3Plus;
};
})

View File

@ -1,4 +1,3 @@
#! /bin/sh
# Fg42 - Emacs Editor for advance users # Fg42 - Emacs Editor for advance users
# #
# Copyright (c) 2010-2024 Sameer Rahmani <lxsameer@gnu.org> # Copyright (c) 2010-2024 Sameer Rahmani <lxsameer@gnu.org>
@ -15,5 +14,15 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
export FG42_HOME=___FG42_HOME___ {
LIBRARY_PATH=$(cc -print-file-name=libgccjit.so):$LIBRARY_PATH FG42_WM=false ${EMACS_PATH:-emacs} --name FG42 --no-site-file --no-site-lisp --no-splash --title FG42 -l $FG42_HOME/fg42-config.el "$@" lxsameer = {
email = "lxsameer@lxsameer.com";
github = "lxsameer";
git = "lxsameer";
matrix = "@lxsameer:matrix.org";
name = "Sameer Rahmani";
keys = [{
fingerprint = "6F3F A93B 4BD9 C3CA EF38 77E6 384A 12C3 1023 3CC5";
}];
};
}

View File

@ -1,112 +0,0 @@
#! /bin/bash
# Fg42 - Emacs Editor for advance users
#
# Copyright (c) 2010-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
current=$(cd "$(dirname "$0")/." >/dev/null 2>&1 ; pwd -P)
fg42_home="$current/.."
# Coloring Functions
info() {
if [ "$1" ]
then
echo "[\033[01;32mINFO\033[00m]: $1"
fi
}
error() {
if [ "$1" ]
then
echo "[\033[01;31mERR\033[00m]: $1"
fi
}
warn() {
if [ "$1" ]
then
echo "[\033[01;33mWARN\033[00m]: $1"
fi
}
install_fonts() {
info "Downloading and installing fonts..."
mkdir -p ~/.fonts
wget "https://dl.fg42.org/fonts/0.1.0.tar.gz" -O ~/.fonts/fg42.tar.gz
tar zxf ~/.fonts/fg42.tar.gz -C ~/.fonts --strip 1
cp -r "$fg42_home/share/fonts/vazir/*" ~/.fonts/
info "Font installation is done."
}
install_runners() {
info "Creating the runner scripts..."
cp "$current/templates/fg42" "$current/../fg42"
cp "$current/templates/fg42-wm" "$current/../fg42-wm"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sed -i "s'___FG42_HOME___'$fg42_home'" "$fg42_home/fg42"
sed -i "s'___FG42_HOME___'$fg42_home'" "$fg42_home/fg42-wm"
fi
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i'' -e "s'___FG42_HOME___'$fg42_home'" "$fg42_home/fg42"
sed -i'' -e "s'___FG42_HOME___'$fg42_home'" "$fg42_home/fg42-wm"
fi
chmod +x "$fg42_home/fg42"
chmod +x "$fg42_home/fg42-wm"
info "Copying conifg file to ~/.fg42.el..."
cp "$fg42_home/config/fg42.user.el" ~/.fg42.el
info "Installing the runners..."
sudo mkdir -p /usr/local/bin/
sudo rm -f /usr/local/bin/fg42
sudo rm -f /usr/local/bin/fg42-wm
sudo ln -s "$fg42_home/fg42" /usr/local/bin/fg42
sudo ln -s "$fg42_home/fg42-wm" /usr/local/bin/fg42-wm
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
info "Copying share files..."
sudo mkdir -p /usr/share/fg42/
sudo mkdir -p /usr/local/share/applications
sudo cp "$fg42_home/share/applications/fg42.desktop" /usr/local/share/applications
sudo cp -r "$fg42_home/share/icons/hicolor/" /usr/local/share/icons
sudo cp -r "$fg42_home/share/*" /usr/share/fg42/
sudo mkdir -p /usr/share/xsessions/
sudo cp -r "$fg42_home/share/xsessions/fg42.desktop" /usr/share/xsessions/
else
info "Skipping share files since this is not a Linux env..."
fi
}
install_extras() {
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
info "Copying share files..."
sudo mkdir -p /usr/share/fg42/
sudo cp "$fg42_home/share/applications/fg42.desktop" /usr/local/share/applications
sudo cp -r "$fg42_home/share/icons/hicolor/" /usr/local/share/icons
sudo cp -r "$fg42_home/share/*" /usr/share/fg42/
sudo cp -r "$fg42_home/share/xsessions/fg42.desktop" /usr/share/xsessions/
else
info "Skipping share files since this is not a Linux env..."
fi
}
eval "install_$1"

View File

@ -1,37 +0,0 @@
#! /bin/sh
# Fg42 - Emacs Editor for advance users
#
# Copyright (c) 2010-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Disable access control for the current user.
xhost +SI:localuser:$USER
# Make Java applications aware this is a non-reparenting window manager.
export _JAVA_AWT_WM_NONREPARENTING=1
# Set default cursor.
xsetroot -cursor_name left_ptr
# Set keyboard repeat rate.
xset r rate 400 30
# Uncomment the following block to use the exwm-xim module.
#export XMODIFIERS=@im=exwm-xim
#export GTK_IM_MODULE=xim
#export QT_IM_MODULE=xim
#export CLUTTER_IM_MODULE=xim
export FG42_HOME=___FG42_HOME___
LIBRARY_PATH=$(cc -print-file-name=libgccjit.so):$LIBRARY_PATH FG42_WM=true ${EMACS_PATH:-emacs} --name FG42 --no-site-file --no-site-lisp --no-splash --title FG42 -l $FG42_HOME/fg42-config.el "$@"