summaryrefslogtreecommitdiff
path: root/users.nix
blob: 270d8cf0911bc542707244bb7c46e35215d13f3d (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{
  config,
  lib,
  machine,
  ...
}: let
  machines = import ./machines.nix;
in {
  users.users =
    builtins.mapAttrs
    (name: value: lib.mkIf (builtins.elem name machine.users) value)
    {
      "andromeda" = {
        isNormalUser = true;
        description = "andromeda";
        hashedPasswordFile = builtins.toString config.age.secrets.secret0.path;
        extraGroups = [
          "networkmanager"
          "wheel"
        ];
      };
      "mtgmonkey" = {
        isNormalUser = true;
        description = "mtgmonkey";
        hashedPasswordFile = builtins.toString config.age.secrets.secret1.path;
        extraGroups = [
          (lib.mkIf
            (machine == machines.lenovo)
            "networkmanager")
          "wheel"
        ];
        openssh.authorizedKeys.keys = [
          (lib.mkIf
            (machine == machines."109-199-104-83")
            config.pub-keys.ssh.andromeda)
        ];
      };
    };
  environment.persistence."/nix/persist".users = lib.mkIf config.environment.persistence."/nix/persist".enable (
    builtins.mapAttrs
    (name: value: lib.mkIf (builtins.elem name machine.users) value)
    {
      "andromeda" = {
        directories = [
          ".backups"
          ".local/share/Anki2"
          ".local/share/chat.fluffy.fluffychat"
          ".local/share.zoxide"
          ".ssh"
          "conf"
          "Downloads"
          "pp"
        ];
        files = [
          ".bash_history"
          ".brush_history"
        ];
      };
      "mtgmonkey" = {
        directories = [
          ".local/share/zoxide"
          ".ssh"
        ];
        files = [
          ".bash_history"
          ".brush_history"
        ];
      };
    }
  );
}