DEVELOPMENT ENVIRONMENT

~liljamo/nix-arta

ref: a8156c500e9efa2a17b05ee1852f65a05f5acb60 nix-arta/roles/base.nix -rw-r--r-- 920 bytes
a8156c50Jonni Liljamo feat: initial version 4 months 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
{
  config,
  lib,
  ...
}: let
  cfg = config.roles.base;
in {
  options.roles.base = {
    username = lib.mkOption {
      type = lib.types.str;
    };
    isWheel = lib.mkEnableOption "wheter to enable admin permissions";
    hashedPasswordFile = lib.mkOption {
      type = lib.types.path;
    };
  };

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

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