blob: 45a02e3ecedd13358f9e930bcdfa9a7e2ccd3e4f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/** Build a meta-module that includes sub-modules
*
* Because of the way that the emacsWithPackages function works, it
* can only load a single "default.el" as an entry point.
*
*/
{ pkgs, lib, ... }:
rec {
/**
* Create a new elisp module with a set of package dependencies.
*
* {
* name = "base";
* lisp = ./default.el;
* deps = [ pkgs.hello ];
* }
*
* The lisp path is the main file contained in the nix store, and deps
* contains a set of emacsPackages, and base packages that the module
* depends on to function.
*/
buildModule = with pkgs; (name: path: pkgs: {
inherit name pkgs;
path = runCommand "${name}.el" {} ''
mkdir -p $out/share/emacs/site-lisp
cp -r ${path}/default.el $out/share/emacs/site-lisp/${name}.el
'';
});
/**
* Build a bootstrap module which includes submodules
*
*
*/
bootstrap =
modules: let
# Take a module and unfold the paths into a list
unfold = { path, pkgs, ... }: [ path ] ++ pkgs;
# Create an elisp require statement
mkInclude = modules: lib.concatMapStringsSep "\n" (name: "(require '${name})") modules;
# Build the list of module paths
mkModPaths = modules: builtins.foldl' (acc: mod: acc ++ (unfold mod)) [] modules;
# Build the list of module names
mkModList = modules: map (m: m.name) modules;
### Function invocations
modList = mkModList modules;
modPaths = mkModPaths modules;
loader = pkgs.writeTextFile {
name = "default.el";
text = ''
;;; THIS FILE IS AUTOMATICALLY GENERATED
${(mkInclude modList)}
'';
};
loaderWrap = pkgs.runCommand "default.el" {} ''
mkdir -p $out/share/emacs/site-lisp/
cp ${loader} $out/share/emacs/site-lisp/default.el
'';
paths = modPaths ++ [ loaderWrap ];
in
with pkgs;
symlinkJoin {
name = "libkookie-emacs-packages";
inherit paths;
};
}
|