/ modules / misc / users.nix
users.nix
 1  {
 2    lib,
 3    config,
 4    ...
 5  }: let 
 6    cfg = config.users;
 7    inherit(lib) mkOption types;
 8    in {
 9      options.users = {
10        main = mkOption {
11          type = with types; str;
12          description = ''
13            List of package names that are allowed to be installed dispite being unfree.
14          '';
15          };
16  
17        groups = mkOption {
18          type = with types; listOf str;
19          default = [];
20          description = ''
21            Extra groups the main user will be apart of.
22          '';
23        };
24      };
25  
26      config = {
27        os = {
28          users.users.root = {
29            group = "root";
30            hashedPassword = "$6$Zph0AgVL/4E0MTzN$xT4licArTl4ZHjUhQx.V87t3qoLGVZNucqhCH4h/UYx7gcDH6eTNb/dpJBvApl1dyTPgERf7Hu1w1HkVlKSJf/";
31            isSystemUser = true;
32          };
33  
34          users.users.${cfg.main} = {
35            uid = 1000;
36            hashedPassword = "$6$2kijaBST13rqrL2T$5rlGqmTrB.cYdKttgxbESHh3Oda0cCAfA.u6Qxh/gL1SaW9QpzVje58y1Xayrs6aA6quUfdpXC.jNpTzSG0bH1";
37            isNormalUser = true;
38            extraGroups = [
39              "wheel"
40              "video"
41              "networkmanager"
42              
43            ]
44            ++ cfg.groups;
45          };
46          users.mutableUsers = false;
47        };
48        hmUsername = cfg.main;
49      };
50    }