summaryrefslogtreecommitdiff
path: root/home-manager/clone-repos.nix
blob: 0822d7b22d4b72990aee9766dd7aa01c58bab4fc (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
{ config, lib, pkgs, ... }: let
	cfg = config.home._repos;
	# TODO MAKE OPTIONS
	server = "https://git.tjkeller.xyz/";
	src = "${config.xdg.userDirs.documents}/src";
	dotConfig = config.xdg.configHome;
	bin = "$HOME/.local/bin";
	cloneMissing = repo: source: target: ''clonemissing "${repo}" "${source}" "${target}"'';
in {
	options.home._repos = {
		enable = lib.mkEnableOption "clone git repos";
		desktop = lib.mkEnableOption "clone repos that are for desktop use";
	};

	config = lib.mkIf cfg.enable {
		# TODO look into xdg.configFile.<name>
		# home.file.<name>.source = config.lib.file.mkOutOfStoreSymlink "...";
		home.activation = {
			cloneRepos = lib.hm.dag.entryAfter ["writeBoundary"] (''
				export PATH="${pkgs.git}/bin:$PATH"
				${builtins.readFile ./resources/activation-scripts/clone-repos.sh}
			'' + lib.strings.concatStringsSep "\n" ([
				(cloneMissing "${server}dotconfig"   "${src}/config"        dotConfig)
				(cloneMissing "${server}nixos"       "${src}/nixos"         "")
				(cloneMissing "${server}nvim"        "${dotConfig}/nvim"    "")
				(cloneMissing "${server}zsh"         "${dotConfig}/zsh"     "")
			] ++ lib.optionals cfg.desktop [
				(cloneMissing "${server}scripts"     "${src}/scripts"       bin)
				(cloneMissing "${server}userscripts" "${src}/userscripts"   "")
				(cloneMissing "${server}awesome"     "${dotConfig}/awesome" "")
			]));
		};
	};
}