summaryrefslogtreecommitdiff
path: root/parts/lib/configs.nix
blob: 5392d9bc25c245fca0107cd7fa688d1e917867a1 (plain)
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
{inputs, ...}: let
  inherit (builtins) mapAttrs;
  inherit (inputs) nixpkgs hm;

  mkSystemCfg = name: {
    profile,
    modules ? profile.modules,
    system ? profile.system,
    specialArgs ? profile.specialArgs,
  }:
    profile.builder {
      inherit specialArgs system;
      modules =
        [../systems/${name}]
        ++ (
          if modules == profile.modules
          then modules
          else modules ++ profile.modules
        );
    };

  mkHMCfg = name: {
    pkgs ? nixpkgs.legacyPackages."x86_64-linux",
    extraSpecialArgs ? {inherit inputs;},
    modules ? [],
  }:
    hm.lib.homeManagerConfiguration {
      inherit extraSpecialArgs pkgs;

      modules =
        [
          ../users/${name}/home.nix

          {
            _module.args.osConfig = {};
            programs.home-manager.enable = true;
          }
        ]
        ++ modules;
    };
in {
  mapSystems = mapAttrs mkSystemCfg;
  mapHMUsers = mapAttrs mkHMCfg;
}