(desktop) Gen 494: reformatted several files using alejandra

This commit is contained in:
pagedMov
2024-10-15 20:16:32 -04:00
parent 1441353258
commit bd1add14bb
98 changed files with 6440 additions and 3256 deletions

View File

@@ -1,31 +1,32 @@
{ self, pkgs }:
{
self,
pkgs,
}:
pkgs.writeShellScriptBin "garbage-collect" ''
#!/run/current-system/sw/bin/bash
pkgs.writeShellScriptBin "garbage-collect" (''
#!/run/current-system/sw/bin/bash
echo "This will delete all unused paths in the nix store and delete any files in the gtrash folder."
echo -e "\033[1;4;38;2;243;139;168mThis process is irreversible.\033[0m Are you sure?"
select yn in "Yes" "No"; do
case $yn in
Yes ) echo "Sweeping system...";scheck && runbg aplay "$HOME/media/sound/sys/collectgarbage.wav";break;;
No ) echo "Canceling garbage collection."; return;;
esac
done
output=$(nix-collect-garbage | tee /dev/tty)
nix_freed=$(echo "$output" | grep -oP '\d+(\.\d+)? MiB freed' | cut -d' ' -f1)
echo "This will delete all unused paths in the nix store and delete any files in the gtrash folder."
echo -e "\033[1;4;38;2;243;139;168mThis process is irreversible.\033[0m Are you sure?"
select yn in "Yes" "No"; do
case $yn in
Yes ) echo "Sweeping system...";scheck && runbg aplay "$HOME/media/sound/sys/collectgarbage.wav";break;;
No ) echo "Canceling garbage collection."; return;;
esac
done
output=$(nix-collect-garbage | tee /dev/tty)
nix_freed=$(echo "$output" | grep -oP '\d+(\.\d+)? MiB freed' | cut -d' ' -f1)
if [ "$(ls -A ~/.local/share/Trash/files/ 2>/dev/null)" ]; then
rm_freed=$(du ~/.local/share/Trash/files 2> /dev/null | awk '{print $1}')
rm_freed=$(echo "scale=2; $rm_freed / 1000" | bc)
/run/current-system/sw/bin/rm -rfv ~/.local/share/Trash/files
mkdir ~/.local/share/Trash/files
else
rm_freed="0"
fi
total_freed=$(echo "$nix_freed + $rm_freed" | bc)
echo -e "System cleaning complete, freed \033[1;4;38;2;166;227;161m$total_freed MiB\033[0m in total"
scheck && runbg aplay "$HOME/media/sound/sys/rm.wav"
'')
if [ "$(ls -A ~/.local/share/Trash/files/ 2>/dev/null)" ]; then
rm_freed=$(du ~/.local/share/Trash/files 2> /dev/null | awk '{print $1}')
rm_freed=$(echo "scale=2; $rm_freed / 1000" | bc)
/run/current-system/sw/bin/rm -rfv ~/.local/share/Trash/files
mkdir ~/.local/share/Trash/files
else
rm_freed="0"
fi
total_freed=$(echo "$nix_freed + $rm_freed" | bc)
echo -e "System cleaning complete, freed \033[1;4;38;2;166;227;161m$total_freed MiB\033[0m in total"
scheck && runbg aplay "$HOME/media/sound/sys/rm.wav"
''

View File

@@ -1,35 +1,36 @@
{ self, pkgs }:
{
self,
pkgs,
}:
pkgs.writeShellScriptBin "homep" ''
#!/run/current-system/sw/bin/bash
# Ensure the package manifest is generated or updated
if [ ! -f "/tmp/nixpkgs_manifest.txt" ]; then
echo "Generating Nixpkgs manifest..."
nix-env -qaP 2>/dev/null | awk '{print $1}' | sed 's/nixos\.//' > /tmp/nixpkgs_manifest.txt
fi
pkgs.writeShellScriptBin "homep" (''
#!/run/current-system/sw/bin/bash
# Select packages using fzf with multi-select enabled
selected_packages=$(cat /tmp/nixpkgs_manifest.txt | fzf -m)
# Ensure the package manifest is generated or updated
if [ ! -f "/tmp/nixpkgs_manifest.txt" ]; then
echo "Generating Nixpkgs manifest..."
nix-env -qaP 2>/dev/null | awk '{print $1}' | sed 's/nixos\.//' > /tmp/nixpkgs_manifest.txt
fi
# Check if any packages were selected
if [ -n "$selected_packages" ]; then
echo "$selected_packages" | while read -r package; do
# Append each selected package to the Nix config file
sed -i "/^\t]/i \ \t\t$package" "$HOME/sysflakes/glasshouse-desktop/home/userpkgs.nix"
echo "Added $package to the Home Manager configuration."
done
# Select packages using fzf with multi-select enabled
selected_packages=$(cat /tmp/nixpkgs_manifest.txt | fzf -m)
echo "Packages added successfully. Rebuild system config?"
select yn in "Yes" "No"; do
case $yn in
"Yes" ) nixswitch;break;;
"No" ) exit;;
esac
done
# Check if any packages were selected
if [ -n "$selected_packages" ]; then
echo "$selected_packages" | while read -r package; do
# Append each selected package to the Nix config file
sed -i "/^\t]/i \ \t\t$package" "$HOME/sysflakes/glasshouse-desktop/home/userpkgs.nix"
echo "Added $package to the Home Manager configuration."
done
echo "Packages added successfully. Rebuild system config?"
select yn in "Yes" "No"; do
case $yn in
"Yes" ) nixswitch;break;;
"No" ) exit;;
esac
done
else
echo "No packages selected."
fi
'')
else
echo "No packages selected."
fi
''

