aboutsummaryrefslogtreecommitdiffstats
path: root/modules/scripts/default.nix
blob: c933a5eca674655c21f5f4a99390fed7aed86f67 (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
{ config, lib, pkgs, ... }:

{
	options.scripts = {
		enable = lib.mkEnableOption "Enable scripts.";
	};

	config = lib.mkIf config.scripts.enable {
		home.file."scripts" = {
			source = ./scripts;
			recursive = true;
		};

		home.file."scripts/home-manager-switch" = {
			text = ''
#!/bin/sh
home-manager switch --flake ${config.baseDirectory}/#${config.home.username}
			'';
			executable = true;
		};

		home.activation.modifyScripts = lib.mkAfter ''
			for script in ${config.home.homeDirectory}/scripts/*.sh; do
				[ -f "$script" ] && mv "$script" "''${script%.sh}"
			done
			chmod -R u+x ${config.home.homeDirectory}/scripts
		'';
	};
}