1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-25 03:09:47 +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:
Jonas Holst Damtoft 2018-12-29 21:21:11 +01:00 committed by Robert Helgesson
parent 42732990cd
commit cf0aad391c
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
2 changed files with 32 additions and 0 deletions

28
modules/lib/types.nix Normal file
View 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;
};
}

View file

@ -4,6 +4,8 @@ with lib;
let let
hmTypes = import ../lib/types.nix { inherit lib; };
cfg = config.programs.emacs; cfg = config.programs.emacs;
# Copied from all-packages.nix, with modifications to support # Copied from all-packages.nix, with modifications to support
@ -34,6 +36,7 @@ in
extraPackages = mkOption { extraPackages = mkOption {
default = self: []; default = self: [];
type = hmTypes.selectorFunction;
defaultText = "epkgs: []"; defaultText = "epkgs: []";
example = literalExample "epkgs: [ epkgs.emms epkgs.magit ]"; example = literalExample "epkgs: [ epkgs.emms epkgs.magit ]";
description = "Extra packages available to Emacs."; description = "Extra packages available to Emacs.";
@ -41,6 +44,7 @@ in
overrides = mkOption { overrides = mkOption {
default = self: super: {}; default = self: super: {};
type = hmTypes.overlayFunction;
defaultText = "self: super: {}"; defaultText = "self: super: {}";
example = literalExample '' example = literalExample ''
self: super: rec { self: super: rec {