DEVELOPMENT ENVIRONMENT

~liljamo/nix-arta

ref: 9031c8774b76b84d14d8f5ca5c468daff910b989 nix-arta/roles/base.nix -rw-r--r-- 1.5 KiB
9031c877Jonni Liljamo feat(systems/hosts/metrics): grafana default theme light a month ago
                                                                                
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
{
  config,
  lib,
  ...
}: let
  cfg = config.roles.base;
in {
  options.roles.base = {
    root = lib.mkOption {
      type = lib.types.submodule {
        options = {
          hashedPasswordFile = lib.mkOption {
            type = lib.types.path;
          };
        };
      };
    };
    primaryUser = lib.mkOption {
      type = lib.types.submodule {
        options = {
          username = lib.mkOption {
            type = lib.types.str;
          };
          isWheel = lib.mkEnableOption "admin permissions";
          extraGroups = lib.mkOption {
            type = lib.types.listOf lib.types.str;
            default = [];
          };
          hashedPasswordFile = lib.mkOption {
            type = lib.types.path;
          };
        };
      };
    };
  };

  imports = [
    (lib.mkAliasOptionModule ["hm"] [
      "home-manager"
      "users"
      cfg.primaryUser.username
    ])
  ];

  config = let
    homeDirectory = "/home/${cfg.primaryUser.username}";
  in {
    users.users.root.hashedPasswordFile = cfg.root.hashedPasswordFile;
    users.users.${cfg.primaryUser.username} = {
      isNormalUser = true;
      extraGroups = cfg.primaryUser.extraGroups ++ lib.optional cfg.primaryUser.isWheel "wheel";
      home = homeDirectory;
      hashedPasswordFile = cfg.primaryUser.hashedPasswordFile;
    };
    home-manager = {
      useUserPackages = true;
      useGlobalPkgs = true;
    };
    hm.home = {
      inherit (cfg.primaryUser) username;
      inherit homeDirectory;
      stateVersion = config.system.stateVersion;
    };
  };
}