From 9518f12e3472fc516536b3d9c1d9c5ad42d84078 Mon Sep 17 00:00:00 2001 From: joy Date: Sat, 31 Aug 2024 16:55:57 +0200 Subject: [PATCH] better rb.sh --- modules/apps/zsh/default.nix | 6 +++--- modules/apps/zsh/scripts/rebuild.sh | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/modules/apps/zsh/default.nix b/modules/apps/zsh/default.nix index b492bc9..06152fe 100644 --- a/modules/apps/zsh/default.nix +++ b/modules/apps/zsh/default.nix @@ -13,11 +13,11 @@ cat = "bat"; cn = "cd ~/nix"; ls = "${pkgs.eza}/bin/eza --icons -a --group-directories-first"; - pu = "sh ~/nix/modules/zsh/scripts/push.sh"; - ip = "sh ~/nix/modules/zsh/scripts/ip.sh"; + pu = "sh ~/nix/modules/apps/zsh/scripts/push.sh"; + ip = "sh ~/nix/modules/apps/zsh/scripts/ip.sh"; fr = "sudo systemctl reboot --firmware"; ser = "ssh root@joygnu.org"; - rb = "sh ~/nix/modules/zsh/scripts/rebuild.sh"; + rb = "sh ~/nix/modules/apps/zsh/scripts/rebuild.sh"; up = "sudo nix flake update ~/nix"; del = "sudo nix-collect-garbage -d"; }; diff --git a/modules/apps/zsh/scripts/rebuild.sh b/modules/apps/zsh/scripts/rebuild.sh index 77032a9..11d65a3 100755 --- a/modules/apps/zsh/scripts/rebuild.sh +++ b/modules/apps/zsh/scripts/rebuild.sh @@ -1,11 +1,17 @@ #!/bin/sh -hostname=$(hostname) +current_dir=$(pwd) + +cd ~/nix git add . -if [[ $hostname == *"desktop"* ]]; then +hostname=$(hostname) + +if echo "$hostname" | grep -q 'desktop'; then sudo nixos-rebuild switch --flake ~/nix/#desktop -elif [[ $hostname == *"laptop"* ]]; then +elif echo "$hostname" | grep -q 'laptop'; then sudo nixos-rebuild switch --flake ~/nix/#laptop fi + +cd "$current_dir"