-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
93 lines (86 loc) · 2.65 KB
/
flake.nix
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{
inputs = {
systems.url = "github:nix-systems/default";
twist.url = "github:emacs-twist/twist.nix";
emacs-ci.url = "github:purcell/nix-emacs-ci";
};
nixConfig = {
extra-substituters = ["https://emacs-ci.cachix.org"];
extra-trusted-public-keys = ["emacs-ci.cachix.org-1:B5FVOrxhXXrOL0S+tQ7USrhjMT5iOPH+QN9q0NItom4="];
};
outputs = {
systems,
nixpkgs,
self,
...
} @ inputs: let
inherit (nixpkgs) lib;
eachSystem = f:
nixpkgs.lib.genAttrs (import systems) (
system:
f (import nixpkgs {
inherit system;
overlays = [
inputs.twist.overlays.default
];
})
);
# Darwin doesn't support all Emacs versions in nix-emacs-ci, so use Linux
emacsPackages = inputs.emacs-ci.packages.x86_64-linux;
in {
data = import ./generated;
lib.builtinLibrariesOfEmacsVersion = targetVersion: let
xs =
builtins.map ({libraries, ...}: libraries)
(
builtins.filter ({version, ...}: version == targetVersion)
(builtins.attrValues self.data)
);
in
if builtins.length xs > 0
then builtins.head xs
else null;
devShells = eachSystem (pkgs: {
default = pkgs.mkShell {buildInputs = [pkgs.just];};
});
packages = eachSystem (pkgs: {
default = pkgs.linkFarm "default" (
[
{
name = "default.nix";
path = pkgs.writeText "emacs-builtins-default-nix" ''{${
lib.concatMapStrings (
name: "${name} = import ./${name}.nix;\n"
)
(builtins.attrNames emacsPackages)
}}'';
}
]
++ (lib.mapAttrsToList (emacsName: emacsPackage: {
name = "${emacsName}.nix";
path =
pkgs.runCommand "build-${emacsName}-builtins-nix" {
buildInputs = [emacsPackage];
} ''
EMACS_VERSION="$(emacs --version \
| grep -F "GNU Emacs" \
| grep -oE "[[:digit:]]+(:?\.[[:digit:]]+)+")"
echo >>$out '{'
echo >>$out " version = \"''${EMACS_VERSION}\";"
echo >>$out ' libraries = ['
sed -e 's/^/"/' -e 's/$/"/' ${(pkgs.emacsTwist {
inherit emacsPackage;
initFiles = [];
lockDir = null;
inventories = [];
})
.builtinLibraryList} >>$out
echo >>$out ' ];'
echo >>$out '}'
'';
})
emacsPackages)
);
});
};
}