diff --git a/apps/aarch64-darwin/apply b/apps/aarch64-darwin/apply index 1cad43d..bd80b87 100755 --- a/apps/aarch64-darwin/apply +++ b/apps/aarch64-darwin/apply @@ -1,28 +1,7 @@ #!/usr/bin/env bash set -euo pipefail - -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' - -print_info() { - echo -e "${BLUE}📘${NC} $1" -} - -print_success() { - echo -e "${GREEN}✅${NC} $1" -} - -print_error() { - echo -e "${RED}❌${NC} $1" -} - -print_warning() { - echo -e "${YELLOW}⚡${NC} $1" -} +source "$(dirname "$0")/../common.sh" HOSTNAME="${1:-$(scutil --get LocalHostName 2>/dev/null || hostname -s)}" @@ -30,4 +9,4 @@ print_info "Applying configuration for $HOSTNAME" nix run nix-darwin -- switch --flake ".#$HOSTNAME" "${@:2}" -print_success "Configuration applied successfully" \ No newline at end of file +print_success "Configuration applied successfully" diff --git a/apps/aarch64-darwin/build b/apps/aarch64-darwin/build index 24d0136..6db64db 100755 --- a/apps/aarch64-darwin/build +++ b/apps/aarch64-darwin/build @@ -1,28 +1,7 @@ #!/usr/bin/env bash set -euo pipefail - -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' - -print_info() { - echo -e "${BLUE}📘${NC} $1" -} - -print_success() { - echo -e "${GREEN}✅${NC} $1" -} - -print_error() { - echo -e "${RED}❌${NC} $1" -} - -print_warning() { - echo -e "${YELLOW}⚡${NC} $1" -} +source "$(dirname "$0")/../common.sh" HOSTNAME="${1:-$(scutil --get LocalHostName 2>/dev/null || hostname -s)}" @@ -34,4 +13,4 @@ if [[ -L ./result ]]; then unlink ./result fi -print_success "Build completed successfully" \ No newline at end of file +print_success "Build completed successfully" diff --git a/apps/aarch64-darwin/build-switch b/apps/aarch64-darwin/build-switch index a0e6787..016d494 100755 --- a/apps/aarch64-darwin/build-switch +++ b/apps/aarch64-darwin/build-switch @@ -1,28 +1,7 @@ #!/usr/bin/env bash set -euo pipefail - -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' - -print_info() { - echo -e "${BLUE}📘${NC} $1" -} - -print_success() { - echo -e "${GREEN}✅${NC} $1" -} - -print_error() { - echo -e "${RED}❌${NC} $1" -} - -print_warning() { - echo -e "${YELLOW}⚡${NC} $1" -} +source "$(dirname "$0")/../common.sh" HOSTNAME="${1:-$(scutil --get LocalHostName 2>/dev/null || hostname -s)}" @@ -45,4 +24,4 @@ if [[ -L ./result ]]; then unlink ./result fi -print_success "Build and switch completed successfully" \ No newline at end of file +print_success "Build and switch completed successfully" diff --git a/apps/aarch64-darwin/rollback b/apps/aarch64-darwin/rollback index 48f0dd7..f2b9050 100755 --- a/apps/aarch64-darwin/rollback +++ b/apps/aarch64-darwin/rollback @@ -1,28 +1,7 @@ #!/usr/bin/env bash set -euo pipefail - -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' - -print_info() { - echo -e "${BLUE}📘${NC} $1" -} - -print_success() { - echo -e "${GREEN}✅${NC} $1" -} - -print_error() { - echo -e "${RED}❌${NC} $1" -} - -print_warning() { - echo -e "${YELLOW}⚡${NC} $1" -} +source "$(dirname "$0")/../common.sh" print_info "Available generations:" darwin-rebuild --list-generations @@ -38,4 +17,4 @@ fi print_warning "Rolling back to generation $GEN_NUM..." darwin-rebuild switch --switch-generation "$GEN_NUM" -print_success "Rollback to generation $GEN_NUM complete" \ No newline at end of file +print_success "Rollback to generation $GEN_NUM complete" diff --git a/apps/common.sh b/apps/common.sh new file mode 100644 index 0000000..ea1248c --- /dev/null +++ b/apps/common.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +print_info() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +print_success() { + echo -e "${GREEN}[OK]${NC} $1" +} + +print_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +print_warning() { + echo -e "${YELLOW}[WARN]${NC} $1" +} diff --git a/apps/x86_64-linux/apply b/apps/x86_64-linux/apply index 8661f29..48086bc 100755 --- a/apps/x86_64-linux/apply +++ b/apps/x86_64-linux/apply @@ -1,28 +1,7 @@ #!/usr/bin/env bash set -euo pipefail - -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' - -print_info() { - echo -e "${BLUE}📘${NC} $1" -} - -print_success() { - echo -e "${GREEN}✅${NC} $1" -} - -print_error() { - echo -e "${RED}❌${NC} $1" -} - -print_warning() { - echo -e "${YELLOW}⚡${NC} $1" -} +source "$(dirname "$0")/../common.sh" HOSTNAME="${1:-$(hostname)}" @@ -34,4 +13,4 @@ else nixos-rebuild switch --flake ".#$HOSTNAME" "${@:2}" fi -print_success "Configuration applied successfully" \ No newline at end of file +print_success "Configuration applied successfully" diff --git a/apps/x86_64-linux/build b/apps/x86_64-linux/build index 29a7091..9922130 100755 --- a/apps/x86_64-linux/build +++ b/apps/x86_64-linux/build @@ -1,28 +1,7 @@ #!/usr/bin/env bash set -euo pipefail - -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' - -print_info() { - echo -e "${BLUE}📘${NC} $1" -} - -print_success() { - echo -e "${GREEN}✅${NC} $1" -} - -print_error() { - echo -e "${RED}❌${NC} $1" -} - -print_warning() { - echo -e "${YELLOW}⚡${NC} $1" -} +source "$(dirname "$0")/../common.sh" HOSTNAME="${1:-$(hostname)}" @@ -34,4 +13,4 @@ if [[ -L ./result ]]; then unlink ./result fi -print_success "Build completed successfully" \ No newline at end of file +print_success "Build completed successfully" diff --git a/apps/x86_64-linux/build-switch b/apps/x86_64-linux/build-switch index d954277..a1b4068 100755 --- a/apps/x86_64-linux/build-switch +++ b/apps/x86_64-linux/build-switch @@ -1,24 +1,7 @@ #!/usr/bin/env bash set -euo pipefail - -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' - -print_info() { - echo -e "${BLUE}📘${NC} $1" -} - -print_success() { - echo -e "${GREEN}✅${NC} $1" -} - -print_error() { - echo -e "${RED}❌${NC} $1" -} +source "$(dirname "$0")/../common.sh" HOSTNAME="${1:-$(hostname)}" diff --git a/apps/x86_64-linux/rollback b/apps/x86_64-linux/rollback index ea55ef1..493263b 100644 --- a/apps/x86_64-linux/rollback +++ b/apps/x86_64-linux/rollback @@ -1,28 +1,7 @@ #!/usr/bin/env bash set -euo pipefail - -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' - -print_info() { - echo -e "${BLUE}📘${NC} $1" -} - -print_success() { - echo -e "${GREEN}✅${NC} $1" -} - -print_error() { - echo -e "${RED}❌${NC} $1" -} - -print_warning() { - echo -e "${YELLOW}⚡${NC} $1" -} +source "$(dirname "$0")/../common.sh" print_info "Available generations:" if [[ "$EUID" -ne 0 ]]; then @@ -48,4 +27,4 @@ else /nix/var/nix/profiles/system/bin/switch-to-configuration switch fi -print_success "Rollback to generation $GEN_NUM complete" \ No newline at end of file +print_success "Rollback to generation $GEN_NUM complete"