-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
81 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ let | |
"github-notifications" | ||
"screenshare" | ||
"bootstrap" | ||
"swarsel-install" | ||
"t2ts" | ||
"ts2t" | ||
"vershell" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ writeShellApplication, git }: | ||
|
||
writeShellApplication { | ||
name = "swarsel-install"; | ||
runtimeInputs = [ git ]; | ||
text = builtins.readFile ../../scripts/swarsel-install.sh; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
set -eo pipefail | ||
|
||
target_flake="chaostheatre" | ||
target_user="swarsel" | ||
|
||
function help_and_exit() { | ||
echo | ||
echo "Remotely installs NixOS on a target machine using this nix-config." | ||
echo | ||
echo "USAGE: $0 [OPTIONS]" | ||
echo | ||
echo "ARGS:" | ||
echo " -f <target_flake> specify flake to deploy the nixos config of." | ||
echo " Default: chaostheatre" | ||
echo " -u <target_user> specify user to deploy for." | ||
echo " Default: swarsel" | ||
echo " -h | --help Print this help." | ||
exit 0 | ||
} | ||
|
||
function green() { | ||
echo -e "\x1B[32m[+] $1 \x1B[0m" | ||
if [ -n "${2-}" ]; then | ||
echo -e "\x1B[32m[+] $($2) \x1B[0m" | ||
fi | ||
} | ||
function yellow() { | ||
echo -e "\x1B[33m[*] $1 \x1B[0m" | ||
if [ -n "${2-}" ]; then | ||
echo -e "\x1B[33m[*] $($2) \x1B[0m" | ||
fi | ||
} | ||
|
||
while [[ $# -gt 0 ]]; do | ||
case "$1" in | ||
-f) | ||
shift | ||
target_flake=$1 | ||
;; | ||
-u) | ||
shift | ||
target_user=$1 | ||
;; | ||
-h | --help) help_and_exit ;; | ||
*) | ||
echo "Invalid option detected." | ||
help_and_exit | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
cd /home/"$target_user" | ||
green "Cloning repository from GitHub" | ||
git clone https://github.com/Swarsel/.dotfiles.git | ||
|
||
cd .dotfiles | ||
sudo nixos-generate-config /home/"$target_user"/.dotfiles/hosts/nixos/"$target_flake"/hardware-configuration.nix | ||
git add /home/"$target_user"/.dotfiles/hosts/nixos/"$target_flake"/hardware-configuration.nix | ||
green "Installing flake $target_flake" | ||
sudo nixos-rebuild --show-trace --flake .#"$target_flake" --keep-going switch |