-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathflake.nix
111 lines (105 loc) · 3.43 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
{
outputs = _: rec {
flakeModules = {
default = ./nix/modules/flake-parts;
autoWire = ./nix/modules/flake-parts/autowire.nix;
};
# For backwards compat only
flakeModule = flakeModules.default;
# Like flake-parts mkFlake, but auto-imports modules/flake-parts, consistent with autowiring feature.
#
# Looks under either nix/modules/flake-parts or modules/flake-parts for modules to import. `systems` is set to a default value. `root` is passed as top-level module args (as distinct from `inputs.self` the use of which can lead to infinite recursion).
lib.mkFlake =
{ inputs
, root
, systems ? [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]
, specialArgs ? { }
}:
inputs.flake-parts.lib.mkFlake { inherit inputs specialArgs; } {
inherit systems;
_module.args = { inherit root; };
imports =
let
# Patterns to search in order
candidates = [
# These correspond to `flakeModules.*`
"nix/modules/flake"
"modules/flake"
# Just for backwards compatbility
"nix/modules/flake-parts"
"modules/flake-parts"
];
getModulesUnderFirst = cs: with builtins;
if cs == [ ] then throw "None of these paths exist: ${toString candidates}"
else if pathExists "${root}/${head cs}"
then
map (fn: "${root}/${head cs}/${fn}") (attrNames (readDir (root + /${head cs})))
else getModulesUnderFirst (tail cs);
in
getModulesUnderFirst candidates;
};
templates =
let
tmplPath = path: builtins.path { inherit path; filter = path: _: baseNameOf path != "test.sh"; };
in
{
linux = {
description = "nixos-unified template for NixOS configuration.nix";
path = tmplPath ./examples/linux;
};
macos = {
description = "nixos-unified template for nix-darwin configuration";
path = tmplPath ./examples/macos;
};
home = {
description = "nixos-unified template for home-manager configuration";
path = tmplPath ./examples/home;
};
};
om = {
templates = rec {
home = {
template = templates.home;
params = [
{
name = "username";
description = "The $USER to apply home-manager configuration on";
placeholder = "john";
}
];
};
macos = {
template = templates.macos;
params = home.params ++ [
{
name = "hostname";
description = "Hostname of the machine";
placeholder = "example1";
}
];
};
linux = {
template = templates.linux;
inherit (macos) params;
};
};
ci.default = let overrideInputs = { nixos-unified = ./.; }; in {
docs.dir = "doc";
macos = {
inherit overrideInputs;
dir = "examples/macos";
systems = [ "x86_64-darwin" "aarch64-darwin" ];
};
home = {
inherit overrideInputs;
dir = "examples/home";
};
linux = {
inherit overrideInputs;
dir = "examples/linux";
systems = [ "x86_64-linux" "aarch64-linux" ];
};
};
};
};
}