View File

@@ -1,29 +1,30 @@
{ self, pkgs }:
{
self,
pkgs,
}:
pkgs.writeShellScriptBin "homer" ''
#!/run/current-system/sw/bin/bash
selected_packages=$(sed -n '/\[/,/\]/p' "$HOME/sysflakes/glasshouse-desktop/home/userpkgs.nix" | sed '1d;$d' | fzf -m)
pkgs.writeShellScriptBin "homer" (''
#!/run/current-system/sw/bin/bash
if [ -n "$selected_packages" ]; then
echo "$selected_packages" | while read -r package; do
sed -i "/\b$package\b/d" "$HOME/sysflakes/glasshouse-desktop/home/userpkgs.nix"
echo "Removed $package from the Home Manager configuration."
done
selected_packages=$(sed -n '/\[/,/\]/p' "$HOME/sysflakes/glasshouse-desktop/home/userpkgs.nix" | sed '1d;$d' | fzf -m)
echo "Removed packages. Rebuild system config?"
select yn in "Yes" "No"; do
case $yn in
"Yes" ) nixswitch;break;;
"No" ) exit;;
esac
done
if [ -n "$selected_packages" ]; then
echo "$selected_packages" | while read -r package; do
sed -i "/\b$package\b/d" "$HOME/sysflakes/glasshouse-desktop/home/userpkgs.nix"
echo "Removed $package from the Home Manager configuration."
done
echo "Removed packages. Rebuild system config?"
select yn in "Yes" "No"; do
case $yn in
"Yes" ) nixswitch;break;;
"No" ) exit;;
esac
done
else
echo "No packages removed."
fi
else
echo "No packages removed."
fi
'')
''

View File

@@ -1,46 +1,49 @@
{ self, pkgs, host}:
{
self,
pkgs,
host,
}:
pkgs.writeShellScriptBin "nixcommit" ''
#!/run/current-system/sw/bin/bash
scheck && runbg aplay ${self}/media/sound/nixswitch-start.wav
builtin cd "$HOME/sysflakes" || exit
nix flake update
pkgs.writeShellScriptBin "nixcommit" (''
#!/run/current-system/sw/bin/bash
if [ -n "$2" ]; then
echo "too many arguments"
exit
fi
scheck && runbg aplay ${self}/media/sound/nixswitch-start.wav
builtin cd "$HOME/sysflakes" || exit
nix flake update
diffcheck=$(git status | grep "working tree clean")
if [ -n "$diffcheck" ]; then
scheck && runbg aplay ${self}/media/sound/warning.wav
echo "Nothing to commit"
exit
fi
if [ -n "$2" ]; then
echo "too many arguments"
exit
fi
alejandra . &> /dev/null
git add .
diffcheck=$(git status | grep "working tree clean")
if [ -n "$diffcheck" ]; then
scheck && runbg aplay ${self}/media/sound/warning.wav
echo "Nothing to commit"
exit
fi
# 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
echo "No commit message given"
echo "Squashing into most recent commit"
git rebase --autosquash master
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"
fi
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
echo "No commit message given"
echo "Squashing into most recent commit"
git rebase --autosquash master
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"
fi
scheck && runbg aplay ${self}/media/sound/gitcommit.wav
builtin cd - || exit
'')
scheck && runbg aplay ${self}/media/sound/gitcommit.wav
builtin cd - || exit
''

View File

