forked from FG42/FG42
1
0
Fork 0
FG42/nix/modules/unit/default.nix

258 lines
7.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/>.
# 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, config, pkgs, makeFG42Drv, ... }:
with lib;
let
cfg = config.fg42;
deps = (with pkgs.emacsPackages; [
treesit-grammars.with-all-grammars
]);
drv = makeFG42Drv {
pname = "unit";
version = config.fg42.version;
src = ./.;
};
maintainer = mkOptionType {
name = "maintainer";
check = email: elem email (attrValues lib.maintainers);
merge = loc: defs: listToAttrs (singleton (nameValuePair (last defs).file (last defs).value));
};
listOfMaintainers = types.listOf maintainer // {
# Returns list of
# { "module-file" = [
# "maintainer1 <first@nixos.org>"
# "maintainer2 <second@nixos.org>" ];
# }
merge = loc: defs:
zipAttrs
(flatten (imap1
(n: def: imap1
(m: def':
maintainer.merge (loc ++ [ "[${toString n}-${toString m}]" ])
[{ inherit (def) file; value = def'; }])
def.value)
defs));
};
docFile = types.path // {
# Returns tuples of
# { file = "module location"; value = <path/to/doc.xml>; }
merge = loc: defs: defs;
};
in
{
options = {
meta = {
maintainers = mkOption {
type = listOfMaintainers;
internal = true;
default = [ ];
example = literalExpression ''[ lib.maintainers.all ]'';
description = lib.mdDoc ''
List of maintainers of each module. This option should be defined at
most once per module.
'';
};
doc = mkOption {
type = docFile;
internal = true;
example = "./meta.chapter.md";
description = lib.mdDoc ''
Documentation prologue for the set of options of each module. This
option should be defined at most once per module.
'';
};
};
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;
toolkit = "no";
});
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
'';
};
fg42.font = mkOption {
type = types.submodule {
options = {
name = mkOption {
type = types.str;
};
size = mkOption {
type = types.int;
};
};
};
example = ''fg42.font = {name = "Fira Mono"; size = 10; };'';
description = "The default font for FG42";
};
fg42.theme = mkOption {
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
'';
};
fg42.requires = mkOption {
type = types.listOf types.str;
description = ''
A list of Emacs packages to preload in compile time.
In general you want your entry point module in this list
to setup your autoloads, hooks, and everything.
'';
};
fg42.vars = mkOption {
type = types.listOf
(types.submodule {
options = {
name = mkOption {
type = types.str;
};
defaultValue = mkOption {
type = types.anything;
};
docstring = mkOption {
type = types.str;
};
};
});
default = [ ];
description = ''
Any element in this list will translate to an Elisp variable and will
be available to the Elisp code via the `fg42/config` interface.
'';
};
fg42.consts = mkOption {
type = types.listOf
(types.submodule {
options = {
name = mkOption {
type = types.str;
};
defaultValue = mkOption {
type = types.anything;
};
docstring = mkOption {
type = types.str;
};
};
});
default = [ ];
description = ''
Any element in this list will translate to an Elisp const and will
be available to the Elisp code via the `fg42/config` interface.
'';
};
fg42.modeline = mkOption {
type = types.enum [ "emacs" "noether" ];
default = "emacs";
description = ''
What modeline mode to ues. Options are "emacs" for a normal modeline and
"noether" to disable Emacs's modeline and replace it by the noether mode.
'';
};
};
config = {
fg42.version = import ../../version.nix { };
fg42.elispPackages = [ drv ] ++ deps;
fg42.theme = lib.mkDefault "base16-eighties";
fg42.theme-package-name = lib.mkDefault "base16-theme";
fg42.vars = [
(lib.defConst "version" cfg.version "FG42's version")
(lib.defVar "font-name" cfg.font.name "The default font for FG42")
(lib.defVar "font-size" cfg.font.size "The default font size for FG42")
(lib.defVar "theme" cfg.theme "The default theme for FG42")
(lib.defVar "theme-package-name" cfg.theme-package-name ''
The theme package name to use with FG42. The package should be added to `elispPackages` already.
'')
];
meta = {
maintainers = [ maintainers.lxsameer ];
doc = ./README.md;
};
};
}