summaryrefslogtreecommitdiff
path: root/users/timmy/default.nix
blob: e118395f05f6db1711690a9be9c4bdba546fc7b2 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
{ lib, config, pkgs, home-manager, ... }: let
	cfg = config._users.timmy;
	username = "timmy";
	email = "tjk@tjkeller.xyz";
	fullname = "Tim Keller";
	home = "/home/${username}";
	userDirs = {
		desktop   = "${home}";
		download  = "${home}/dls";
		documents = "${home}/docs";
		pictures  = "${home}/pics";
		# Set these as null so they're not created
		music       = null;
		publicShare = null;
		templates   = null;
		videos      = null;
	};
	sshKeyPaths = [ "${home}/.ssh/id_ed25519" ];
	sshPublicKeyPaths = lib.map (keyPath: keyPath + ".pub") sshKeyPaths;
	sshPublicKeys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDnsnAWcz46OVi1MWSxpOIUtUvwalijDwvW+oEvNjzep" ];
in {
	imports = [
		./hosts.nix
		./localization.nix
		./nas.nix
		./printing.nix
		./user.nix
		./wifi.nix
	];

	options._users.timmy = {
		enable = lib.mkEnableOption "create user timmy";
		autologin.enable = lib.mkEnableOption "enables getty automatic login";
	};

	#config = lib.mkIf cfg.enable {
	config = {
		# Setup zsh
		programs.zsh = {
			enable = true;
			_zshenv = {
				enable = true;
				exports = {
					ZDOTDIR = "$HOME/.config/zsh";
				};
			};
		};
		#environment.systemPackages = [ pkgs.zsh-fast-syntax-highlighting ];  # TODO

		# Setup normal user
		users.users.timmy = {
			home = home;
			description = fullname;
			isNormalUser = true;
			shell = pkgs.zsh;
			extraGroups = [
				"nixbld"
				"video"
				"wheel"
			] ++ lib.optionals config.hardware.i2c.enable [
				"i2c"
			] ++ lib.optionals config.virtualisation.libvirtd.enable [
				"libvirtd"
			] ++ lib.optionals config.virtualisation.docker.enable [
				"docker"
			];
		};

		# Configure automatic login with getty
		services.getty = lib.mkIf cfg.autologin.enable {
			autologinUser = username;
		};

		# Configure sops age key paths since age keys are generated via ssh private key
		sops.age = { inherit sshKeyPaths; };

		# Add authorizedKeys to cgit service
		services._cgit.ssh.authorizedKeys = {
			keys = sshPublicKeys;
			keyFiles = sshPublicKeyPaths;
		};

		# Configure user home
		home-manager.users.timmy = {
			# Setup home-manager
			home = {
				username = username;
				homeDirectory = home;
				stateVersion = "24.05";
			};

			# Setup userdirs
			xdg.userDirs = {
				enable = true;
				createDirectories = true;
			} // userDirs;

			# Setup git
			programs.git = {
				enable = true;
				settings = {
					user = {
						name = fullname;
						email = email;
					};
					merge.tool = "nvimdiff";
					mergetool.nvimdiff = {
						cmd = ''nvim -d "$LOCAL" "$MERGED" "$REMOTE"'';
						prompt = false;
					};
					# Unfortunately, this doesn't work for some reason
					#url = {
					#	"ssh://git@publicgit/".insteadOf = "https://git.tjkeller.xyz/";
					#};
				};
			};

			# Clone repos
			home._repos = {
				enable = true;
			};

			# Setup gtk bookmarks
			gtk.gtk3.bookmarks = (
				lib.mapAttrsToList (name: dir:
					lib.mkIf (dir != null) "file://${dir} ${lib.toUpper (lib.substring 0 1 name)}${lib.substring 1 (-1) name}"  # Make first letter upper case
				) userDirs
			);
		};
	};
}