summaryrefslogtreecommitdiff
path: root/os/core/home-manager.nix
blob: 63f3dfd0dbae07e0ec2056013673b73fafe8a7ab (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,
  config,
  lib,
  username,
  ...
}:
let
  cfg = config.os.core.home-manager;
in
{
  imports = [ inputs.home-manager.nixosModules.home-manager ];

  options.os.core.home-manager = {
    enable = lib.mkEnableOption "home Manager configuration";

    users = lib.mkOption {
      default = { };
      description = "Attribute set of users and their home-manager configurations";
      type = lib.types.attrsOf (
        lib.types.submodule {
          options = {
            path = lib.mkOption {
              type = lib.types.path;
              description = "Path to the user's home.nix file";
            };
          };
        }
      );
    };
  };
  config = lib.mkIf cfg.enable {
    home-manager = {
      extraSpecialArgs = { inherit inputs username; };
      useGlobalPkgs = true;
      useUserPackages = true;
      backupFileExtension = "bak";

      users = lib.mapAttrs (name: userCfg: {
        imports = [ userCfg.path ];
      }) cfg.users;
    };
  };
}