From 82b377f00e1d8802233d79202bb29e4f33c538ac Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Tue, 20 Feb 2024 14:53:50 +0000 Subject: [PATCH] Finish up the first working flake to build FG42 --- .gitignore | 3 +- dev.org | 71 -------- flake.nix | 64 ++----- lisp/fg42.el | 2 + lisp/fg42/core.el | 5 +- lisp/fg42/cubes/autocompletion.el | 1 + lisp/fg42/cubes/bookmark.el | 1 + lisp/fg42/cubes/editor.el | 5 + lisp/fg42/cubes/elisp.el | 1 + lisp/fg42/cubes/git.el | 1 + lisp/fg42/cubes/{icons.el => iconspack.el} | 4 +- lisp/fg42/cubes/modeline.el | 4 +- lisp/fg42/cubes/noether.el | 8 +- lisp/fg42/cubes/org.el | 6 +- lisp/fg42/cubes/project.el | 2 +- lisp/fg42/cubes/snippets.el | 6 +- lisp/fg42/cubes/terminal.el | 1 + lisp/fg42/cubes/themes.el | 1 + lisp/fg42/deps.el | 1 + lisp/fg42/init.el | 15 +- lisp/fg42/project.el | 2 +- lisp/fpkg.el | 20 +- lisp/fpkg/core.el | 5 - nix/fg42.nix | 172 +++++++++++++----- scripts/templates/fg42 => nix/maintainers.nix | 15 +- scripts/install_files.sh | 112 ------------ scripts/templates/fg42-wm | 37 ---- 27 files changed, 205 insertions(+), 360 deletions(-) delete mode 100644 dev.org rename lisp/fg42/cubes/{icons.el => iconspack.el} (95%) rename scripts/templates/fg42 => nix/maintainers.nix (71%) delete mode 100644 scripts/install_files.sh delete mode 100644 scripts/templates/fg42-wm diff --git a/.gitignore b/.gitignore index cdca16b..b6b9b23 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,5 @@ emacs.d/ docs/site/orgs/cubes/ **/*/sitemap.inc -result \ No newline at end of file +result +v4/ \ No newline at end of file diff --git a/dev.org b/dev.org deleted file mode 100644 index d66ecb8..0000000 --- a/dev.org +++ /dev/null @@ -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 diff --git a/flake.nix b/flake.nix index 51851db..b3e3c87 100644 --- a/flake.nix +++ b/flake.nix @@ -28,11 +28,12 @@ }; lemacs = pkgs.emacs29.override { + # Gtk causes a flickering issue on WM mode withGTK3 = false; toolkit = "lucid"; }; - elispDepsFile = ./deps.el; + elispDepsFile = ./lisp/fg42/deps.el; elispPkgs = pkgs.callPackage ./nix/deps.nix { inherit elispDepsFile; @@ -41,7 +42,7 @@ ourPackages = pkgs.callPackage ./nix/packages.nix {}; fg42 = pkgs.callPackage ./nix/fg42.nix { - inherit elispPkgs ourPackages; + inherit elispPkgs ourPackages nixpkgs; srcDir = ./.; emacs = lemacs; }; @@ -49,58 +50,15 @@ in { inherit pkgs; - packages.emacs = fg42.emacsInUse; - packages.default = pkgs.writeScriptBin "fg42" '' - #!${pkgs.stdenv.shell} + packages.default = fg42; - export FG42_HOME=${fg42}/fg42 - export FG42_USE_NIX=true; - - LIBRARY_PATH="$(cc -print-file-name=libgccjit.so):$LIBRARY_PATH" \ - FG42_WM=false ${fg42.emacsInUse}/bin/emacs \ - --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 - # ''; - # }; + devShells.default = pkgs.mkShell { + nativeBuildInputs = [ fg42 pkgs.fish ]; + buildInputs = [ fg42 ]; + shellHook = '' + fish && exit + ''; + }; } ); } diff --git a/lisp/fg42.el b/lisp/fg42.el index 921b3f9..a6f1994 100644 --- a/lisp/fg42.el +++ b/lisp/fg42.el @@ -47,9 +47,11 @@ ;; (fg42/-startup-optimization) (require 'fpkg/core) (fpkg/initialize) + (when (file-exists-p user-init-file) (require 'fg42/cube) (load user-init-file)) + (add-hook 'emacs-startup-hook (lambda () (run-hooks 'fg42/-cubes-body-hook) diff --git a/lisp/fg42/core.el b/lisp/fg42/core.el index 1ed66c4..dc0c562 100644 --- a/lisp/fg42/core.el +++ b/lisp/fg42/core.el @@ -31,11 +31,14 @@ (defvar fg42/debug-p nil "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") "The pass to fg42-home.") -(defvar fg42-tmp (concat fg42-home "/tmp")) +(defvar fg42-tmp (concat fg42-config-dir "/tmp")) (provide 'fg42/core) diff --git a/lisp/fg42/cubes/autocompletion.el b/lisp/fg42/cubes/autocompletion.el index a42dd32..56fd337 100644 --- a/lisp/fg42/cubes/autocompletion.el +++ b/lisp/fg42/cubes/autocompletion.el @@ -32,6 +32,7 @@ (fpkg/use flycheck :defer () :init + (require 'flycheck) (global-flycheck-mode))) diff --git a/lisp/fg42/cubes/bookmark.el b/lisp/fg42/cubes/bookmark.el index edb73d6..7041ac4 100644 --- a/lisp/fg42/cubes/bookmark.el +++ b/lisp/fg42/cubes/bookmark.el @@ -44,6 +44,7 @@ (eval `(fpkg/use bm :init + (require 'bm) ;; restore on load (even before you require bm) (setq bm-restore-repository-on-load t) diff --git a/lisp/fg42/cubes/editor.el b/lisp/fg42/cubes/editor.el index 71fea56..13af4a3 100644 --- a/lisp/fg42/cubes/editor.el +++ b/lisp/fg42/cubes/editor.el @@ -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 as a modern file manager." :init + (require 'dirvish) (dirvish-override-dired-mode)) @@ -96,6 +97,7 @@ contextual information." (fpkg/use pinentry :init (progn + (require 'pinentry) (setq epa-pinentry-mode 'loopback) (pinentry-start)))) @@ -278,12 +280,14 @@ https://emacsthemes.com/themes/badwolf-theme.html" (fpkg/use selectrum :defer nil :init + (require 'selectrum) (selectrum-mode +1)) (fpkg/use selectrum-prescient :defer t :init (progn + (require 'selectrum-prescient) (setq prescient-filter-method '(literal fuzzy regexp initialism)) (selectrum-prescient-mode +1) (prescient-persist-mode +1))) @@ -292,6 +296,7 @@ https://emacsthemes.com/themes/badwolf-theme.html" (fpkg/use ctrlf :defer t :init + (require 'ctrlf) (ctrlf-mode +1))) diff --git a/lisp/fg42/cubes/elisp.el b/lisp/fg42/cubes/elisp.el index 002a6df..5c30e30 100644 --- a/lisp/fg42/cubes/elisp.el +++ b/lisp/fg42/cubes/elisp.el @@ -36,6 +36,7 @@ (fpkg/use eros :init + (require 'eros) (eros-mode)) (add-hook 'emacs-lisp-mode-hook #'rainbow-delimiters-mode)) diff --git a/lisp/fg42/cubes/git.el b/lisp/fg42/cubes/git.el index dd63a66..12629b1 100644 --- a/lisp/fg42/cubes/git.el +++ b/lisp/fg42/cubes/git.el @@ -43,6 +43,7 @@ For more info check out [[https://github.com/dgutov/diff-hl][diff-hl]] 's page." (fpkg/use diff-hl :init (progn + (require 'diff-hl) (when-flag git (add-hook 'magit-pre-refresh-hook 'diff-hl-magit-pre-refresh) (add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)) diff --git a/lisp/fg42/cubes/icons.el b/lisp/fg42/cubes/iconspack.el similarity index 95% rename from lisp/fg42/cubes/icons.el rename to lisp/fg42/cubes/iconspack.el index 92a88e6..48fcf0b 100644 --- a/lisp/fg42/cubes/icons.el +++ b/lisp/fg42/cubes/iconspack.el @@ -37,5 +37,5 @@ package." :if (display-graphic-p))) -(provide 'fg42/cubes/icons) -;;; icons.el ends here +(provide 'fg42/cubes/iconspack) +;;; iconspack.el ends here diff --git a/lisp/fg42/cubes/modeline.el b/lisp/fg42/cubes/modeline.el index 0ba2030..493a64b 100644 --- a/lisp/fg42/cubes/modeline.el +++ b/lisp/fg42/cubes/modeline.el @@ -23,7 +23,7 @@ ;;; Code: (require 'fpkg) (require 'fg42/cube) -(require 'fg42/cubes/icons) +(require 'fg42/cubes/iconspack) (autoload-cube 'fg42/statusbar-default "modeline/statusbar-default.el" @@ -68,6 +68,7 @@ to Emacs modeline." :defer nil :init (progn + (require 'smart-mode-line) (setq sml/theme 'respectful) (setq sml/no-confirm-load-theme t) (sml/setup)))) @@ -110,6 +111,7 @@ to Emacs modeline." :after smart-mode-line :init (progn + (require 'smart-mode-line) (setq mini-modeline-enhance-visual nil) (setq fg42/modeline-setter #'fg42/mini-modeline-setter)) :defer nil diff --git a/lisp/fg42/cubes/noether.el b/lisp/fg42/cubes/noether.el index 660f13d..ac15059 100644 --- a/lisp/fg42/cubes/noether.el +++ b/lisp/fg42/cubes/noether.el @@ -23,17 +23,17 @@ ;;; Code: (require 'fpkg) (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 to Emacs modeline." - :straight (noether-mode :repo "https://devheroes.codes/lxsameer/noether.git") + :straight (noether :repo "https://devheroes.codes/lxsameer/noether.git") :init (require 'noether) (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 noether-minimal-mode-line noether-minimal-location diff --git a/lisp/fg42/cubes/org.el b/lisp/fg42/cubes/org.el index 47c9014..bd7a6e7 100644 --- a/lisp/fg42/cubes/org.el +++ b/lisp/fg42/cubes/org.el @@ -83,6 +83,7 @@ For more information checkout [[https://github.com/alphapapa/org-super-agenda]]" :after org-agenda :init (progn + (require 'org-super-agenda) (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-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 (fpkg/use org-sidebar :init + (require 'org-sidebar) (setq org-sidebar-default-fns fns) :bind (("" . 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 :defer t :init + (require 'org-journal) ;; Change default prefix key; needs to be set before loading org-journal (setq org-journal-prefix-key "C-c j ") :config @@ -187,9 +190,10 @@ For more info on ~org-mode~ check out [[https://orgmode.org/]]" org-journal-date-format "%Y-%m-%d (%A): "))) - (fpkg/use org-mode + (fpkg/use org :init (progn + (require 'org) (require 'org-capture) (global-set-key capture-key 'org-capture) (setq org-tag-alist global-tags) diff --git a/lisp/fg42/cubes/project.el b/lisp/fg42/cubes/project.el index 0c54c2e..6d5c290 100644 --- a/lisp/fg42/cubes/project.el +++ b/lisp/fg42/cubes/project.el @@ -25,7 +25,6 @@ (require 'fg42/cube) - (defcube fg42/projectile-cube "Projectile Cube" :title "fg42/cubes/fg42/projectile-cube.org" @@ -36,6 +35,7 @@ ()))) (fpkg/use projectile :init + (require 'projectile) (projectile-mode +1) :config (progn diff --git a/lisp/fg42/cubes/snippets.el b/lisp/fg42/cubes/snippets.el index 0beddd8..e0ad2e7 100644 --- a/lisp/fg42/cubes/snippets.el +++ b/lisp/fg42/cubes/snippets.el @@ -34,9 +34,11 @@ (fpkg/use yasnippet :init + (require 'yasnippet) (let* ((snippet-home (expand-file-name "snippets" - (file-name-directory (locate-library "yasnippet-snippets")))) - (local-snippet (expand-file-name "core/fg42/cubes/snippets" fg42-home)) + (file-name-directory (locate-library "yasnippet-snippets")))) + (local-snippet (expand-file-name + "lisp/fg42/cubes/snippets" fg42-home)) (user-snippets (or (plist-get fg42/yasnippet-cube-params :snippets-dir) ;; Just to make sure that we don't return nil. Since ;; yas-snippet-dirs shoud not contain nil value diff --git a/lisp/fg42/cubes/terminal.el b/lisp/fg42/cubes/terminal.el index 64ec0f7..44cdbfb 100644 --- a/lisp/fg42/cubes/terminal.el +++ b/lisp/fg42/cubes/terminal.el @@ -33,6 +33,7 @@ (fpkg/use vterm :init (progn + (require 'vterm) (setq vterm-shell _shell))))) diff --git a/lisp/fg42/cubes/themes.el b/lisp/fg42/cubes/themes.el index 80eaa3c..e694f07 100644 --- a/lisp/fg42/cubes/themes.el +++ b/lisp/fg42/cubes/themes.el @@ -36,6 +36,7 @@ (fpkg/use dracula-theme :init (fg42/setup-theme + (require 'dracula-theme) (load-theme 'dracula t) (custom-theme-set-faces 'dracula diff --git a/lisp/fg42/deps.el b/lisp/fg42/deps.el index 1bdd548..ca40dcf 100644 --- a/lisp/fg42/deps.el +++ b/lisp/fg42/deps.el @@ -118,4 +118,5 @@ all-the-icons ) +(provide 'fg42/deps) ;;; deps.el ends here diff --git a/lisp/fg42/init.el b/lisp/fg42/init.el index 1891101..d1f7cdd 100644 --- a/lisp/fg42/init.el +++ b/lisp/fg42/init.el @@ -20,8 +20,10 @@ ;; along with this program. If not, see . ;; ;;; Commentary: +;; This is the very first file that Emacs will load to setup FG42 ;;; Code: -(setq debug-on-error t) +(when (string= (getenv "FG42_DEBUG") "1") + (setq debug-on-error t)) (eval-when-compile (defvar package-archives) @@ -29,7 +31,9 @@ (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 (setq package-enable-at-startup nil) @@ -40,7 +44,7 @@ (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 user-emacs-directory emacsd) (setq user-init-file @@ -48,7 +52,6 @@ (format "%s/.fg42.el" (getenv "HOME"))))) - ;; Load the customization file. In FG42 it is different than ;; the default `user-init-file' (if (file-exists-p custom-file) @@ -57,5 +60,5 @@ (require 'fg42) (fg42/initialize) -(provide 'fg42-config) -;;; fg42-config.el ends here +(provide 'fg42/init) +;;; init.el ends here diff --git a/lisp/fg42/project.el b/lisp/fg42/project.el index 3ef980d..7f659e9 100644 --- a/lisp/fg42/project.el +++ b/lisp/fg42/project.el @@ -27,7 +27,7 @@ (require 'fpkg) (require 'fg42/flags) -(fpkg/require 'projectile) +;;(fpkg/require 'projectile) (fpkg/require 'f) (defflag fg42-project diff --git a/lisp/fpkg.el b/lisp/fpkg.el index 017a7c1..c14ccbf 100644 --- a/lisp/fpkg.el +++ b/lisp/fpkg.el @@ -56,22 +56,22 @@ "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-params details)))) - - `(progn - (require ,pkg) - (use-package ,pkg ,@params))) + (let ((p (inject-straight (inject-params details)))) + `(progn + (use-package ,pkg ,@p))) `(progn - (require ,pkg) - (use-package ,pkg :defer t :ensure nil)))) + (use-package ,pkg :defer t :ensure nil)))) (defmacro fpkg/require (pkg) "Work like require but make sure that PKG is installed first." + (let ((pkg-name (intern (symbol-name `,(cadr pkg))))) - `(fpkg/use ,pkg-name - :init - (require ,pkg)))) + (if fg42-use-nix + `(require ,pkg) + `(fpkg/use ,pkg-name + :init + (require ,pkg))))) (provide 'fpkg) ;;; fpkg.el ends here diff --git a/lisp/fpkg/core.el b/lisp/fpkg/core.el index 89c2519..c09cf83 100644 --- a/lisp/fpkg/core.el +++ b/lisp/fpkg/core.el @@ -29,11 +29,6 @@ (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 () "Install and load the `use-package' in compile time." diff --git a/nix/fg42.nix b/nix/fg42.nix index 853d25d..6d82ab3 100644 --- a/nix/fg42.nix +++ b/nix/fg42.nix @@ -14,13 +14,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . { + lib, + nixpkgs, stdenv, elispPkgs, srcDir, emacsPackagesFor, - emacsPackages, ourPackages, - writeScriptBin, + writeText, symlinkJoin, # This is a set of system tools required for FG42 # to work. @@ -31,65 +32,138 @@ vazir-fonts, fira-code, nerdfonts, + gcc, + ltex-ls, }: with builtins; -let - getEpkg = epkgs: x: - if hasAttr x epkgs - then getAttr x epkgs - else getAttr x ourPackages; - epkgSet = emacsPackagesFor emacs; - #epkgs = (map getEpkg elispPkgs); - emacsBundle = epkgSet.emacsWithPackages (epkgs: - (map (getEpkg epkgs) elispPkgs) - ); +stdenv.mkDerivation (final: + let + getPkg = epkgs: pkg: + if hasAttr pkg epkgs + then getAttr pkg epkgs + else getAttr pkg ourPackages; -in stdenv.mkDerivation (final: rec{ - pname = "fg42"; - version = "4.0.0"; + emacsBundle = (emacsPackagesFor emacs).withPackages (epkgs: + (map (x: getPkg epkgs x) elispPkgs) + ); - src = srcDir; - outputs = [ "out" ]; + maintainers = import ./maintainers.nix; - buildPhase = '' - mkdir -p $out/fg42 - mkdir -p $out/bin/ + in rec{ + pname = "fg42"; + version = "4.0.0"; - cp -rv ${src}/core $out/fg42/ - cp -rv ${src}/share $out/ + src = srcDir; + outputs = [ "out" ]; - runHook preBuild - cd $out/fg42 - emacs -L . --batch -f batch-byte-compile *.el - cd - - cp -v ${src}/fg42-config.el $out/fg42/ + buildPhase = '' + LISPDIR=$out/share/fg42/ + mkdir -p $out/bin + install -d $LISPDIR + 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 = '' - runHook preInstall + cat >> $out/bin/fg42 << EOF + #!${stdenv.shell} - # LISPDIR=$out/share/emacs/site-lisp - # install -d $LISPDIR - # install *.el *.elc $LISPDIR - emacs --batch -l package --eval "(package-generate-autoloads \"${pname}\" \"$out/fg42\")" + export FG42_HOME=${placeholder "out"}/share/fg42/ + export FG42_EMACSD=~/.fg42/v4/emacs.d + export FG42_USE_NIX=true; - 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 = [ - emacsBundle - ripgrep - git - texinfo - vazir-fonts - fira-code - nerdfonts - ]; - buildInputs = propagatedUserEnvPkgs; + cat >> $out/bin/fg42-wm << EOF + #!${stdenv.shell} - 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; + }; + + }) diff --git a/scripts/templates/fg42 b/nix/maintainers.nix similarity index 71% rename from scripts/templates/fg42 rename to nix/maintainers.nix index 29a0ff8..35f0561 100644 --- a/scripts/templates/fg42 +++ b/nix/maintainers.nix @@ -1,4 +1,3 @@ -#! /bin/sh # Fg42 - Emacs Editor for advance users # # Copyright (c) 2010-2024 Sameer Rahmani @@ -15,5 +14,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -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"; + }]; + }; +} diff --git a/scripts/install_files.sh b/scripts/install_files.sh deleted file mode 100644 index e84ff5f..0000000 --- a/scripts/install_files.sh +++ /dev/null @@ -1,112 +0,0 @@ -#! /bin/bash -# Fg42 - Emacs Editor for advance users -# -# Copyright (c) 2010-2024 Sameer Rahmani -# -# 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 . - -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" diff --git a/scripts/templates/fg42-wm b/scripts/templates/fg42-wm deleted file mode 100644 index 6c7d178..0000000 --- a/scripts/templates/fg42-wm +++ /dev/null @@ -1,37 +0,0 @@ -#! /bin/sh -# Fg42 - Emacs Editor for advance users -# -# Copyright (c) 2010-2024 Sameer Rahmani -# -# 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 . - -# 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 "$@"