@@ -1,35 +1,36 @@
{ self, pkgs }:
{
self,
pkgs,
}:
pkgs.writeShellScriptBin "nixp" ''
#!/run/current-system/sw/bin/bash
# Ensure the package manifest is generated or updated
if [ ! -f "/tmp/nixpkgs_manifest.txt" ]; then
echo "Generating Nixpkgs manifest..."
nix-env -qaP 2>/dev/null | awk '{print $1}' | sed 's/nixos\.//' > /tmp/nixpkgs_manifest.txt
fi
pkgs.writeShellScriptBin "nixp" (''
#!/run/current-system/sw/bin/bash
# Select packages using fzf with multi-select enabled
selected_packages=$(cat /tmp/nixpkgs_manifest.txt | fzf -m)
# Ensure the package manifest is generated or updated
if [ ! -f "/tmp/nixpkgs_manifest.txt" ]; then
echo "Generating Nixpkgs manifest..."
nix-env -qaP 2>/dev/null | awk '{print $1}' | sed 's/nixos\.//' > /tmp/nixpkgs_manifest.txt
fi
# Check if any packages were selected
if [ -n "$selected_packages" ]; then
echo "$selected_packages" | while read -r package; do
# Append each selected package to the Nix config file
sed -i "/^\t]/i \ \t\t$package" "$HOME/sysflakes/glasshouse-desktop/sys/packages.nix"
echo "Added $package to the Nix configuration."
done
# Select packages using fzf with multi-select enabled
selected_packages=$(cat /tmp/nixpkgs_manifest.txt | fzf -m)
echo "Packages added successfully. Rebuild system config?"
select yn in "Yes" "No"; do
case $yn in
"Yes" ) nixswitch;break;;
"No" ) exit;;
esac
done
# Check if any packages were selected
if [ -n "$selected_packages" ]; then
echo "$selected_packages" | while read -r package; do
# Append each selected package to the Nix config file
sed -i "/^\t]/i \ \t\t$package" "$HOME/sysflakes/glasshouse-desktop/sys/packages.nix"
echo "Added $package to the Nix configuration."
done
echo "Packages added successfully. Rebuild system config?"
select yn in "Yes" "No"; do
case $yn in
"Yes" ) nixswitch;break;;
"No" ) exit;;
esac
done
else
echo "No packages selected."
fi
'')
else
echo "No packages selected."
fi
''

View File

@@ -1,24 +1,25 @@
{ self, pkgs }:
{
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"
pkgs.writeShellScriptBin "nixpush" (''
#!/run/current-system/sw/bin/bash
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
scheck && runbg aplay ${self}/media/sound/nixswitch-start.wav
set -e
pushd "$HOME/sysflakes"
echo "Pushing the following commits upstream on branch '$(git branch | rg "\*" | awk '{print $2}')'"
echo "$commits"
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
'')
git push
scheck && runbg aplay ${self}/media/sound/gitpush.wav
popd
''

View File

@@ -1,29 +1,30 @@
{ self, pkgs }:
{
self,
pkgs,
}:
pkgs.writeShellScriptBin "nixr" ''
#!/run/current-system/sw/bin/bash
selected_packages=$(sed -n '/\[/,/\]/p' "$HOME/sysflakes/glasshouse-desktop/sys/packages.nix" | sed '1d;$d' | fzf -m)
pkgs.writeShellScriptBin "nixr" (''
#!/run/current-system/sw/bin/bash
if [ -n "$selected_packages" ]; then
echo "$selected_packages" | while read -r package; do
sed -i "/\b$package\b/d" "$HOME/sysflakes/glasshouse-desktop/sys/packages.nix"
echo "Removed $package from the Nix configuration."
done
selected_packages=$(sed -n '/\[/,/\]/p' "$HOME/sysflakes/glasshouse-desktop/sys/packages.nix" | sed '1d;$d' | fzf -m)
echo "Removed packages. Rebuild system config?"
select yn in "Yes" "No"; do
case $yn in
"Yes" ) nixswitch;break;;
"No" ) exit;;
esac
done
if [ -n "$selected_packages" ]; then
echo "$selected_packages" | while read -r package; do
sed -i "/\b$package\b/d" "$HOME/sysflakes/glasshouse-desktop/sys/packages.nix"
echo "Removed $package from the Nix configuration."
done
echo "Removed packages. Rebuild system config?"
select yn in "Yes" "No"; do
case $yn in
"Yes" ) nixswitch;break;;
"No" ) exit;;
esac
done
else
echo "No packages removed."
fi
else
echo "No packages removed."
fi
'')
''

View File

@@ -1,8 +1,9 @@
{ self, pkgs }:
{
self,
pkgs,
}:
pkgs.writeShellScriptBin "nsp" ''
#!/run/current-system/sw/bin/bash
pkgs.writeShellScriptBin "nsp" (''
#!/run/current-system/sw/bin/bash
nix-shell -p "$@" --run zsh
'')
nix-shell -p "$@" --run zsh
''

View File

@@ -1,20 +1,21 @@
{ host, self, pkgs }:
{
host,
self,
pkgs,
}:
pkgs.writeShellScriptBin "rebuild" ''
#!/run/current-system/sw/bin/bash
scheck && runbg aplay ${self}/media/sound/nixswitch-start.wav
set -e
pushd "$HOME/sysflakes"
pkgs.writeShellScriptBin "rebuild" (''
#!/run/current-system/sw/bin/bash
scheck && runbg aplay ${self}/media/sound/nixswitch-start.wav
set -e
pushd "$HOME/sysflakes"
nix flake update
git diff
sudo nixos-rebuild switch --flake "$HOME/sysflakes#${host}"
if [ $? -eq 0 ]; then
scheck && runbg aplay ${self}/media/sound/update.wav
else
scheck && runbg aplay ${self}/media/sound/error.wav
fi
popd
'')
nix flake update
sudo nixos-rebuild switch --flake "$HOME/sysflakes#${host}"
if [ $? -eq 0 ]; then
scheck && runbg aplay ${self}/media/sound/update.wav
else
scheck && runbg aplay ${self}/media/sound/error.wav
fi
popd
''