From a9c96ade19695dee421094fc5ab1d377ea1b64c7 Mon Sep 17 00:00:00 2001 From: Jake Ginesin Date: Sun, 9 Feb 2025 03:18:59 -0500 Subject: [PATCH] 314 current 2025-02-09 03:18:46 25.05.20241217.d3c42f1 6.6.66 * --- home/home.nix | 10 ++-- home/scripts/bluetooth/gb.sh | 2 - home/scripts/bspwm/dupe-display.sh | 1 - home/scripts/bspwm/fast-shift.sh | 1 - home/scripts/bspwm/reset-duplicate.sh | 1 - home/scripts/bspwm/swap-desktop.sh | 1 - home/scripts/music/ytdl.sh | 2 - home/scripts/phone-mount/phone-mount.sh | 2 - home/scripts/phone-mount/phone-unmount.sh | 2 - home/scripts/rebuild.sh | 67 +++++++++++++++++++++++ 10 files changed, 72 insertions(+), 17 deletions(-) create mode 100644 home/scripts/rebuild.sh diff --git a/home/home.nix b/home/home.nix index 3608d2d..25831be 100644 --- a/home/home.nix +++ b/home/home.nix @@ -16,11 +16,11 @@ in { ./fonts/default.nix # need to manage fonts in two places becuase life sucks nix sucks ]; - home.activation.copyScripts = lib.mkAfter '' - mkdir -p ~/.scripts - cp ${./nixos-rebuild.sh} ~/.scripts/ - chmod -R u+w ~/.scripts/ - ''; + # home.activation.copyScripts = lib.mkAfter '' + # mkdir -p ~/.scripts + # cp ${./nixos-rebuild.sh} ~/.scripts/ + # chmod -R u+w ~/.scripts/ + # ''; home.stateVersion = "24.11"; # Please read the comment before changing. diff --git a/home/scripts/bluetooth/gb.sh b/home/scripts/bluetooth/gb.sh index d4546f0..53e8543 100644 --- a/home/scripts/bluetooth/gb.sh +++ b/home/scripts/bluetooth/gb.sh @@ -1,5 +1,3 @@ -#!/bin/bash - if [[ $(bluetoothctl devices) == "No default controller available" ]]; then echo "click the bluetooth button lol" exit 1 diff --git a/home/scripts/bspwm/dupe-display.sh b/home/scripts/bspwm/dupe-display.sh index 760b691..8fb4ef0 100644 --- a/home/scripts/bspwm/dupe-display.sh +++ b/home/scripts/bspwm/dupe-display.sh @@ -1,4 +1,3 @@ -#!/bin/bash xrandr --output HDMI-2 --mode 1920x1080 --same-as eDP-1 --scale 1x1 bspc desktop Desktop --remove bspc wm -r diff --git a/home/scripts/bspwm/fast-shift.sh b/home/scripts/bspwm/fast-shift.sh index 637f93a..d16f1c8 100644 --- a/home/scripts/bspwm/fast-shift.sh +++ b/home/scripts/bspwm/fast-shift.sh @@ -1,4 +1,3 @@ -#!/bin/bash shift="$1" current=$(bspc query -D -d --names) #echo "$(($current + 1))" diff --git a/home/scripts/bspwm/reset-duplicate.sh b/home/scripts/bspwm/reset-duplicate.sh index 8828c9c..0e39e26 100644 --- a/home/scripts/bspwm/reset-duplicate.sh +++ b/home/scripts/bspwm/reset-duplicate.sh @@ -1,4 +1,3 @@ -#!/bin/bash xrandr --output HDMI-1 --off xrandr --output HDMI-2 --off xrandr --output eDP-1 --mode 1920x1080 --primary diff --git a/home/scripts/bspwm/swap-desktop.sh b/home/scripts/bspwm/swap-desktop.sh index 7a22231..9b3546b 100644 --- a/home/scripts/bspwm/swap-desktop.sh +++ b/home/scripts/bspwm/swap-desktop.sh @@ -1,4 +1,3 @@ -#!/bin/bash # swaps the current desktop with selected shift="$1" current=$(bspc query -D -d --names) diff --git a/home/scripts/music/ytdl.sh b/home/scripts/music/ytdl.sh index b87ca73..d439dfe 100644 --- a/home/scripts/music/ytdl.sh +++ b/home/scripts/music/ytdl.sh @@ -1,5 +1,3 @@ -#!/bin/sh - usage() { echo "Usage: ./ytdl [URL] [options]" echo "Download an mp3 from a given URL, process it, and optionally move it to the music directory." diff --git a/home/scripts/phone-mount/phone-mount.sh b/home/scripts/phone-mount/phone-mount.sh index 78053b9..0a687a3 100644 --- a/home/scripts/phone-mount/phone-mount.sh +++ b/home/scripts/phone-mount/phone-mount.sh @@ -1,5 +1,3 @@ -#!/bin/bash - MOUNT_POINT="/home/synchronous/android_phone" # Check if mount point exists, if not, create it diff --git a/home/scripts/phone-mount/phone-unmount.sh b/home/scripts/phone-mount/phone-unmount.sh index aa1aaf5..3414934 100644 --- a/home/scripts/phone-mount/phone-unmount.sh +++ b/home/scripts/phone-mount/phone-unmount.sh @@ -1,5 +1,3 @@ -#!/bin/bash - MOUNT_POINT="/home/synchronous/android_phone" fusermount -u $MOUNT_POINT rm -rf $MOUNT_POINT diff --git a/home/scripts/rebuild.sh b/home/scripts/rebuild.sh new file mode 100644 index 0000000..084d5d1 --- /dev/null +++ b/home/scripts/rebuild.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +# blatently adapted from: https://gist.github.com/0atman/1a5133b842f929ba4c1e195ee67599d5 + +# set -e + +# cd to your config dir +pushd /home/synchronous/nix-cfg + +# early return if no changes are given +git --git-dir /home/synchronous/nix-cfg/.git add . +if git --git-dir /home/synchronous/nix-cfg/.git diff-index --quiet HEAD; then + echo "No changes detected, exiting." + popd + exit 0 +fi + +/run/current-system/sw/bin/nix flake check /home/synchronous/nix-cfg/ + +# Autoformat your nix files +alejandra . &>/dev/null \ + || ( alejandra . ; echo "formatting failed!" && exit 1) + +# shows changes between last commit and head + +# git --git-dir /home/synchronous/nix-cfg/.git add . +# git --git-dir /home/synchronous/nix-cfg/.git --no-pager diff -U0 +git --git-dir /home/synchronous/nix-cfg/.git --no-pager diff HEAD -U0 +# '*.nix' + +echo "" +echo "Summary:" +git status --porcelain + +echo "" +echo "NixOS Rebuilding..." + +# Rebuild, output simplified errors, log trackebacks +sudo /run/current-system/sw/bin/nixos-rebuild switch --flake /home/synchronous/nix-cfg/flake.nix &> /tmp/nixos-switch.log +# cat /tmp/nixos-switch.log | grep --color error && exit 1 + +if grep --color error /tmp/nixos-switch.log; then + # cat /tmp/nixos-switch.log | grep --color error + read -p "Would you like to view the error log? (y/n): " choice + choice=${choice:-n} + if [[ "$choice" == "y" || "$choice" == "Y" ]]; then + cat /tmp/nixos-switch.log + fi + exit 1; +fi + +# Get current generation metadata +current=$(nixos-rebuild list-generations | grep current) + +# Commit all changes witih the generation metadata +git --git-dir /home/synchronous/nix-cfg/.git add . +git --git-dir /home/synchronous/nix-cfg/.git commit -am "$current" + +# Back to where you were +popd + +# rm /tmp/nixos-switch.log + +# Notify all OK! +notify-send -e "NixOS Rebuilt OK!" --icon=software-update-available + +echo "" +echo "Full rebuild log in /tmp/nixos-switch.log"