forked from nix-community/dream2nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
88 lines (75 loc) · 2.01 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
{
description = "Simplified nix packaging for various programming language ecosystems";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
# TODO: go back to upstream after PRs are merged
pyproject-nix.url = "github:davhau/pyproject.nix/dream2nix";
pyproject-nix.flake = false;
purescript-overlay.url = "github:thomashoneyman/purescript-overlay";
purescript-overlay.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs: let
inherit
(builtins)
mapAttrs
readDir
;
inherit
(inputs.nixpkgs.lib)
filterAttrs
mapAttrs'
removeSuffix
;
devFlake = import ./dev-flake;
modulesDir = ./modules;
moduleKinds =
filterAttrs (_: type: type == "directory") (readDir modulesDir);
mapModules = kind:
mapAttrs'
(fn: _: {
name = removeSuffix ".nix" fn;
value = modulesDir + "/${kind}/${fn}";
})
(readDir (modulesDir + "/${kind}"));
# expose core-modules at the top-level
corePath = ./modules/dream2nix/core;
coreDirs = filterAttrs (name: _: name != "default.nix") (readDir corePath);
coreModules =
mapAttrs'
(fn: _: {
name = removeSuffix ".nix" fn;
value = corePath + "/${fn}";
})
(filterAttrs (_: type: type == "regular" || type == "directory") coreDirs);
in {
modules = let
allModules = mapAttrs (kind: _: mapModules kind) moduleKinds;
in
allModules
// {
dream2nix = allModules.dream2nix or {} // coreModules;
};
lib = import ./lib {
dream2nix = inputs.self;
inherit (inputs.nixpkgs) lib;
};
overrides = let
overridesDir = ./overrides;
in
mapAttrs
(
category: _type:
mapAttrs
(name: _type: overridesDir + "/${category}/${name}")
(readDir (overridesDir + "/${category}"))
)
(readDir overridesDir);
inherit
(devFlake)
checks
devShells
packages
templates
;
};
}