mirror of
https://github.com/nix-community/home-manager
synced 2024-12-24 10:49:48 +01:00
emacs: fix merging of extraPackages
and overrides
Because `extraPackages` and `overrides` expect functions as values it has not been possible to perform merges. This adds suitable types for these options that allow reasonable merging.
This commit is contained in:
parent
42732990cd
commit
cf0aad391c
2 changed files with 32 additions and 0 deletions
28
modules/lib/types.nix
Normal file
28
modules/lib/types.nix
Normal file
|
@ -0,0 +1,28 @@
|
|||
{ lib }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
|
||||
selectorFunction = mkOptionType {
|
||||
name = "selectorFunction";
|
||||
description =
|
||||
"Function that takes an attribute set and returns a list"
|
||||
+ " containing a selection of the values of the input set";
|
||||
check = isFunction;
|
||||
merge = _loc: defs:
|
||||
as: concatMap (select: select as) (getValues defs);
|
||||
};
|
||||
|
||||
overlayFunction = mkOptionType {
|
||||
name = "overlayFunction";
|
||||
description =
|
||||
"An overlay function, takes self and super and returns"
|
||||
+ " an attribute set overriding the desired attributes.";
|
||||
check = isFunction;
|
||||
merge = _loc: defs:
|
||||
self: super:
|
||||
foldl' (res: def: mergeAttrs res (def.value self super)) {} defs;
|
||||
};
|
||||
|
||||
}
|
|
@ -4,6 +4,8 @@ with lib;
|
|||
|
||||
let
|
||||
|
||||
hmTypes = import ../lib/types.nix { inherit lib; };
|
||||
|
||||
cfg = config.programs.emacs;
|
||||
|
||||
# Copied from all-packages.nix, with modifications to support
|
||||
|
@ -34,6 +36,7 @@ in
|
|||
|
||||
extraPackages = mkOption {
|
||||
default = self: [];
|
||||
type = hmTypes.selectorFunction;
|
||||
defaultText = "epkgs: []";
|
||||
example = literalExample "epkgs: [ epkgs.emms epkgs.magit ]";
|
||||
description = "Extra packages available to Emacs.";
|
||||
|
@ -41,6 +44,7 @@ in
|
|||
|
||||
overrides = mkOption {
|
||||
default = self: super: {};
|
||||
type = hmTypes.overlayFunction;
|
||||
defaultText = "self: super: {}";
|
||||
example = literalExample ''
|
||||
self: super: rec {
|
||||
|
|
Loading…
Reference in a new issue