forked from jan-leila/nix-config
		
	added user option to rebuild.sh
This commit is contained in:
		
							parent
							
								
									04dc0cb5ba
								
							
						
					
					
						commit
						2150819f7d
					
				
					 1 changed files with 10 additions and 4 deletions
				
			
		
							
								
								
									
										14
									
								
								rebuild.sh
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								rebuild.sh
									
										
									
									
									
								
							|  | @ -14,11 +14,16 @@ while [ $# -gt 0 ]; do | ||||||
|       if [[ "$1" != *=* ]]; then shift; fi |       if [[ "$1" != *=* ]]; then shift; fi | ||||||
|       mode="${1#*=}" |       mode="${1#*=}" | ||||||
|       ;; |       ;; | ||||||
|  |     --user*|-u*) | ||||||
|  |       if [[ "$1" != *=* ]]; then shift; fi | ||||||
|  |       user="${1#*=}" | ||||||
|  |       ;; | ||||||
|     --help|-h) |     --help|-h) | ||||||
|       echo "--help -h: print this message" |       echo "--help -h: print this message" | ||||||
|       echo "--target -t: set the target system to install on" |       echo "--target -t: set the target system to rebuild on" | ||||||
|       echo "--flake -f: set the flake to install on the target system" |       echo "--flake -f: set the flake to rebuild on the target system" | ||||||
|       echo "--user -u: set the user to install flake as on the target system" |       echo "--mode -m: set the mode to rebuild flake as on the target system" | ||||||
|  |       echo "--user -u: set the user to rebuild flake as on the target system" | ||||||
|       exit 0 |       exit 0 | ||||||
|       ;; |       ;; | ||||||
|     *) |     *) | ||||||
|  | @ -32,10 +37,11 @@ done | ||||||
| target=${target:-$(hostname)} | target=${target:-$(hostname)} | ||||||
| flake=${flake:-$target} | flake=${flake:-$target} | ||||||
| mode=${mode:-switch} | mode=${mode:-switch} | ||||||
|  | user=${user:-$USER} | ||||||
| 
 | 
 | ||||||
| if [[ "$target" == "$(hostname)" ]] | if [[ "$target" == "$(hostname)" ]] | ||||||
| then | then | ||||||
| 	nixos-rebuild $mode --use-remote-sudo --flake .#$flake | 	nixos-rebuild $mode --use-remote-sudo --flake .#$flake | ||||||
| else | else | ||||||
| 	nixos-rebuild $mode --use-remote-sudo --target-host $USER@$target --flake .#$flake | 	nixos-rebuild $mode --use-remote-sudo --target-host $user@$target --flake .#$flake | ||||||
| fi | fi | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue