-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.nix
More file actions
51 lines (44 loc) · 1.41 KB
/
Copy pathdefault.nix
File metadata and controls
51 lines (44 loc) · 1.41 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
# Central definition for attrsOf-based per-user modules (los.homev2)
#
# This module defines los.homev2 with a submodule that includes options
# from all per-user modules. Each module contributes its options via
# the submoduleWith pattern.
#
# Modules are auto-discovered from sibling directories. Each directory
# must contain options.nix and config.nix files.
#
# Usage in host config:
# imports = [ ../../modules/homev2 ];
# los.homev2 = {
# alice = {
# languages.go.enable = true;
# sway.enable = true;
# firefox.enable = true;
# };
# bob = {
# languages.rust.enable = true;
# git.enable = true;
# };
# };
{ lib, pkgs, ... }:
let
# Get all entries in this directory
entries = builtins.readDir ./.;
# Filter for directories only (these are the module directories)
moduleDirs = lib.filterAttrs (name: type: type == "directory") entries;
# Build list of options.nix paths
optionsModules = lib.mapAttrsToList (name: _: ./${name}/options.nix) moduleDirs;
# Build list of config.nix paths
configModules = lib.mapAttrsToList (name: _: ./${name}/config.nix) moduleDirs;
in
{
options.los.homev2 = lib.mkOption {
type = lib.types.attrsOf (lib.types.submoduleWith {
specialArgs = { inherit pkgs; };
modules = optionsModules;
});
default = { };
description = "Per-user configuration (attrsOf-based modules)";
};
imports = configModules;
}