# 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 . { lib, nixpkgs, stdenv, elispPkgs, srcDir, emacsPackagesFor, ourPackages, writeText, symlinkJoin, # python deps python311, python3Packages, # This is a set of system tools required for FG42 # to work. pyright, emacs, ripgrep, git, texinfo, vazir-fonts, fira-code, nerdfonts, gcc, ltex-ls, bash, }: with builtins; let getPkg = epkgs: pkg: if hasAttr pkg epkgs then getAttr pkg epkgs else getAttr pkg ourPackages; emacsBundle = (emacsPackagesFor emacs).withPackages (epkgs: (map (x: getPkg epkgs x) elispPkgs) ); maintainers = import ./maintainers.nix; in stdenv.mkDerivation (final: rec{ pname = "fg42$"; version = "4.0.0"; src = srcDir; outputs = [ "out" ]; buildPhase = '' LISPDIR=$out/share/fg42/ mkdir -p $out/bin install -d $LISPDIR cp -rv ${src}/lisp/ $LISPDIR cp -rv ${src}/share $out/ runHook preBuild cd $LISPDIR emacs -L . --batch -f batch-byte-compile *.el cd - cat >> $out/bin/fg42 << EOF #!${stdenv.shell} export FG42_HOME=${placeholder "out"}/share/fg42/ export FG42_EMACSD=~/.fg42/v4/emacs.d export FG42_USE_NIX=true; LIBRARY_PATH="\$(${stdenv.cc}/bin/cc -print-file-name=libgccjit.so):\$LIBRARY_PATH" \ FG42_WM=fales ${emacsBundle}/bin/emacs \ --name FG42 \ -q --no-splash --title FG42 \ -l \$FG42_HOME/lisp/fg42/init.el "\$@" EOF chmod +x $out/bin/fg42 runHook postBuild cat >> $out/bin/fg42-wm << EOF #!${stdenv.shell} 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="\$(${stdenv.cc}/bin/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 cat >> $out/share/runtiem_deps << EOF ${vazir-fonts} ${fira-code} ${nerdfonts} ${ripgrep} ${git} ${ltex-ls} # Python deps ${python311}/bin/python ${pyright} ${python3Packages.black} ${python3Packages.pylint} ${python3Packages.flake8} EOF runHook postBuild ''; installPhase = '' runHook preInstall #LISPDIR=$out/share/fg42/lisp/ #emacs --batch -l package --eval "(package-generate-autoloads \"${pname}\" \"$LISPDIR\")" runHook postInstall ''; buildInputs = [ emacs texinfo emacsBundle ripgrep git texinfo vazir-fonts fira-code nerdfonts gcc ltex-ls bash ]; 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; }; })