(desktop) Gen 490: split nixcommit into two scripts, one for committing one for pushing. also renamed nixswitch to rebuild
This commit is contained in:
BIN
media/sound/gitcommit.wav
Normal file
BIN
media/sound/gitcommit.wav
Normal file
Binary file not shown.
@@ -25,7 +25,7 @@ let
|
|||||||
toggle_float = (import ./wm-controls/toggle_float.nix { self = self; pkgs = pkgs;});
|
toggle_float = (import ./wm-controls/toggle_float.nix { self = self; pkgs = pkgs;});
|
||||||
toggle_oppacity = (import ./wm-controls/toggle_oppacity.nix { self = self; pkgs = pkgs;});
|
toggle_oppacity = (import ./wm-controls/toggle_oppacity.nix { self = self; pkgs = pkgs;});
|
||||||
toggle_waybar = (import ./wm-controls/toggle_waybar.nix { self = self; pkgs = pkgs;});
|
toggle_waybar = (import ./wm-controls/toggle_waybar.nix { self = self; pkgs = pkgs;});
|
||||||
nixswitch = (import ./nix/nixswitch.nix { host = host; self = self; pkgs = pkgs;});
|
rebuild = (import ./nix/rebuild.nix { host = host; self = self; pkgs = pkgs;});
|
||||||
nixcommit = (import ./nix/nixcommit.nix { host = host; self = self; pkgs = pkgs;});
|
nixcommit = (import ./nix/nixcommit.nix { host = host; self = self; pkgs = pkgs;});
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
@@ -45,7 +45,7 @@ in
|
|||||||
nixcommit
|
nixcommit
|
||||||
nixp
|
nixp
|
||||||
nixr
|
nixr
|
||||||
nixswitch
|
rebuild
|
||||||
nsp
|
nsp
|
||||||
runbg
|
runbg
|
||||||
scheck
|
scheck
|
||||||
|
|||||||
@@ -7,23 +7,37 @@ pkgs.writeShellScriptBin "nixcommit" (''
|
|||||||
scheck && runbg aplay ${self}/media/sound/nixswitch-start.wav
|
scheck && runbg aplay ${self}/media/sound/nixswitch-start.wav
|
||||||
builtin cd "$HOME/sysflakes" || exit
|
builtin cd "$HOME/sysflakes" || exit
|
||||||
nix flake update
|
nix flake update
|
||||||
|
|
||||||
if [ -n "$2" ]; then
|
if [ -n "$2" ]; then
|
||||||
echo "too many arguments"
|
echo "too many arguments"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gen=$(readlink /nix/var/nix/profiles/system | sed 's/.*system-\([0-9]*\)-link/\1/')
|
|
||||||
gen=$((gen + 1))
|
|
||||||
|
|
||||||
diffcheck=$(git status | grep "working tree clean")
|
diffcheck=$(git status | grep "working tree clean")
|
||||||
if [ -n "$diffcheck" ]; then
|
if [ -n "$diffcheck" ]; then
|
||||||
scheck && runbg aplay ${self}/media/sound/warning.wav
|
scheck && runbg aplay ${self}/media/sound/warning.wav
|
||||||
echo "Nothing to commit"
|
echo "Nothing to commit"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git add .
|
git add .
|
||||||
|
|
||||||
|
# Automatic fixup commit to the most recent commit (HEAD~1)
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
commits=$(git log origin/$(git rev-parse --abbrev-ref HEAD)..HEAD --oneline)
|
||||||
|
if [ -n "$commits" ]; then
|
||||||
|
git commit --fixup HEAD
|
||||||
|
else
|
||||||
|
echo "No prior local commits to squash into, please provide a commit message"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Generate the system generation number
|
||||||
|
gen=$(readlink /nix/var/nix/profiles/system | sed 's/.*system-\([0-9]*\)-link/\1/')
|
||||||
|
gen=$((gen + 1))
|
||||||
git commit -m "(${host}) Gen $gen: $1"
|
git commit -m "(${host}) Gen $gen: $1"
|
||||||
git push
|
fi
|
||||||
scheck && runbg aplay ${self}/media/sound/gitpush.wav
|
|
||||||
|
scheck && runbg aplay ${self}/media/sound/gitcommit.wav
|
||||||
builtin cd - || exit
|
builtin cd - || exit
|
||||||
'')
|
'')
|
||||||
|
|||||||
24
modules/home/scripts/nix/nixpush.nix
Normal file
24
modules/home/scripts/nix/nixpush.nix
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{ self, pkgs }:
|
||||||
|
|
||||||
|
|
||||||
|
pkgs.writeShellScriptBin "nixpush" (''
|
||||||
|
#!/run/current-system/sw/bin/bash
|
||||||
|
|
||||||
|
scheck && runbg aplay ${self}/media/sound/nixswitch-start.wav
|
||||||
|
set -e
|
||||||
|
pushd "$HOME/sysflakes"
|
||||||
|
|
||||||
|
commits=$(git log origin/$(git rev-parse --abbrev-ref HEAD)..HEAD --oneline)
|
||||||
|
if [ -z "$commits" ]; then
|
||||||
|
scheck && runbg aplay ${self}/media/sound/warning.wav
|
||||||
|
echo "Nothing to push"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Pushing the following commits upstream on branch '$(git branch | rg "\*" | awk '{print $2}')'"
|
||||||
|
echo "$commits"
|
||||||
|
|
||||||
|
git push
|
||||||
|
scheck && runbg aplay ${self}/media/sound/gitpush.wav
|
||||||
|
popd
|
||||||
|
'')
|
||||||
@@ -1,18 +1,20 @@
|
|||||||
{ host, self, pkgs }:
|
{ host, self, pkgs }:
|
||||||
|
|
||||||
|
|
||||||
pkgs.writeShellScriptBin "nixswitch" (''
|
pkgs.writeShellScriptBin "rebuild" (''
|
||||||
#!/run/current-system/sw/bin/bash
|
#!/run/current-system/sw/bin/bash
|
||||||
|
|
||||||
scheck && runbg aplay ${self}/media/sound/nixswitch-start.wav
|
scheck && runbg aplay ${self}/media/sound/nixswitch-start.wav
|
||||||
builtin cd "$HOME/sysflakes" || exit
|
set -e
|
||||||
|
pushd "$HOME/sysflakes"
|
||||||
|
|
||||||
nix flake update
|
nix flake update
|
||||||
|
git diff
|
||||||
sudo nixos-rebuild switch --flake "$HOME/sysflakes#${host}"
|
sudo nixos-rebuild switch --flake "$HOME/sysflakes#${host}"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
scheck && runbg aplay ${self}/media/sound/update.wav
|
scheck && runbg aplay ${self}/media/sound/update.wav
|
||||||
else
|
else
|
||||||
scheck && runbg aplay ${self}/media/sound/error.wav
|
scheck && runbg aplay ${self}/media/sound/error.wav
|
||||||
fi
|
fi
|
||||||
builtin cd "$OLDPWD" || exit
|
popd
|
||||||
'')
|
'')
|
||||||
Reference in New Issue
Block a user