-
Notifications
You must be signed in to change notification settings - Fork 87
/
default.nix
77 lines (69 loc) · 1.92 KB
/
default.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
{
system ? builtins.currentSystem,
inputs ? import ./flake.lock.nix { },
nixpkgs ? import inputs.nixpkgs {
inherit system;
# Makes the config pure as well. See <nixpkgs>/top-level/impure.nix:
config = { };
overlays = [ ];
},
}:
let
# Build a list of all the files, imported as Nix code, from a directory.
importTree =
dir:
let
data = builtins.readDir dir;
op =
sum: name:
let
path = "${dir}/${name}";
type = data.${name};
in
sum
++ (
if type == "regular" then
[ path ]
# assume it's a directory
else
importTree path
);
in
builtins.foldl' op [ ] (builtins.attrNames data);
in
rec {
# Folder that contains all the extra modules
extraModulesDir = toString ./extra;
# Get the modules documentation from an empty evaluation
modules-docs =
(eval {
configuration = {
# Load all of the extra modules so they appear in the docs
imports = importTree extraModulesDir;
};
}).config.modules-docs;
# Docs
docs = nixpkgs.callPackage ./docs { inherit modules-docs; };
# Tests
tests = import ./tests {
inherit system;
inputs = null;
pkgs = nixpkgs;
};
# Evaluate the devshell module
eval = import ./modules nixpkgs;
importTOML = import ./nix/importTOML.nix;
# Build the devshell from a TOML declaration.
fromTOML = path: mkShell (importTOML path);
# A utility to build a "naked" nix-shell environment that doesn't contain
# all of the default environment variables. This is mostly for internal use.
mkNakedShell = nixpkgs.callPackage ./nix/mkNakedShell.nix { };
# A developer shell that works in all scenarios
#
# * nix-build
# * nix-shell
# * flake app
# * direnv integration
# * setup hook for derivation or hercules ci effect
mkShell = configuration: (eval { inherit configuration; }).shell;
}