summaryrefslogtreecommitdiff
path: root/home-manager/clone-repos.nix
blob: fcf96f79096d54a18807197f60ef046742cda83b (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
{ 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.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" "")
			]));
			linkZshProfile = lib.hm.dag.entryAfter ["writeBoundary"] ''
				run ln -sf $VERBOSE_ARG ${dotConfig}/zsh/zprofile $HOME/.zprofile
			'';
		};
		#home.file.Zprofile = {
		#	source = "${dotConfig}/zsh/zprofile";
		#	target = ".zprofile";
		#};
	};
}