forked from FG42/FG42
Remove the old buildConfig in favor of the new build.el
This commit is contained in:
parent
c9cdb0a83e
commit
74d36d5ae1
|
@ -29,6 +29,44 @@
|
||||||
(when (not (json-available-p))
|
(when (not (json-available-p))
|
||||||
(error "Error: libjasson support is missing"))
|
(error "Error: libjasson support is missing"))
|
||||||
|
|
||||||
|
(defvar file-header " ;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
|
||||||
|
;;
|
||||||
|
;; Copyright (c) 2010-2024 Sameer Rahmani <lxsameer@gnu.org>
|
||||||
|
;;
|
||||||
|
;; Author: Sameer Rahmani <lxsameer@gnu.org>
|
||||||
|
;; URL: https://devheroes.codes/FG42/FG42
|
||||||
|
;; Version: 4.0.0
|
||||||
|
;;
|
||||||
|
;; 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, either version 3 of the License, or
|
||||||
|
;; (at your option) any later version.
|
||||||
|
;;
|
||||||
|
;; 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/>.
|
||||||
|
;;
|
||||||
|
;;; Commentary:
|
||||||
|
;; This is the builder script that takes the config.json from the input
|
||||||
|
;; (typically provided by Nix). And generates appropriate Elisp file
|
||||||
|
;; for the main FG42 Elsip code to load and use.
|
||||||
|
;;
|
||||||
|
;; Please note that this file runs with Emacs and not FG42.
|
||||||
|
;;; Code:
|
||||||
|
;; ============================================================================
|
||||||
|
;; This file is auto generated by FG42. Don't modify it.
|
||||||
|
;; ============================================================================
|
||||||
|
")
|
||||||
|
|
||||||
|
(defvar file-footer "
|
||||||
|
(require 'fg42)
|
||||||
|
(provide 'fg42_init)
|
||||||
|
;; fg42_init.el ends here
|
||||||
|
")
|
||||||
|
|
||||||
;; Elisp's hashtables are not functional so I have to store the
|
;; Elisp's hashtables are not functional so I have to store the
|
||||||
;; state like this, Ewwwwww!
|
;; state like this, Ewwwwww!
|
||||||
|
@ -55,9 +93,10 @@
|
||||||
`(eval-when-compile
|
`(eval-when-compile
|
||||||
,@(mapcar (lambda (pkg) `(require ',(intern pkg))) elisp-pkgs)))))
|
,@(mapcar (lambda (pkg) `(require ',(intern pkg))) elisp-pkgs)))))
|
||||||
|
|
||||||
|
|
||||||
(defun generate-generic-vars (k v)
|
(defun generate-generic-vars (k v)
|
||||||
"Generate a list of vars for K and value V."
|
"Generate a list of vars for K and value V."
|
||||||
(add-to-list 'build-state `(defvar ,(intern (format "fg42/%s" k)) ,v)))
|
(add-to-list 'build-state `(defvar ,(intern (format "fg42/config/%s" k)) ,v)))
|
||||||
|
|
||||||
|
|
||||||
(defun fg42-config-key-handler (k v)
|
(defun fg42-config-key-handler (k v)
|
||||||
|
@ -91,7 +130,9 @@ CONFIG maps to the collective `config' value of Nix modules."
|
||||||
;; rist though
|
;; rist though
|
||||||
(maphash #'handle-top-level j)
|
(maphash #'handle-top-level j)
|
||||||
(with-temp-file (cadr command-line-args-left)
|
(with-temp-file (cadr command-line-args-left)
|
||||||
(mapc (lambda (x) (print x (current-buffer))) build-state)))
|
(insert file-header)
|
||||||
|
(mapc (lambda (x) (print x (current-buffer))) build-state)
|
||||||
|
(insert file-footer)))
|
||||||
|
|
||||||
|
|
||||||
(provide 'build)
|
(provide 'build)
|
||||||
|
|
|
@ -50,48 +50,12 @@ let
|
||||||
# Fonts are obviously runtime dependency as well
|
# Fonts are obviously runtime dependency as well
|
||||||
runtimeDependencies = cfg.paths ++ cfg.fonts ++ cfg.elispPackages;
|
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 {
|
configFile = writeTextFile {
|
||||||
name = "config.json";
|
name = "config.json";
|
||||||
text = (toJSON config);
|
text = (toJSON config);
|
||||||
executable = false;
|
executable = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
startupPackage = cfg.startUp;
|
|
||||||
|
|
||||||
|
|
||||||
# elsipFiles = map (file: ) cfg.elispPackages;
|
|
||||||
# nativeCompiler = epkgs: ''
|
|
||||||
# emacs -L . --batch -f batch-native-compile ${elispFiles}
|
|
||||||
# '';
|
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
inherit version;
|
inherit version;
|
||||||
|
@ -103,6 +67,8 @@ stdenv.mkDerivation rec {
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
|
|
||||||
LISPDIR=$out/share/fg42/
|
LISPDIR=$out/share/fg42/
|
||||||
|
STARTUP_FILE=$LISPDIR/lisp/fg42_init.el
|
||||||
|
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
mkdir -p $out/share/applications/
|
mkdir -p $out/share/applications/
|
||||||
|
|
||||||
|
@ -119,7 +85,7 @@ stdenv.mkDerivation rec {
|
||||||
export FONTCONFIG_FILE="$LISPDIR/fonts.conf"
|
export FONTCONFIG_FILE="$LISPDIR/fonts.conf"
|
||||||
chmod 755 $LISPDIR -R
|
chmod 755 $LISPDIR -R
|
||||||
|
|
||||||
emacs --batch -l $LISPDIR/lisp/build.el $LISPDIR/config.json $LISPDIR/lisp/fg42_init.el
|
emacs --batch -l $LISPDIR/lisp/build.el $LISPDIR/config.json $STARTUP_FILE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -153,12 +119,13 @@ stdenv.mkDerivation rec {
|
||||||
|
|
||||||
export PATH=${pathsStr}:$PATH
|
export PATH=${pathsStr}:$PATH
|
||||||
export FONTCONFIG_FILE="$LISPDIR/fonts.conf"
|
export FONTCONFIG_FILE="$LISPDIR/fonts.conf"
|
||||||
|
export STARTUP_FILE=$LISPDIR/lisp/fg42_init.el
|
||||||
|
|
||||||
LIBRARY_PATH="\$(${stdenv.cc}/bin/cc -print-file-name=libgccjit.so):\$LIBRARY_PATH" \
|
LIBRARY_PATH="\$(${stdenv.cc}/bin/cc -print-file-name=libgccjit.so):\$LIBRARY_PATH" \
|
||||||
FG42_WM=fales ${emacsBundle}/bin/emacs \
|
FG42_WM=fales ${emacsBundle}/bin/emacs \
|
||||||
--name FG42 \
|
--name FG42 \
|
||||||
-q --no-splash --title FG42 \
|
-q --no-splash --title FG42 \
|
||||||
-l ${cfg.startUp} "\$@"
|
-l "$STARTUP_FILE" "\$@"
|
||||||
EOF
|
EOF
|
||||||
chmod +x $out/bin/fg42
|
chmod +x $out/bin/fg42
|
||||||
|
|
||||||
|
@ -172,11 +139,9 @@ stdenv.mkDerivation rec {
|
||||||
cat >> $out/bin/fg42-wm << EOF
|
cat >> $out/bin/fg42-wm << EOF
|
||||||
#!${stdenv.shell}
|
#!${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 PATH=${pathsStr}:\$PATH
|
||||||
export FONTCONFIG_FILE="$LISPDIR/fonts.conf"
|
export FONTCONFIG_FILE="$LISPDIR/fonts.conf"
|
||||||
|
export STARTUP_FILE=$LISPDIR/lisp/fg42_init.el
|
||||||
|
|
||||||
# Disable access control for the current user.
|
# Disable access control for the current user.
|
||||||
${xorg.xhost}/bin/xhost +SI:localuser:\$USER
|
${xorg.xhost}/bin/xhost +SI:localuser:\$USER
|
||||||
|
@ -200,7 +165,7 @@ stdenv.mkDerivation rec {
|
||||||
FG42_WM=true ${emacsBundle}/bin/emacs \
|
FG42_WM=true ${emacsBundle}/bin/emacs \
|
||||||
--name FG42 \
|
--name FG42 \
|
||||||
-q --no-splash --title FG42 \
|
-q --no-splash --title FG42 \
|
||||||
-l \$FG42_HOME/lisp/fg42/fg42.el "\$@"
|
-l $STARTUP_FILE "\$@"
|
||||||
EOF
|
EOF
|
||||||
chmod +x $out/bin/fg42-wm
|
chmod +x $out/bin/fg42-wm
|
||||||
|
|
||||||
|
|
|
@ -86,10 +86,19 @@ with lib;
|
||||||
description = "The default font for FG42";
|
description = "The default font for FG42";
|
||||||
};
|
};
|
||||||
|
|
||||||
fg42.startUp = mkOption {
|
|
||||||
type = types.uniq types.path;
|
fg42.theme = mkOption {
|
||||||
description = "The main startup file to load first. This is usually fg42.el";
|
type = types.str;
|
||||||
|
description = "The theme name to use with FG42.";
|
||||||
};
|
};
|
||||||
|
fg42.theme-package-name = mkOption
|
||||||
|
{
|
||||||
|
type = types.str;
|
||||||
|
description = ''
|
||||||
|
The theme package name to use with FG42. The package should be added
|
||||||
|
to `elispPackages` already;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ let
|
||||||
yasnippet
|
yasnippet
|
||||||
yasnippet-snippets
|
yasnippet-snippets
|
||||||
flycheck
|
flycheck
|
||||||
|
base16-theme
|
||||||
]);
|
]);
|
||||||
drv = makeFG42Drv {
|
drv = makeFG42Drv {
|
||||||
pname = "fg42-editor";
|
pname = "fg42-editor";
|
||||||
|
@ -51,7 +52,6 @@ in
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
fg42.elispPackages = [ drv ] ++ deps;
|
fg42.elispPackages = [ drv ] ++ deps;
|
||||||
fg42.startUp = lib.mkDefault "${drv}/share/emacs/site-lisp/fg42.el";
|
|
||||||
|
|
||||||
fg42.fonts = (with pkgs;[
|
fg42.fonts = (with pkgs;[
|
||||||
vazir-fonts
|
vazir-fonts
|
||||||
|
@ -66,6 +66,7 @@ in
|
||||||
]);
|
]);
|
||||||
|
|
||||||
fg42.font = lib.mkDefault '''("Fira Mono" 11)'';
|
fg42.font = lib.mkDefault '''("Fira Mono" 11)'';
|
||||||
fg42.requires = [ "fg42/cpp" ];
|
fg42.theme = lib.mkDefault "base16-eighties";
|
||||||
|
fg42.theme-package-name = lib.mkDefault "base16-theme";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
|
||||||
|
;;
|
||||||
|
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
|
||||||
|
;;
|
||||||
|
;; Author: Sameer Rahmani <lxsameer@gnu.org>
|
||||||
|
;; URL: https://devheroes.codes/FG42/FG42
|
||||||
|
;; Version: 4.0.0
|
||||||
|
;;
|
||||||
|
;; 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, either version 3 of the License, or
|
||||||
|
;; (at your option) any later version.
|
||||||
|
;;
|
||||||
|
;; 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/>.
|
||||||
|
;;
|
||||||
|
;;; Commentary:
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
|
(defmacro fg42/config-get (key)
|
||||||
|
"Return the value for KEY or raise an error."
|
||||||
|
(let ((sym (intern (format "fg42/config/%s" key))))
|
||||||
|
(if (boundp sym)
|
||||||
|
`,sym
|
||||||
|
`(error "Can't find config '%s'" ,key))))
|
||||||
|
|
||||||
|
(defmacro fg42/config-get-or (key &optional default)
|
||||||
|
"Return the value for KEY or DEFAULT."
|
||||||
|
(let ((sym (intern (format "fg42/config/%s" key))))
|
||||||
|
(if (boundp sym)
|
||||||
|
`,sym
|
||||||
|
`,default)))
|
||||||
|
|
||||||
|
(provide 'fg42/config)
|
||||||
|
;;; config.el ends here
|
|
@ -25,7 +25,7 @@
|
||||||
(require 'fpkg)
|
(require 'fpkg)
|
||||||
;; We build this file via the main FG42's Nix derivation. It
|
;; We build this file via the main FG42's Nix derivation. It
|
||||||
;; contains the final Nix configuration of FG42.
|
;; contains the final Nix configuration of FG42.
|
||||||
(require 'fg42/build-config)
|
(require 'fg42/config)
|
||||||
(require 'fg42/themes)
|
(require 'fg42/themes)
|
||||||
;; ;; Language support
|
;; ;; Language support
|
||||||
;; (require 'fg42/autocomplete)
|
;; (require 'fg42/autocomplete)
|
||||||
|
@ -48,7 +48,6 @@
|
||||||
(require 'server)
|
(require 'server)
|
||||||
(require 'fg42/utils)
|
(require 'fg42/utils)
|
||||||
|
|
||||||
|
|
||||||
(defun fg42/setup-font ()
|
(defun fg42/setup-font ()
|
||||||
"Set the default font of `FG42' to FONT-NAME and FONT-SIZE."
|
"Set the default font of `FG42' to FONT-NAME and FONT-SIZE."
|
||||||
(let ((name (car fg42/font))
|
(let ((name (car fg42/font))
|
||||||
|
@ -207,7 +206,7 @@ contextual information."
|
||||||
;; In the following section we're setting some default behavior of FG42.
|
;; In the following section we're setting some default behavior of FG42.
|
||||||
;; Most of these configuration are opiniated and I think most of people
|
;; Most of these configuration are opiniated and I think most of people
|
||||||
;; shared the same opinion or don't care at all.
|
;; shared the same opinion or don't care at all.
|
||||||
(fg42/setup-font)
|
;;(fg42/setup-font)
|
||||||
(add-hook 'fg42/after-init-hook
|
(add-hook 'fg42/after-init-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(set-default 'cursor-type 'bar)
|
(set-default 'cursor-type 'bar)
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
(eval-when-compile
|
(eval-when-compile
|
||||||
(require 'fpkg)
|
(require 'fpkg)
|
||||||
(require 'fg42/build-config))
|
(require 'fg42/config))
|
||||||
|
|
||||||
(require 'fg42/utils)
|
(require 'fg42/utils)
|
||||||
|
|
||||||
|
@ -42,27 +42,17 @@ It executes way before the rest of the cubes.")
|
||||||
"The hook to plug any configuration to after initialize event of themes.")
|
"The hook to plug any configuration to after initialize event of themes.")
|
||||||
|
|
||||||
|
|
||||||
(defmacro fg42/setup-theme! (&rest body)
|
(defmacro fg42/setup-theme! ()
|
||||||
"Grab the them provided by `fg42/theme' and load it.
|
"Grab the them provided by `fg42/theme' and load it.
|
||||||
|
|
||||||
Load the theme via `use!' and pass the BODY to the `use!' macroro.
|
Load the theme via `use!' and pass the BODY to the `use!' macroro.
|
||||||
If the theme name and the theme package name are different the package
|
If the theme name and the theme package name are different the package
|
||||||
name can be set via `fg42/theme-package'".
|
name can be set via `fg42/theme-package'."
|
||||||
|
`(use! ,(intern (fg42/config-get-or theme-package-name (fg42/config-get theme)))
|
||||||
(declare (indent defun))
|
"Setting up the ,pkg package."
|
||||||
(let ((pkg (if (not (null fg42/theme-package))
|
:config
|
||||||
fg42/theme-package
|
(progn
|
||||||
fg42/theme)))
|
(load-theme ',(intern (fg42/config-get theme)) t))))
|
||||||
`(use! ,pkg
|
|
||||||
"Setting up the ,pkg package."
|
|
||||||
:config
|
|
||||||
(load-theme fg42/theme t)
|
|
||||||
,@body)))
|
|
||||||
|
|
||||||
;; (use! base16-theme
|
|
||||||
;; "Load base16 based themes in FG42."
|
|
||||||
;; :config
|
|
||||||
;; (load-theme 'base16-eighties t))
|
|
||||||
|
|
||||||
|
|
||||||
(provide 'fg42/themes)
|
(provide 'fg42/themes)
|
||||||
|
|
|
@ -45,10 +45,8 @@
|
||||||
(declare (indent defun))
|
(declare (indent defun))
|
||||||
(if (and (listp details) (< 0 (length details)))
|
(if (and (listp details) (< 0 (length details)))
|
||||||
(let ((p (inject-params details)))
|
(let ((p (inject-params details)))
|
||||||
`(progn
|
`(use-package ,pkg ,@p))
|
||||||
(use-package ,pkg ,@p)))
|
`(use-package ,pkg :defer t :ensure nil)))
|
||||||
`(progn
|
|
||||||
(use-package ,pkg :defer t :ensure nil))))
|
|
||||||
|
|
||||||
|
|
||||||
(defmacro use! (pkg docs &rest details)
|
(defmacro use! (pkg docs &rest details)
|
||||||
|
@ -60,8 +58,8 @@ DOCS is the documentation of the package."
|
||||||
(when (not (stringp docs))
|
(when (not (stringp docs))
|
||||||
(error "Missing docstring for '%s' package" pkg))
|
(error "Missing docstring for '%s' package" pkg))
|
||||||
|
|
||||||
(let ((disabled (or (member pkg fg42/disabled-features) nil)))
|
(let ((disabled (member pkg fg42/disabled-features)))
|
||||||
(when (not disabled)
|
(when (null disabled)
|
||||||
`(use-package ,pkg ,@details))))
|
`(use-package ,pkg ,@details))))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue