forked from FG42/FG42
Revise the derivation to break down the config into nix modules
This commit is contained in:
parent
26c1a6074d
commit
1a0f2a31d2
50
flake.nix
50
flake.nix
|
@ -29,6 +29,16 @@
|
|||
"x86_64-linux"
|
||||
];
|
||||
|
||||
flake = {
|
||||
|
||||
# The home-manager integration. The can use FG42 with home-manager by including
|
||||
# this module.
|
||||
hm-module = rec {
|
||||
fg42 = import ./nix/hm;
|
||||
default = fg42;
|
||||
};
|
||||
};
|
||||
|
||||
perSystem = { config, self', inputs', pkgs, system, ... }:
|
||||
let
|
||||
test-x = pkgs.writeShellApplication {
|
||||
|
@ -39,30 +49,38 @@
|
|||
${pkgs.xorg.xorgserver.out}/bin/Xephyr -br -ac -noreset -screen 800x600 :1
|
||||
'';
|
||||
};
|
||||
noether = inputs.noether.outputs.packages.${system}.default;
|
||||
factory = params: pkgs.callPackage ./nix/factory.nix ({ inherit noether; } // params);
|
||||
default = (factory { });
|
||||
|
||||
#noether = inputs.noether.outputs.packages.${system}.default;
|
||||
fg42 = pkgs.callPackage ./nix/fg42 {
|
||||
#extraModules = inputs.noether.outputs.fg42Modules.default;
|
||||
};
|
||||
|
||||
run-test-wm = pkgs.writeShellApplication {
|
||||
name = "run-test-wm";
|
||||
runtimeInputs = [ fg42 ];
|
||||
|
||||
text = ''
|
||||
DISPLAY=:1 ${fg42}/bin/fg42-wm
|
||||
'';
|
||||
};
|
||||
|
||||
|
||||
# factory = params: pkgs.callPackage ./nix/factory.nix ({ inherit noether; } // params);
|
||||
# default = (factory { });
|
||||
in
|
||||
{
|
||||
packages = {
|
||||
default = default.fg42;
|
||||
} // (pkgs.lib.optionalAttrs (system == "x86_64-linux") {
|
||||
# Gtk causes a flickering issue on WM mode
|
||||
lucid = (factory { emacsParams.toolkit = "lucid"; }).fg42;
|
||||
gtk3 = (factory { emacsParams.withGTK3 = true; }).fg42;
|
||||
pgtk = (factory { emacsParams.withPgtk = true; }).fg42;
|
||||
gtk2 = (factory { emacsParams.withGTK2 = true; }).fg42;
|
||||
none = (factory { emacsParams.toolkit = "no"; }).fg42;
|
||||
});
|
||||
default = fg42;
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
nativeBuildInputs = [ default.fg42 pkgs.fish test-x default.run-test-wm ];
|
||||
buildInputs = [ default.fg42 ];
|
||||
nativeBuildInputs = [ fg42 pkgs.fish test-x run-test-wm ];
|
||||
buildInputs = [ fg42 ];
|
||||
};
|
||||
|
||||
apps.wm = {
|
||||
type = "app";
|
||||
program = "${default.run-test-wm}/bin/run-test-wm";
|
||||
program = "${run-test-wm}/bin/run-test-wm";
|
||||
};
|
||||
|
||||
apps.x = {
|
||||
|
@ -71,7 +89,7 @@
|
|||
};
|
||||
apps.default = {
|
||||
type = "app";
|
||||
program = "${default.fg42}/bin/fg42";
|
||||
program = "${fg42}/bin/fg42";
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
@ -13,44 +13,31 @@
|
|||
#
|
||||
# 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
|
||||
, stdenv
|
||||
, emacs29
|
||||
, callPackage
|
||||
, writeShellApplication
|
||||
, noether
|
||||
, emacsParams ? { }
|
||||
, fg42Params ? { }
|
||||
}:
|
||||
|
||||
# This is the home manager module that exposes FG42. It differs
|
||||
# from FG42 modules that are structurally the same but used in
|
||||
# different context
|
||||
{ pkgs, lib ? pkgs.lib, modules ? null, extraModules ? [ ] }:
|
||||
with lib;
|
||||
|
||||
let
|
||||
lemacs = emacs29.override ({
|
||||
withTreeSitter = true;
|
||||
} // emacsParams);
|
||||
|
||||
elispDepsFile = ../lisp/fg42/deps.el;
|
||||
|
||||
elispPkgs = callPackage ./deps.nix {
|
||||
inherit elispDepsFile;
|
||||
fg42Modules =
|
||||
if modules != null
|
||||
then modules
|
||||
else
|
||||
import ../modules {
|
||||
inherit pkgs;
|
||||
lib = lib;
|
||||
};
|
||||
|
||||
ourPackages = {
|
||||
noether-mode = noether;
|
||||
unitModule = import ./unit.nix { inherit pkgs lib; };
|
||||
final = lib.evalModules {
|
||||
modules = [ unitModule ] ++ fg42Modules ++ extraModules;
|
||||
};
|
||||
|
||||
fg42 = callPackage ./fg42.nix ({
|
||||
inherit elispPkgs ourPackages;
|
||||
srcDir = ../.;
|
||||
emacs = lemacs;
|
||||
|
||||
} // fg42Params);
|
||||
|
||||
run-test-wm = writeShellApplication {
|
||||
name = "run-test-wm";
|
||||
runtimeInputs = [ fg42 ];
|
||||
|
||||
text = ''
|
||||
DISPLAY=:1 ${fg42}/bin/fg42-wm
|
||||
'';
|
||||
};
|
||||
in
|
||||
{ inherit fg42 run-test-wm; }
|
||||
pkgs.callPackage ./derivation.nix {
|
||||
inherit (final) config options;
|
||||
maintainers = import ../maintainers.nix;
|
||||
utils = pkgs.callPackage ./utils.nix { };
|
||||
}
|
|
@ -14,128 +14,57 @@
|
|||
# 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
|
||||
, elispPkgs
|
||||
, srcDir
|
||||
, emacsPackagesFor
|
||||
, ourPackages
|
||||
, direnv
|
||||
, makeFontsConf
|
||||
, nix
|
||||
, nixpkgs-fmt
|
||||
, nil
|
||||
, # nix lsp server
|
||||
|
||||
# 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
|
||||
, fira-mono
|
||||
, noto-fonts
|
||||
, gcc
|
||||
, ltex-ls
|
||||
, bash
|
||||
, tree-sitter
|
||||
, fd
|
||||
, aspellWithDicts
|
||||
, supportWM ? true
|
||||
, utils
|
||||
, emacsPackagesFor
|
||||
, makeFontsConf
|
||||
, xorg
|
||||
, slock
|
||||
, supportPython ? true
|
||||
, supportVerilog ? true
|
||||
, svls
|
||||
, verilator
|
||||
,
|
||||
, maintainers
|
||||
, ...
|
||||
}:
|
||||
with builtins;
|
||||
let
|
||||
version = "4.0.0";
|
||||
getPkg = epkgs: pkg:
|
||||
if hasAttr pkg epkgs then getAttr pkg epkgs else getAttr pkg ourPackages;
|
||||
cfg = config.fg42;
|
||||
emacs = cfg.emacs;
|
||||
version = cfg.version;
|
||||
|
||||
emacsBundle = (emacsPackagesFor emacs).withPackages (epkgs:
|
||||
(map (x: getPkg epkgs x) elispPkgs)
|
||||
++ [ epkgs.treesit-grammars.with-all-grammars ]);
|
||||
emacsBundle = (emacsPackagesFor emacs).withPackages (_: cfg.elispPackages);
|
||||
|
||||
maintainers = import ./maintainers.nix;
|
||||
|
||||
dicts = aspellWithDicts (dicts: with dicts; [ en en-computers en-science ]);
|
||||
|
||||
runtimeBins = [
|
||||
ripgrep
|
||||
git
|
||||
tree-sitter
|
||||
direnv
|
||||
nix
|
||||
nil
|
||||
dicts
|
||||
fd
|
||||
nixpkgs-fmt
|
||||
]
|
||||
++ (lib.optional (!stdenv.buildPlatform.isRiscV) [
|
||||
# Not supported on Risc-V
|
||||
ltex-ls
|
||||
])
|
||||
++ (lib.optional supportPython [
|
||||
python311
|
||||
# Python deps
|
||||
python311
|
||||
pyright
|
||||
|
||||
python3Packages.black
|
||||
python3Packages.pylint
|
||||
python3Packages.flake8
|
||||
]) ++ (lib.optional supportVerilog [ svls ])
|
||||
++ (lib.optional (supportVerilog && stdenv.isLinux) [
|
||||
# SystemC is required by verilator that at the
|
||||
# moment is only available on Linux
|
||||
verilator
|
||||
]) ++ (lib.optional (supportWM && stdenv.isLinux) [
|
||||
# Window manager supports works on Linux only
|
||||
xorg.xhost
|
||||
slock
|
||||
]);
|
||||
|
||||
paths = map (x: "${x}/bin/") (lib.lists.flatten runtimeBins);
|
||||
paths = map (x: "${x}/bin/") cfg.paths;
|
||||
pathsStr = lib.strings.concatStrings (lib.strings.intersperse ":" paths);
|
||||
|
||||
mimes = import ./mimes.nix;
|
||||
fontsConf = makeFontsConf {
|
||||
fontDirectories = [
|
||||
vazir-fonts
|
||||
fira-code
|
||||
nerdfonts
|
||||
fira-mono
|
||||
noto-fonts
|
||||
];
|
||||
};
|
||||
mimeTypes = builtins.concatStringsSep ";" cfg.mimeTypes;
|
||||
|
||||
fontsConf = makeFontsConf { fontDirectories = cfg.fonts; };
|
||||
|
||||
|
||||
in
|
||||
stdenv.mkDerivation (final: rec {
|
||||
stdenv.mkDerivation rec {
|
||||
inherit version;
|
||||
pname = "fg42";
|
||||
src = srcDir;
|
||||
outputs = [ "out" ];
|
||||
pname = "FG42";
|
||||
|
||||
src = ../../.;
|
||||
|
||||
buildPhase = ''
|
||||
LISPDIR=$out/share/fg42/
|
||||
mkdir -p $out/bin
|
||||
mkdir -p $out/share/applications/
|
||||
|
||||
install -d $LISPDIR
|
||||
|
||||
cp -rv ${src}/lisp/ $LISPDIR
|
||||
|
||||
cp -rv ${src}/share $out/
|
||||
cp -rv ${src}/snippets $LISPDIR/snippets
|
||||
cp "${fontsConf}" $LISPDIR/fonts.conf
|
||||
|
||||
chmod 755 $LISPDIR -R
|
||||
|
||||
export FONTCONFIG_FILE="$LISPDIR/fonts.conf"
|
||||
|
||||
cat >> $out/share/applications/FG42.desktop << EOF
|
||||
|
@ -144,7 +73,7 @@ stdenv.mkDerivation (final: rec {
|
|||
Name=FG42
|
||||
GenericName=FG42
|
||||
Comment=The nix base Emacs bundle for advance users
|
||||
MimeType=${mimes.mimeTypes}
|
||||
MimeType=${mimeTypes}
|
||||
Type=Application
|
||||
Terminal=false
|
||||
Categories=Development;TextEditor;
|
||||
|
@ -213,26 +142,17 @@ stdenv.mkDerivation (final: rec {
|
|||
EOF
|
||||
chmod +x $out/bin/fg42-wm
|
||||
|
||||
cat >> $out/share/runtiem_deps << EOF
|
||||
${vazir-fonts}
|
||||
${fira-code}
|
||||
${fira-mono}
|
||||
${nerdfonts}
|
||||
${noto-fonts}
|
||||
${lib.strings.concatLines paths}
|
||||
EOF
|
||||
LISPDIR=$out/share/fg42/lisp/
|
||||
emacs --batch -l package --eval "(package-generate-autoloads \"${pname}\" \"$LISPDIR\")"
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
# installPhase = ''
|
||||
# runHook preInstall
|
||||
|
||||
#LISPDIR=$out/share/fg42/lisp/
|
||||
#emacs --batch -l package --eval "(package-generate-autoloads \"${pname}\" \"$LISPDIR\")"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
# runHook postInstall
|
||||
# '';
|
||||
|
||||
buildInputs = [ emacs emacsBundle git texinfo gcc bash ];
|
||||
|
||||
|
@ -243,7 +163,7 @@ stdenv.mkDerivation (final: rec {
|
|||
platforms = emacs.meta.platforms;
|
||||
homepage = "https://fg42.org/";
|
||||
maintainers = [ maintainers.lxsameer ];
|
||||
description = "The mighty editor for the emacsians";
|
||||
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
|
||||
|
@ -253,5 +173,4 @@ stdenv.mkDerivation (final: rec {
|
|||
'';
|
||||
license = lib.licenses.gpl3Plus;
|
||||
};
|
||||
|
||||
})
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
# 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/>.
|
||||
|
||||
# This is the home manager module that exposes FG42. It differs
|
||||
# from FG42 modules that are structurally the same but used in
|
||||
# different context
|
||||
{ lib, pkgs, ... }:
|
||||
with lib;
|
||||
{
|
||||
options = {
|
||||
fg42.version = mkOption {
|
||||
type = types.str;
|
||||
visible = true;
|
||||
readOnly = true;
|
||||
description = "FG42's version.";
|
||||
};
|
||||
|
||||
fg42.emacs = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.emacs29.override ({
|
||||
withTreeSitter = true;
|
||||
});
|
||||
description = "What Emacs package to use.";
|
||||
};
|
||||
|
||||
fg42.elispPackages = mkOption {
|
||||
type = types.listOf types.package;
|
||||
default = [ ];
|
||||
description = ''
|
||||
A list of Emacs packages that should be included in FG42
|
||||
'';
|
||||
};
|
||||
|
||||
fg42.paths = mkOption {
|
||||
type = types.listOf types.package;
|
||||
default = [ ];
|
||||
description = ''
|
||||
A list of packages that should be added to FG42's PATH
|
||||
'';
|
||||
};
|
||||
|
||||
fg42.mimeTypes = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
A list of mineType strings that FG42 should handle via
|
||||
desktop file.
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
fg42.fonts = mkOption {
|
||||
type = types.listOf types.package;
|
||||
default = [ ];
|
||||
description = ''
|
||||
A list of font packages that should be included in FG42
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
config = {
|
||||
fg42.version = import ../version.nix { };
|
||||
};
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
# 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/>.
|
||||
{ ... }:
|
||||
{
|
||||
makeDesktopFile = { };
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
# 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/>.
|
||||
|
||||
# This is the home manager module that exposes FG42. It differs
|
||||
# from FG42 modules that are structurally the same but used in
|
||||
# different context
|
||||
{ config, lib, pkgs, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.programs.fg42;
|
||||
defaultModules = pkgs.callPackage ../modules { };
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ (import ../maintainers.nix { }).lxsameer ];
|
||||
|
||||
options = {
|
||||
enable = mkEnableOption "FG42";
|
||||
|
||||
extraModules = mkOption {
|
||||
type = types.listOf types.submodule;
|
||||
default = cfg.defaultModules ++ cfg.extraModules;
|
||||
defaultText = literalExpression "[]";
|
||||
example = literalExpression ''
|
||||
extraModules = [
|
||||
./any-fg42-module-youwant.nix
|
||||
];
|
||||
'';
|
||||
};
|
||||
|
||||
modules = mkOption {
|
||||
type = types.listOf types.deferredModule;
|
||||
default = cfg.defaultModules ++ cfg.extraModules;
|
||||
defaultText = literalExpression "[]";
|
||||
example = literalExpression ''
|
||||
modules = [
|
||||
./any-fg42-module-youwant.nix
|
||||
];
|
||||
'';
|
||||
};
|
||||
|
||||
|
||||
finalPackage = mkOption {
|
||||
type = types.package;
|
||||
visible = false;
|
||||
readOnly = true;
|
||||
description = ''
|
||||
The Emacs package including any overrides and extra packages.
|
||||
'';
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ cfg.finalPackage ];
|
||||
programs.fg42.finalPackage = pkgs.callPackage ../fg42 {
|
||||
modules = cfg.modules ++ cfg.extraModules;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
# 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/>.
|
||||
|
||||
# This is the home manager module that exposes FG42. It differs
|
||||
# from FG42 modules that are structurally the same but used in
|
||||
# different context
|
||||
|
||||
# A list of default FG42 modules to build FG42 with.
|
||||
{ pkgs, lib }:
|
||||
let
|
||||
modules = [
|
||||
./editor.nix
|
||||
];
|
||||
|
||||
pkgsModule = { config, ... }: {
|
||||
config = {
|
||||
_module.args.baseModules = modules;
|
||||
_module.args.pkgs = lib.mkDefault pkgs;
|
||||
_module.check = true;
|
||||
#inherit lib;
|
||||
};
|
||||
};
|
||||
in
|
||||
modules ++ [ pkgsModule ]
|
|
@ -0,0 +1,33 @@
|
|||
# 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/>.
|
||||
|
||||
# This is the home manager module that exposes FG42. It differs
|
||||
# from FG42 modules that are structurally the same but used in
|
||||
# different context
|
||||
|
||||
# A list of default FG42 modules to build FG42 with.
|
||||
{ lib, ... }:
|
||||
{
|
||||
options = {
|
||||
fg42.editor = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "blah";
|
||||
description = ''
|
||||
FG42's version1.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
# 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/>.
|
||||
|
||||
# This is the home manager module that exposes FG42. It differs
|
||||
# from FG42 modules that are structurally the same but used in
|
||||
# different context
|
||||
_: "4.0.0"
|
Loading…
Reference in New Issue