Repository navigation
Expand file tree
/
Copy pathcodedown.nix
More file actions
108 lines (87 loc) · 3.75 KB
/
Copy pathcodedown.nix
File metadata and controls
108 lines (87 loc) · 3.75 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{ pkgsStableSrc
, pkgsStable
# , pkgsMasterSrc
# , pkgsMaster
, requiredPackages ? []
, system ? "x86_64-linux"
}:
let
common = pkgsStable.callPackage ./modules/kernels/common.nix {};
callPackage = pkgsStable.callPackage;
lib = pkgsStable.lib;
in
rec {
spellchecker = callPackage ./modules/language_servers/markdown-spellcheck-lsp {};
testing = {
builds-forever = callPackage ./modules/testing/builds-forever/default.nix {};
builder-uid = callPackage ./modules/testing/builder-uid/default.nix {};
};
# Exported so clients can build searchers for other package sets, like "codedown.searcher nixpkgs"
searcher = common.searcher;
settingsSchemas = lib.mapAttrs (_attr: value: value.meta.settingsSchema or []) kernels;
evaluateConfig = callPackage ./nix/evaluate-config.nix {
inherit pkgsStable;
# inherit pkgsMaster;
};
everythingConfig = let
base = evaluateConfig {};
kernelNames = builtins.attrNames base.options.kernels;
shellNames = builtins.attrNames base.options.shells;
exporterNames = builtins.attrNames base.options.exporters;
in
builtins.foldl' lib.recursiveUpdate {} (
(map (n: { kernels.${n}.enable = true; }) kernelNames)
++ (map (n: { shells.${n}.enable = true; }) shellNames)
++ (map (n: { exporters.${n}.enable = true; }) exporterNames)
);
everythingEnv = evaluateConfig everythingConfig;
packageSearch = common.searcher' {
# Note that we deliberately don't include "testing" packages in the searcher
packages =
(lib.mapAttrs' (n: v: lib.nameValuePair ("kernels." + n) v) everythingEnv.config.builtKernels)
// (lib.mapAttrs' (n: v: lib.nameValuePair ("exporters." + n) v) everythingEnv.config.builtExporters)
// (lib.mapAttrs' (n: v: lib.nameValuePair n v) everythingEnv.config.packages)
// { "language-servers.spellchecker" = spellchecker; }
;
};
kernels = everythingEnv.config.builtKernels;
exporters = everythingEnv.config.builtExporters;
makeEnvironment = callPackage ./nix/makeEnvironment.nix {
inherit pkgsStable;
# inherit pkgsMaster;
};
# Which languages support which features, derived from the module evaluation.
# Plain import rather than callPackage: these return data, and callPackage would
# graft `override`/`overrideDerivation` functions onto it that don't survive toJSON.
featureMatrix = import ./nix/feature-matrix.nix {
inherit lib everythingEnv kernels;
};
lspProbeEnvs = import ./nix/single-kernel-env.nix {
inherit lib makeEnvironment;
kernelNames = builtins.attrNames kernels;
};
validateEnvironment = callPackage ./nix/validateEnvironment.nix {};
# Exposed for consumers to pin and use to gather metadata from other channels like Nixpkgs
chooseMeta = callPackage ./nix/choose-meta.nix {};
nixpkgsOverlay = callPackage ./nix/nixpkgs-overlay.nix { inherit searcher; };
importChannel = {
bootstrapNixpkgs ? null,
nixpkgsConfig ? {},
channel
}:
let
imported = import channel;
overlays = [nixpkgsOverlay];
in
# Import codedown-languages
if (builtins.isFunction imported && builtins.hasAttr "isCodeDown" (builtins.functionArgs imported)) then imported ({ inherit system; } // lib.optionalAttrs (bootstrapNixpkgs != null) { inherit (bootstrapNixpkgs) fetchFromGitHub; })
# Import Nixpkgs
else if (builtins.isFunction imported && builtins.hasAttr "overlays" (builtins.functionArgs imported)) then imported { inherit overlays system; config = nixpkgsConfig; }
# Generic import
else if (builtins.isFunction imported) then imported { inherit system; }
else imported
;
# Exposed so it's easier to compute build dependencies in the presence of IFD
inherit pkgsStableSrc pkgsStable requiredPackages;
# inherit pkgsMasterSrc pkgsMaster;
}