[O] Import nix.sh only if it's nixos

This commit is contained in:
Hykilpikonna
2021-09-16 22:11:55 -04:00
parent 76a0569938
commit 6b9a54f84a
+31 -29
View File
@@ -1,32 +1,34 @@
alias rebuild="nixos-rebuild switch"
alias gc="nix-collect-garbage -d"
alias rebuild-gc="rebuild; gc"
if command -v nixos-rebuild &> /dev/null; then
alias rebuild="nixos-rebuild switch"
alias gc="nix-collect-garbage -d"
alias rebuild-gc="rebuild; gc"
# Update git
nix-git-update() {
pushd /etc/nixos
# Make sure there aren't any other changes
if git diff-index --quiet HEAD --; then
# No changes
update-nix-fetchgit *.nix
# If there are changes after updating
if ! git diff-index --quiet HEAD --; then
# Has changes
rebuild-gc
git add *.nix
git commit -m "[U] Update fetchgit refs"
git push
echo "Successfully updated fetchgit refs"
# Update git
nix-git-update() {
pushd /etc/nixos
# Make sure there aren't any other changes
if git diff-index --quiet HEAD --; then
# No changes
update-nix-fetchgit *.nix
# If there are changes after updating
if ! git diff-index --quiet HEAD --; then
# Has changes
rebuild-gc
git add *.nix
git commit -m "[U] Update fetchgit refs"
git push
echo "Successfully updated fetchgit refs"
else
echo "There aren't any updates"
fi
else
echo "There aren't any updates"
# Changes
echo "Error: There are uncommitted changes"
git status
fi
else
# Changes
echo "Error: There are uncommitted changes"
git status
fi
popd
}
popd
}
fi