| 
									
										
										
										
											2024-07-08 19:20:17 +01:00
										 |  |  | #!/usr/bin/env bash | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | set -o errexit | 
					
						
							|  |  |  | set -o nounset | 
					
						
							|  |  |  | set -o pipefail | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 07:48:53 +00:00
										 |  |  | function build { | 
					
						
							|  |  |  |   _nixos build "$@" | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-08 19:20:17 +01:00
										 |  |  | function check { | 
					
						
							|  |  |  |   nix flake check | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-11 07:44:18 +00:00
										 |  |  | function clean { | 
					
						
							|  |  |  |   nix store gc --verbose | 
					
						
							|  |  |  |   nix store optimise --verbose | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-25 08:03:59 +00:00
										 |  |  | function collect-garbage { | 
					
						
							|  |  |  |   nix-collect-garbage -d | 
					
						
							|  |  |  |   sudo nix-collect-garbage -d | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-23 13:17:10 +01:00
										 |  |  | function format { | 
					
						
							|  |  |  |   nix fmt flake.nix home hosts lib modules | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-08 19:20:17 +01:00
										 |  |  | function help { | 
					
						
							|  |  |  |   printf "%s <task> [args]\n\nTasks:\n" "$0" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   compgen -A function | grep -v "^_" | cat -n | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   printf "\nExtended help:\n  Each task has comments for general usage\n" | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 07:48:53 +00:00
										 |  |  | function switch { | 
					
						
							| 
									
										
										
										
											2024-07-08 19:20:17 +01:00
										 |  |  |   _nixos switch "$@" | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-14 07:48:53 +00:00
										 |  |  | function test { | 
					
						
							| 
									
										
										
										
											2024-07-08 19:20:17 +01:00
										 |  |  |   _nixos test "$@" | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function update { | 
					
						
							|  |  |  |   nix flake update | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function _nixos { | 
					
						
							|  |  |  |   local command="$1" | 
					
						
							|  |  |  |   shift 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   sudo nixos-rebuild "$command" --flake . "$@" | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TIMEFORMAT=$'\nTask completed in %3lR' | 
					
						
							|  |  |  | time "${@:-help}" |