From e9008a62680d9528178a9797519d67560c3bf24f Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L. de Mello" Date: Thu, 25 Jan 2024 22:27:10 -0300 Subject: [PATCH] revert: remove decoration from homelab command --- modules/nixos/homelab/default.nix | 60 ++----------------------------- 1 file changed, 2 insertions(+), 58 deletions(-) diff --git a/modules/nixos/homelab/default.nix b/modules/nixos/homelab/default.nix index 737b5ab..a2d4aef 100644 --- a/modules/nixos/homelab/default.nix +++ b/modules/nixos/homelab/default.nix @@ -2,71 +2,15 @@ let cfg = config.homelab; - homelab-build = pkgs.writeShellScriptBin "homelab-build" '' - flakeDir="${toString cfg.flakeDir}"; - gum="${pkgs.gum}/bin/gum" - interactive="$1" - shift 1; - - function rebuild() { - - local sleep_killed="false"; - local sleep_pid="$(ps -fu $USER | grep "sleep" | grep -v "grep" | awk '{print $2}')"; - - while IFS= read -r LINE; do - if [[ "$sleep_killed" == "false" ]]; then - kill -9 $sleep_pid; # I don't know to hide the message from this command :/ - sleep_killed="true"; - fi - - $gum log --structured --time timeonly --level info "$LINE" - done < <(stdbuf -oL nixos-rebuild switch --flake "$flakeDir" "$@") - - if [[ "$sleep_killed" == "false" ]]; then - kill -9 $sleep_pid; - sleep_killed="true"; - fi - - local gum_pid="$(ps -fu $USER | grep "/bin/gum" | grep -v "grep" | awk '{print $2}')"; - - kill -9 $gum_pid; # it's kinda ugly this code in general, but whatever, at least the output is pretty - } - - function spin() { - sleep 1000; - $gum spin --title "Activating build" -- sleep 1000; - } - - if [[ "$interactive" == "true" ]]; then - $gum log --structured --time timeonly --level info "Building homelab" command "nixos-rebuild switch --flake $flakeDir $@" - rebuild "$@" & spin; - else - nixos-rebuild switch --flake "$flakeDir" "$@"; - fi - ''; homelab = pkgs.writeShellScriptBin "homelab" '' gum="${pkgs.gum}/bin/gum"; - interactive="true"; + flakeDir="${toString cfg.flakeDir}"; command="$1"; - if [[ "$@" == *"--verbose"* ]]; then - interactive="false"; - elif [[ "$1" == *"--not-interactive"* ]]; then - interactive="false"; - shift 1; - command="$1"; - fi - if [[ "$command" == "build" ]]; then shift 1; - sudo ${homelab-build}/bin/homelab-build "$interactive" "$@"; - - if [[ "$interactive" == "true" && "$?" == 0 ]]; then - $gum log --structured --time timeonly --level info "Reseting terminal in 5 seconds..." - sleep 5 - reset - fi + sudo nixos-rebuild switch --flake "$flakeDir" "$@" fi ${if cfg.forgejo.cliAlias then ''