231 lines
6.0 KiB
Nix
231 lines
6.0 KiB
Nix
# 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/>.
|
|
{ lib
|
|
, config
|
|
, stdenv
|
|
, git
|
|
, texinfo
|
|
, gcc
|
|
, bash
|
|
, utils
|
|
, emacsPackagesFor
|
|
, makeFontsConf
|
|
, xorg
|
|
, maintainers
|
|
, writeTextFile
|
|
, writeShellApplication
|
|
, ...
|
|
}:
|
|
|
|
with builtins;
|
|
let
|
|
cfg = config.fg42;
|
|
emacs = cfg.emacs;
|
|
version = cfg.version;
|
|
|
|
emacsBundle = (emacsPackagesFor emacs).withPackages (_: cfg.elispPackages);
|
|
|
|
paths = map (x: "${x}/bin/") cfg.paths;
|
|
pathsStr = lib.strings.concatStrings (lib.strings.intersperse ":" paths);
|
|
|
|
mimeTypes = builtins.concatStringsSep ";" cfg.mimeTypes;
|
|
|
|
fontsConf = makeFontsConf { fontDirectories = cfg.fonts; };
|
|
|
|
# Whatever that needs to be in the PATH is considered a runtime
|
|
# dependency.
|
|
# Fonts are obviously runtime dependency as well
|
|
runtimeDependencies = cfg.paths ++ cfg.fonts ++ cfg.elispPackages;
|
|
|
|
# addToList = epkg: ''(add-to-list 'directories-to-autogen "${epkg}")'';
|
|
|
|
# sexprs = [
|
|
# ''
|
|
# (require 'loaddefs-gen)
|
|
# (defvar directories-to-autogen '())
|
|
# (defvar output-file (getenv "LOADEF_OUTPUT"))
|
|
# ''
|
|
# ] ++ (map addToList cfg.elispPackages) ++ [
|
|
# ''
|
|
# (message ">> %s ----- %s" directories-to-autogen output-file)
|
|
# (loaddefs-generate directories-to-autogen
|
|
# output-file)
|
|
# (provide 'loaddef-generator)
|
|
# ''
|
|
# ];
|
|
# loaddefGenerator = writeText "loaddef-generator.el" (concatStringsSep "\n" sexprs);
|
|
# loaddefScript = writeShellApplication {
|
|
# name = "loaddef";
|
|
|
|
# text = ''
|
|
# #!${stdenv.shell}
|
|
# set +x
|
|
# LOADEF_OUTPUT="$1" ${emacsBundle}/bin/emacs -Q -q --batch -l ${loaddefGenerator}
|
|
# '';
|
|
# };
|
|
|
|
|
|
configFile = writeTextFile {
|
|
name = "config.json";
|
|
text = (toJSON config);
|
|
executable = false;
|
|
};
|
|
|
|
|
|
startupPackage = cfg.startUp;
|
|
|
|
|
|
# elsipFiles = map (file: ) cfg.elispPackages;
|
|
# nativeCompiler = epkgs: ''
|
|
# emacs -L . --batch -f batch-native-compile ${elispFiles}
|
|
# '';
|
|
in
|
|
stdenv.mkDerivation rec {
|
|
inherit version;
|
|
pname = "FG42";
|
|
|
|
src = ../../.;
|
|
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
|
|
LISPDIR=$out/share/fg42/
|
|
mkdir -p $out/bin
|
|
mkdir -p $out/share/applications/
|
|
|
|
install -d $LISPDIR
|
|
|
|
mkdir -p $LISPDIR/lisp
|
|
cp -rv ${src}/lisp/build.el $LISPDIR/lisp
|
|
|
|
cp -rv ${src}/share $out/
|
|
cp -rv ${src}/snippets $LISPDIR/snippets
|
|
cp "${fontsConf}" $LISPDIR/fonts.conf
|
|
cp "${configFile}" $LISPDIR/config.json
|
|
|
|
export FONTCONFIG_FILE="$LISPDIR/fonts.conf"
|
|
chmod 755 $LISPDIR -R
|
|
|
|
emacs --batch -l $LISPDIR/lisp/build.el $LISPDIR/config.json $LISPDIR/lisp/fg42_init.el
|
|
|
|
|
|
|
|
cat >> $out/share/applications/FG42.desktop << EOF
|
|
[Desktop Entry]
|
|
Encoding=UTF-8
|
|
Name=FG42
|
|
GenericName=FG42
|
|
Comment=The nix base Emacs bundle for advance users
|
|
MimeType=${mimeTypes}
|
|
Type=Application
|
|
Terminal=false
|
|
Categories=Development;TextEditor;
|
|
StartupWMClass=FG42
|
|
Exec=${placeholder "out"}/bin/fg42
|
|
Icon=fg42
|
|
Version=${version}
|
|
EOF
|
|
|
|
cat >> $out/share/runtime_deps << EOF
|
|
${lib.strings.concatLines runtimeDependencies}
|
|
${emacsBundle}
|
|
EOF
|
|
|
|
cd $LISPDIR
|
|
#compile stuff
|
|
cd -
|
|
|
|
cat >> $out/bin/fg42 << EOF
|
|
#!${stdenv.shell}
|
|
|
|
export PATH=${pathsStr}:$PATH
|
|
export FONTCONFIG_FILE="$LISPDIR/fonts.conf"
|
|
|
|
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 ${cfg.startUp} "\$@"
|
|
EOF
|
|
chmod +x $out/bin/fg42
|
|
|
|
|
|
LISPDIR=$out/share/fg42/lisp/
|
|
mkdir -p $LISPDIR
|
|
#emacs --batch -l package --eval "(package-generate-autoloads \"${pname}\" \"$LISPDIR\")"
|
|
|
|
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;
|
|
export PATH=${pathsStr}:\$PATH
|
|
export FONTCONFIG_FILE="$LISPDIR/fonts.conf"
|
|
|
|
# Disable access control for the current user.
|
|
${xorg.xhost}/bin/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/fg42.el "\$@"
|
|
EOF
|
|
chmod +x $out/bin/fg42-wm
|
|
|
|
|
|
runHook postBuild
|
|
'';
|
|
|
|
buildInputs = [ emacs emacsBundle git texinfo gcc 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;
|
|
};
|
|
}
|