305 current 2025-01-25 21:36:27 25.05.20241217.d3c42f1 6.6.66 *
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
#!/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
|
||||
|
||||
# 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"
|
||||
16
home/scripts/termbin/tb.nix
Normal file
16
home/scripts/termbin/tb.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
# scripts.nix
|
||||
{pkgs, ...}: {
|
||||
home.packages = with pkgs; [
|
||||
(writeShellApplication {
|
||||
name = "termbin";
|
||||
runtimeInputs = with pkgs; [
|
||||
netcat
|
||||
];
|
||||
|
||||
text = ''
|
||||
file=$1
|
||||
cat "$1" | nc termbin.com 9999
|
||||
'';
|
||||
})
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user